about summary refs log tree commit diff
path: root/tht/C/TP-2017/squares.c
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2020-06-06 21:33:13 +0700
committerNguyễn Gia Phong <mcsinyx@disroot.org>2020-06-06 21:33:13 +0700
commit2f674dc80f0382f1c3178f435714960734dc9d3c (patch)
tree2abba7e4ec72bd16f58f7375126144d3fd9f4bca /tht/C/TP-2017/squares.c
parentb2d80610db6beda38573890ed169815e495bc663 (diff)
downloadcp-2f674dc80f0382f1c3178f435714960734dc9d3c.tar.gz
Reorganize stuff from secondary school
Diffstat (limited to 'tht/C/TP-2017/squares.c')
-rw-r--r--tht/C/TP-2017/squares.c59
1 files changed, 0 insertions, 59 deletions
diff --git a/tht/C/TP-2017/squares.c b/tht/C/TP-2017/squares.c
deleted file mode 100644
index 9ed7317..0000000
--- a/tht/C/TP-2017/squares.c
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-
-struct poin_t {
-	short x, y;
-};
-
-int main()
-{
-	FILE *f = fopen("squares.inp", "r");
-	short m, n, i, j, x, y, mini, maxi, minj, maxj, _minj, _maxj;
-	char k, c, net[1001][1001] = {};
-	long long count = 0;
-	struct poin_t *e;
-
-	fscanf(f, "%hd %hd %hhd\n", &m, &n, &k);
-	for (i = 1; i < MIN(m, n); i++)
-		count += (long long) i * (m - i) * (n - i);
-	e = malloc(k * sizeof(struct poin_t));
-	for (i = 0; i < k; i++) {
-		fscanf(f, "%hd %hd\n", &e[i].x, &e[i].y);
-		net[e[i].x][e[i].y] = 1;
-	}
-	fclose(f);
-
-	for (count *= 12; k--; e++) {
-		x = (*e).x;
-		y = (*e).y;
-		mini = MAX(x - m, 1 - y);
-		maxi = MIN(x - 1, n - y);
-		_minj = MAX(1 - x, 1 - y);
-		_maxj = MIN(m - x, n - y);
-		for (i = mini; i <= maxi; i++) {
-			minj = MAX(MAX(i - x + 1, 1 - y - i), _minj);
-			maxj = MIN(MIN(m - x + i, n - y - i), _maxj);
-			for (j = minj; j <= maxj; j++) {
-				if (!i && !j)
-					continue;
-				c = 1;
-				if (net[x - i][y + j])
-					c++;
-				if (net[x + j][y + i])
-					c++;
-				if (net[x - i + j][y + i + j])
-					c++;
-				count -= 12 / c;
-			}
-		}
-	}
-
-	f = fopen("squares.out", "w");
-	fprintf(f, "%Ld\n", count / 12);
-	fclose(f);
-
-	return 0;
-}