Submission #478264

#TimeUsernameProblemLanguageResultExecution timeMemory
478264rainboySajam (COCI18_sajam)C11
45 / 90
132 ms6492 KiB
#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 (stderr)

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]);
      |   ^~~~~~~~~~~~~~~~~~
#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...