You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.6 KiB
C++
46 lines
1.6 KiB
C++
#include <algorithm>
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
#include <utility>
|
|
using namespace std;
|
|
typedef long long ll;
|
|
pair<ll, ll> bwcount(ll x1, ll y1, ll x2, ll y2)
|
|
{
|
|
if (x1 > x2 || y1 > y2) return make_pair(0, 0);
|
|
ll sum = (y2 - y1 + 1) * (x2 - x1 + 1);
|
|
ll c1 = (x2 - x1 + 1) >> 1, c2 = (x2 - x1 + 2) >> 1;
|
|
ll h = (y2 - y1 + 1) >> 1;
|
|
ll bcnt = h * (c1 + c2) + ((y2 - y1 + 1) & 1) * (((x1 + y1) & 1) ? c2 : c1);
|
|
return make_pair(bcnt, sum - bcnt);
|
|
}
|
|
int main()
|
|
{
|
|
while (false)
|
|
{
|
|
int x1, y1, x2, y2;
|
|
scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
|
|
auto ans = bwcount(x1, y1, x2, y2);
|
|
printf("%lld %lld\n", ans.first, ans.second);
|
|
}
|
|
ll T, n, m, x1, y1, x2, y2, x3, y3, x4, y4;
|
|
scanf("%lld", &T);
|
|
while (T--)
|
|
{
|
|
scanf("%lld%lld%lld%lld%lld%lld%lld%lld%lld%lld",
|
|
&n, &m, &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
|
|
ll sum = n * m;
|
|
ll wsum = (x2 - x1 + 1) * (y2 - y1 + 1);
|
|
ll bsum = (x4 - x3 + 1) * (y4 - y3 + 1);
|
|
auto org = bwcount(1, 1, m, n);
|
|
auto dif1 = bwcount(x1, y1, x2, y2);
|
|
auto dif2 = bwcount(x3, y3, x4, y4);
|
|
auto dif3 = bwcount(max(x1, x3), max(y1, y3), min(x2, x4), min(y2, y4));
|
|
org.first = org.first - dif1.first - dif2.first + dif3.first;
|
|
org.second = org.second - dif1.second - dif2.second + dif3.second;
|
|
org.first += bsum, org.second += wsum;
|
|
ll crs = dif3.first + dif3.second;
|
|
org.second -= crs;
|
|
printf("%lld %lld\n", org.second, org.first);
|
|
}
|
|
return 0;
|
|
} |