about summary refs log tree commit diff
path: root/codechef/saktan.cc
diff options
context:
space:
mode:
Diffstat (limited to 'codechef/saktan.cc')
-rw-r--r--codechef/saktan.cc32
1 files changed, 32 insertions, 0 deletions
diff --git a/codechef/saktan.cc b/codechef/saktan.cc
new file mode 100644
index 0000000..96ef43a
--- /dev/null
+++ b/codechef/saktan.cc
@@ -0,0 +1,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;
+}