제출 #814846

#제출 시각아이디문제언어결과실행 시간메모리
814846rainboyCell Automaton (JOI23_cell)C11
4 / 100
9 ms4436 KiB
#include <stdio.h>

#define N	100000
#define T	50
#define X	100

int main() {
	static int xx[N], yy[N], nn[T + 1];
	static char cc[T + 1][X * 2 + 1][X * 2 + 1];
	int n, q, i, t, x, y;

	scanf("%d%d", &n, &q);
	for (i = 0; i < n; i++) {
		scanf("%d%d", &xx[i], &yy[i]);
		cc[0][X + xx[i]][X + yy[i]] = 2;
	}
	nn[0] = n;
	for (t = 1; t <= T; t++)
		for (x = 0; x <= X * 2; x++)
			for (y = 0; y <= X * 2; y++)
				if (cc[t - 1][x][y] > 0)
					cc[t][x][y] = cc[t - 1][x][y] - 1;
				else if (x > 0 && cc[t - 1][x - 1][y] == 2 || y > 0 && cc[t - 1][x][y - 1] == 2 || x < X * 2 && cc[t - 1][x + 1][y] == 2 || y < X * 2 && cc[t - 1][x][y + 1] == 2)
					cc[t][x][y] = 2, nn[t]++;
	while (q--) {
		scanf("%d", &t);
		printf("%d\n", nn[t]);
	}
	return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

cell.c: In function 'main':
cell.c:23:20: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   23 |     else if (x > 0 && cc[t - 1][x - 1][y] == 2 || y > 0 && cc[t - 1][x][y - 1] == 2 || x < X * 2 && cc[t - 1][x + 1][y] == 2 || y < X * 2 && cc[t - 1][x][y + 1] == 2)
      |              ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
cell.c:23:98: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   23 |     else if (x > 0 && cc[t - 1][x - 1][y] == 2 || y > 0 && cc[t - 1][x][y - 1] == 2 || x < X * 2 && cc[t - 1][x + 1][y] == 2 || y < X * 2 && cc[t - 1][x][y + 1] == 2)
      |                                                                                        ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
cell.c:23:139: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   23 |     else if (x > 0 && cc[t - 1][x - 1][y] == 2 || y > 0 && cc[t - 1][x][y - 1] == 2 || x < X * 2 && cc[t - 1][x + 1][y] == 2 || y < X * 2 && cc[t - 1][x][y + 1] == 2)
      |                                                                                                                                 ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
cell.c:12:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d%d", &n, &q);
      |  ^~~~~~~~~~~~~~~~~~~~~
cell.c:14:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d%d", &xx[i], &yy[i]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cell.c:26:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%d", &t);
      |   ^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...