Submission #23509

#TimeUsernameProblemLanguageResultExecution timeMemory
235090xrgbWindow Xor (KRIII5_WX)C++14
7 / 7
293 ms1996 KiB
#include <cstdio> #include <cstring> const int MAXN = 100004; typedef long long lli; int N, K; int T, G; int D[MAXN]; int A[MAXN]; bool visited[MAXN]; int gcd2(int, int); int main() { lli t, k = 1; scanf("%d %d %lld", &N, &K, &t); for (int i = 0; i < N; ++i) { scanf("%d", &A[i]); } while (t) { if (!(t & 1)) { k <<= 1; t >>= 1; continue; } T = k % N; G = gcd2(N, T); K %= 2 * (N / G); t >>= 1; k <<= 1; memcpy(D, A, sizeof(int) * N); memset(visited, 0, sizeof(bool) * N); for (int i = 0; i < N; ++i) { if (visited[i]) continue; int st = i, val = 0; for (int j = 0; j < K; ++j) { val ^= D[st]; st = (st + T) % N; } int ed = i; while(!visited[ed]) { A[ed] = val; visited[ed] = true; val ^= (D[ed] ^ D[st]); st = (st + T) % N; ed = (ed + T) % N; } } } for (int i = 0; i < N; ++i) { printf("%d ", A[i]); } puts(""); return 0; } int gcd2(int x, int y) { if (y) return gcd2(y, x % y); return x; }

Compilation message (stderr)

WX.cpp: In function 'int main()':
WX.cpp:17:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %lld", &N, &K, &t);
                                 ^
WX.cpp:19:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &A[i]);
                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...