Submission #22718

#TimeUsernameProblemLanguageResultExecution timeMemory
227182000/4000 (#40)Window Xor (KRIII5_WX)C++14
7 / 7
296 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 pow2mod(lli, int); 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; } // Func. int pow2mod(lli x, int y) { int k = 2, ans = 1; while(x) { if (x & 1) { ans = ans * (long long)k % y; } x >>= 1; k = k * (long long)k % y; } return ans; } 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:18: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:20: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...