Submission #543174

# Submission time Handle Problem Language Result Execution time Memory
543174 2022-03-29T15:51:41 Z rainboy Dijamant (COCI22_dijamant) C
70 / 70
122 ms 35572 KB
#include <stdio.h>

#define N	2000
#define M	2000

int main() {
	static char cc[N][M + 1];
	static int ll[N][M], rr[N][M];
	int n, m, i, i_, i1, j, cnt, good;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%s", cc[i]);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++)
			ll[i][j] = cc[i][j] == '#' ? j : (j == 0 ? -1 : ll[i][j - 1]);
		for (j = m - 1; j >= 0; j--)
			rr[i][j] = cc[i][j] == '#' ? j : (j + 1 == m ? m : rr[i][j + 1]);
	}
	cnt = 0;
	for (j = 0; j < m; j++)
		for (i_ = -1, i = 0; i < n; i++)
			if (cc[i][j] == '#') {
				if (i_ == -1 || (i - i_) % 2 != 0 || j - (i - i_) / 2 < 0 || j + (i - i_) / 2 >= m)
					good = 0;
				else {
					good = 1;
					for (i1 = i_; i1 * 2 <= i + i_; i1++)
						if (ll[i1][j] != j - (i1 - i_) || rr[i1][j] != j + (i1 - i_)
								|| ll[i + i_ - i1][j] != j - (i1 - i_) || rr[i + i_ - i1][j] != j + (i1 - i_)) {
							good = 0;
							break;
						}
				}
				if (good)
					cnt++;
				i_ = i;
			}
	printf("%d\n", cnt);
	return 0;
}

Compilation message

Main.c: In function 'main':
Main.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
Main.c:13:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |   scanf("%s", cc[i]);
      |   ^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 1 ms 1244 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1236 KB Output is correct
9 Correct 1 ms 1284 KB Output is correct
10 Correct 1 ms 1236 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 1236 KB Output is correct
13 Correct 1 ms 1236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1236 KB Output is correct
2 Correct 1 ms 1236 KB Output is correct
3 Correct 1 ms 1244 KB Output is correct
4 Correct 1 ms 1236 KB Output is correct
5 Correct 1 ms 1360 KB Output is correct
6 Correct 1 ms 1236 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1236 KB Output is correct
9 Correct 1 ms 1284 KB Output is correct
10 Correct 1 ms 1236 KB Output is correct
11 Correct 1 ms 1364 KB Output is correct
12 Correct 1 ms 1236 KB Output is correct
13 Correct 1 ms 1236 KB Output is correct
14 Correct 49 ms 33968 KB Output is correct
15 Correct 36 ms 33684 KB Output is correct
16 Correct 122 ms 33784 KB Output is correct
17 Correct 56 ms 34064 KB Output is correct
18 Correct 82 ms 35572 KB Output is correct
19 Correct 44 ms 32884 KB Output is correct
20 Correct 52 ms 35236 KB Output is correct
21 Correct 44 ms 32356 KB Output is correct
22 Correct 78 ms 35188 KB Output is correct
23 Correct 66 ms 32048 KB Output is correct
24 Correct 78 ms 34812 KB Output is correct
25 Correct 43 ms 32684 KB Output is correct
26 Correct 113 ms 32596 KB Output is correct