about summary refs log tree commit diff
path: root/codechef/chfdora.c
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2020-01-13 16:29:31 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2020-01-13 16:29:31 +0700
commit65b8ebda4c47fa27ac28899fb2b29097f445b6df (patch)
treee43589f1f02ab11946006b70fe79c79d82629f11 /codechef/chfdora.c
parent0887d8f96950a060a122e14ed2981182ff1eb37d (diff)
downloadcp-65b8ebda4c47fa27ac28899fb2b29097f445b6df.tar.gz
I'm so burnt out rn
Diffstat (limited to 'codechef/chfdora.c')
-rw-r--r--codechef/chfdora.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/codechef/chfdora.c b/codechef/chfdora.c
new file mode 100644
index 0000000..fc0dbf6
--- /dev/null
+++ b/codechef/chfdora.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+
+int min(int a, int b)
+{
+	return (a < b) ? a : b;
+}
+
+int main()
+{
+	int t, n, m;
+
+	scanf("%d", &t);
+	while (t--) {
+		scanf("%d %d", &n, &m);
+		size_t a[n][m];
+		for (int i = 0; i < n; ++i)
+			for (int j = 0; j < m; ++j)
+				scanf("%zu", a[i] + j);
+
+		size_t count = 0;
+		for (int i = 0; i < n; ++i)
+			for (int j = 0; j < m; ++j) {
+				int max = min(min(i, j), min(n-i, m-j)-1);
+				for (int k = 0;
+				     k <= max && a[i+k][j] == a[i-k][j]
+				              && a[i][j+k] == a[i][j-k];
+				     count++, ++k);
+			}
+		printf("%zu\n", count);
+	}
+
+	return 0;
+}