Submission #22938

#TimeUsernameProblemLanguageResultExecution timeMemory
22938dotoryaWindow Xor (KRIII5_WX)C++14
7 / 7
359 ms5312 KiB
#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)

WX.cpp:22:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning(disable:4996)
 ^
WX.cpp:23:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/STACK:336777216")
 ^
WX.cpp: In function 'void dodo(int, int, ll)':
WX.cpp:90:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (j = 1; j < Vu.size(); j++) sum[j] = sum[j - 1] ^ in[Vu[j]];
                 ^
WX.cpp:92:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (j = 0; j < Vu.size(); j++) {
                 ^
WX.cpp: In function 'int main()':
WX.cpp:104: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:105:47: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i = 0; i < N; i++) scanf("%lld", &in[i]);
                                               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...