Submission #525430

# Submission time Handle Problem Language Result Execution time Memory
525430 2022-02-11T15:35:02 Z rainboy 즐거운 사진 수집 (JOI13_collecting) C
30 / 100
2225 ms 66920 KB
#include <stdio.h>

#define N	10
#define N_	(1 << N)

int cc[N_ * 2][N_ * 2], sz[N_ * 2][N_ * 2], n_;

void pul(int i, int j) {
	int il = i << 1, ir = i << 1 | 1;
	int jl = j << 1, jr = j << 1 | 1;

	if (cc[il][jl] == -1 || cc[il][jr] == -1 || cc[ir][jl] == -1 || cc[ir][jr] == -1 || cc[il][jr] != cc[il][jl] || cc[ir][jl] != cc[il][jl] || cc[ir][jr] != cc[il][jl])
		cc[i][j] = -1, sz[i][j] = 1 + sz[il][jl] + sz[il][jr] + sz[ir][jl] + sz[ir][jr];
	else
		cc[i][j] = cc[il][jl], sz[i][j] = 1;
}

void update(int i, int j) {
	i += n_, j += n_;
	cc[i][j] ^= 1, sz[i][j] = 1;
	while (i > 1 && j > 1)
		pul(i >>= 1, j >>= 1);
}

int main() {
	int n, q, i, j;

	scanf("%d%d", &n, &q), n_ = 1 << n;
	for (i = 0; i < n_ * 2; i++)
		for (j = 0; j < n_ * 2; j++)
			cc[i][j] = 0, sz[i][j] = 1;
	while (q--) {
		int t;

		scanf("%d", &t);
		if (t == 0) {
			scanf("%d", &i), i--;
			for (j = 0; j < n_; j++)
				update(i, j);
		} else {
			scanf("%d", &j), j--;
			for (i = 0; i < n_; i++)
				update(i, j);
		}
		printf("%d\n", sz[1][1]);
	}
	return 0;
}

Compilation message

collecting.c: In function 'main':
collecting.c:28:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |  scanf("%d%d", &n, &q), n_ = 1 << n;
      |  ^~~~~~~~~~~~~~~~~~~~~
collecting.c:35:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |   scanf("%d", &t);
      |   ^~~~~~~~~~~~~~~
collecting.c:37:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |    scanf("%d", &i), i--;
      |    ^~~~~~~~~~~~~~~
collecting.c:41:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |    scanf("%d", &j), j--;
      |    ^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 1188 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 1228 KB Output is correct
6 Correct 1 ms 1228 KB Output is correct
7 Correct 1 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 246 ms 33104 KB Output is correct
2 Correct 117 ms 16708 KB Output is correct
3 Correct 238 ms 33096 KB Output is correct
4 Correct 260 ms 33100 KB Output is correct
5 Correct 109 ms 16708 KB Output is correct
6 Correct 238 ms 33100 KB Output is correct
7 Correct 227 ms 33100 KB Output is correct
8 Correct 244 ms 33228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 2225 ms 66920 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -