답안 #478264

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
478264 2021-10-06T18:50:37 Z rainboy Sajam (COCI18_sajam) C
45 / 90
132 ms 6492 KB
#include <stdio.h>

#define N	1000
#define K	50
#define L	20

int min(int a, int b) { return a < b ? a : b; }

int cnt[1 << L];

void init() {
	int b;

	for (b = 1; b < 1 << L; b++)
		cnt[b] = cnt[b & b - 1] + 1;
}

int dist(int *aa, int *bb) {
	int h, d;

	d = 0;
	for (h = 0; h < K; h++)
		d += cnt[aa[h] ^ bb[h]];
	return d;
}

int main() {
	static char cc[N][N + 1];
	static int aa[N][K];
	int n, k_, i, i_, j;

	init();
	scanf("%d%d", &n, &k_);
	for (i = 0; i < n; i++) {
		scanf("%s", cc[i]);
		for (j = 0; j < n; j++)
			if (cc[i][j] == 'o')
				aa[i][j / L] |= 1 << j % L;
	}
	for (i = 0; i < n; i++) {
		int k;

		k = 0;
		for (i_ = 0; i_ < n; i_++) {
			int d = dist(aa[i], aa[i_]);

			k += min(d, n - d);
		}
		if (k <= k_) {
			printf("DA\n");
			return 0;
		}
	}
	for (j = 0; j < n; j++) {
		int k;

		aa[0][j / L] ^= 1 << j % L;
		k = 0;
		for (i = 0; i < n; i++) {
			int d = dist(aa[0], aa[i]);

			k += min(d, n - d);
		}
		aa[0][j / L] ^= 1 << j % L;
	}
	printf("NE\n");
	return 0;
}

Compilation message

sajam.c: In function 'init':
sajam.c:15:22: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   15 |   cnt[b] = cnt[b & b - 1] + 1;
      |                    ~~^~~
sajam.c: In function 'main':
sajam.c:33:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |  scanf("%d%d", &n, &k_);
      |  ^~~~~~~~~~~~~~~~~~~~~~
sajam.c:35:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |   scanf("%s", cc[i]);
      |   ^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4432 KB Output is correct
2 Correct 4 ms 4944 KB Output is correct
3 Correct 5 ms 5176 KB Output is correct
4 Correct 9 ms 6192 KB Output is correct
5 Correct 5 ms 5200 KB Output is correct
6 Correct 4 ms 4816 KB Output is correct
7 Correct 31 ms 5200 KB Output is correct
8 Correct 89 ms 6332 KB Output is correct
9 Correct 8 ms 4688 KB Output is correct
10 Correct 105 ms 6332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4432 KB Output is correct
2 Correct 4 ms 4432 KB Output is correct
3 Incorrect 4 ms 4432 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5712 KB Output is correct
2 Correct 7 ms 5968 KB Output is correct
3 Correct 7 ms 5584 KB Output is correct
4 Correct 6 ms 5500 KB Output is correct
5 Correct 9 ms 6224 KB Output is correct
6 Correct 18 ms 5304 KB Output is correct
7 Correct 37 ms 5840 KB Output is correct
8 Correct 34 ms 5868 KB Output is correct
9 Correct 19 ms 4944 KB Output is correct
10 Correct 131 ms 6456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 6096 KB Output is correct
2 Correct 8 ms 6056 KB Output is correct
3 Correct 6 ms 5456 KB Output is correct
4 Correct 8 ms 5780 KB Output is correct
5 Correct 7 ms 5812 KB Output is correct
6 Correct 50 ms 6324 KB Output is correct
7 Correct 14 ms 5072 KB Output is correct
8 Correct 30 ms 5712 KB Output is correct
9 Correct 93 ms 5816 KB Output is correct
10 Correct 132 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5456 KB Output is correct
2 Correct 6 ms 5632 KB Output is correct
3 Incorrect 57 ms 6476 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 6480 KB Output is correct
2 Correct 10 ms 6380 KB Output is correct
3 Incorrect 54 ms 6280 KB Output isn't correct
4 Halted 0 ms 0 KB -