-
Notifications
You must be signed in to change notification settings - Fork 131
/
Copy pathSAKTAN_CODECHEF.cpp
89 lines (64 loc) · 1.21 KB
/
SAKTAN_CODECHEF.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <bits/stdc++.h>
using namespace std;
int main() {
long i, j, k, t, n, m, u, q;
cin>>t;
for(u=0; u<t; u++)
{
cin>>n;
cin>>m;
cin>>q;
map<long, long> mx;
map<long, long> my;
long o = 0;
long e = 0;
long o2 = 0;
long e2 = 0;
for(i=0; i<q; i++)
{
long x, y;
cin>>x;
cin>>y;
long a, b;
a = ++mx[x];
b = ++my[y];
if(a%2==0)
{
o--;
e++;
}
else
{
if(a==1)
{
o++;
}
else
{
o++;
e--;
}
}
if(b%2==0)
{
o2--;
e2++;
}
else
{
if(b==1)
{
o2++;
}
else
{
o2++;
e2--;
}
}
}
long ans = o*e2 + e*o2 + (n-o-e)*o2 + (m-o2-e2)*o;
cout<<ans<<"\n";
}
return 0;
}