about summary refs log tree commit diff
path: root/codechef/saktan.cc
blob: 96ef43a468b3dd2a94a9494301f45519e9f1b060 (plain) (blame)
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
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int
main()
{
  int t;
  long n, m, q, x, y;

  cin >> t;
  while (t--)
    {
      cin >> n >> m >> q;
      vector<int> u (n), v (m);

      while (q--)
        {
          cin >> x >> y;
          u[x - 1] ^= 1;
          v[y - 1] ^= 1;
        }

      x = accumulate (u.begin(), u.end(), 0);
      y = accumulate (v.begin(), v.end(), 0);
      cout << x * (m - y) + (n - x) * y << endl;
    }

  return 0;
}