about summary refs log tree commit diff
path: root/codechef/fence.py
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-04-15 17:20:41 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-04-15 17:20:41 +0700
commit887c286cc8228e13f85b587ab92b37e920161eb9 (patch)
tree6528ca8873c4f80b6d13114550615c7a1f1f4afe /codechef/fence.py
parentebb7f33582fb24fe70f13796b88e93b99c243425 (diff)
downloadcp-887c286cc8228e13f85b587ab92b37e920161eb9.tar.gz
Codechef celebrate 4.20 a bit early this year
Diffstat (limited to 'codechef/fence.py')
-rwxr-xr-xcodechef/fence.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/codechef/fence.py b/codechef/fence.py
new file mode 100755
index 0000000..8d1b266
--- /dev/null
+++ b/codechef/fence.py
@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+ADJ = (1, 0), (0, 1), (-1, 0), (0, -1)
+
+for i in range(int(input())):
+    fences = set()
+    n, m, k = map(int, input().split())
+    for j in range(k):
+        row, col = map(int, input().split())
+        for dr, dc in ADJ:
+            r, c = row + dr, col + dc
+            try:
+                fences.remove((r, c, row, col))
+            except KeyError:
+                fences.add((row, col, r, c))
+    print(len(fences))