# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22938 | dotorya | Window Xor (KRIII5_WX) | C++14 | 359 ms | 5312 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 <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;
#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 1034567890123456789ll;
const db PI = acos(-1);
const db ERR = 1E-11;
ll mypow(ll a, ll b, ll g = MOD) {
ll rv = 1 % g;
while (b) {
if (b % 2) rv = (rv * a) % g;
a = (a*a) % g;
b /= 2;
}
return rv;
}
ll in[100050];
ll tin[100050];
bool dchk[100050];
vector <int> Vu;
ll sum[100050];
ll getsum(ll x) {
ll t1 = x / Vu.size();
ll t2 = x % Vu.size();
ll rv = 0;
if (t1 % 2) rv = sum[Vu.size() - 1];
rv ^= sum[t2];
return rv;
}
void dodo(int N, int K, ll x) {
x = mypow(2, x, N);
int i, j;
for (i = 0; i < N; i++) dchk[i] = false;
for (i = 0; i < N; i++) {
if (dchk[i]) continue;
ll t = i;
while (!dchk[t]) {
Vu.push_back(t);
dchk[t] = true;
t = (t + x) % N;
}
sum[0] = in[Vu[0]];
for (j = 1; j < Vu.size(); j++) sum[j] = sum[j - 1] ^ in[Vu[j]];
for (j = 0; j < Vu.size(); j++) {
tin[Vu[j]] = getsum(j + K - 1);
if (j) tin[Vu[j]] ^= getsum(j - 1);
}
Vu.clear();
}
for (i = 0; i < N; i++) in[i] = tin[i];
}
int main() {
int N, K, i;
ll T;
scanf("%d %d %lld", &N, &K, &T);
for (i = 0; i < N; i++) scanf("%lld", &in[i]);
for (i = 61; i >= 0; i--) if (T & (1ll << i)) dodo(N, K, i);
for (i = 0; i < N; i++) printf("%lld ", in[i]);
return !printf("\n");
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |