Submission #636794

#TimeUsernameProblemLanguageResultExecution timeMemory
636794valerikk"The Lyuboyn" code (IZhO19_lyuboyn)C++17
3 / 100
328 ms6316 KiB
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int N, K, T; int f[1 << 19]; int main() { scanf("%d%d%d", &N, &K, &T); static char S[19]; scanf("%s", S); int S_num = 0; for(int i = 0; i < N; ++i) { if(S[i] == '1') S_num |= 1 << i; } if(!(K&1)) { puts("-1"); return 0; } int M = 1 << K + 1; f[0] = 0; f[1] = 1; for(int p = 2; p < M; p <<= 1) { for(int i = 0; i < p; ++i) { f[p + i] = f[p - i - 1] | p; } } for(int i = 1; i < M; i += 2) { f[i] = f[i] ^ (M - 1); } for(int p = M; p < 1 << N; p <<= 1) { for(int i = 0; i < p; ++i) { f[p + i] = f[p - i - 1] ^ (M - 1) | p; } } int S_pos = 0; while(f[S_pos] != S_num) { ++S_pos; } for(int i = 0; i < 1 << N; ++i) { int X = f[S_pos + i & (1 << N) - 1]; for(int j = 0; j < N; ++j) { printf("%d", (X >> j) & 1); } printf("\n"); } }

Compilation message (stderr)

lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:25:17: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   25 |  int M = 1 << K + 1;
      |               ~~^~~
lyuboyn.cpp:41:28: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
   41 |    f[p + i] = f[p - i - 1] ^ (M - 1) | p;
      |               ~~~~~~~~~~~~~^~~~~~~~~
lyuboyn.cpp:51:19: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
   51 |   int X = f[S_pos + i & (1 << N) - 1];
      |             ~~~~~~^~~
lyuboyn.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d%d%d", &N, &K, &T);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
lyuboyn.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%s", S);
      |  ~~~~~^~~~~~~~~
#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...