Submission #770027

#TimeUsernameProblemLanguageResultExecution timeMemory
770027rainboy"The Lyuboyn" code (IZhO19_lyuboyn)C11
100 / 100
304 ms5304 KiB
#include <stdio.h> #define N 18 int count(int b) { return b == 0 ? 0 : count(b & b - 1) + 1; } int bb_[N], n; int add(int b) { int i; for (i = 0; i < n; i++) if (b & 1 << i) { if (bb_[i] & 1 << i) b ^= bb_[i]; else { bb_[i] = b; return 1; } } return 0; } int main() { static char cc[N + 1]; static int bb[N]; int m, k, i, b, b_, x, x_; scanf("%d%d%*d%s", &n, &k, cc); x = 0; for (i = 0; i < n; i++) if (cc[i] == '1') x |= 1 << i; m = 0; for (b = 0; b < 1 << n; b++) if (count(b) == k && add(b)) bb[m++] = b; if (m < n) { printf("-1\n"); return 0; } printf("%d\n", 1 << n); for (b = 0; b < 1 << n; b++) { b_ = b ^ b >> 1; x_ = x; for (i = 0; i < n; i++) if ((b_ & 1 << i) != 0) x_ ^= bb[i]; for (i = 0; i < n; i++) printf("%d", x_ >> i & 1); printf("\n"); } return 0; }

Compilation message (stderr)

lyuboyn.c: In function 'count':
lyuboyn.c:6:34: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
    6 |  return b == 0 ? 0 : count(b & b - 1) + 1;
      |                                ~~^~~
lyuboyn.c: In function 'main':
lyuboyn.c:31:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |  scanf("%d%d%*d%s", &n, &k, cc);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...