# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
23509 | 0xrgb | Window Xor (KRIII5_WX) | C++14 | 293 ms | 1996 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |