Submission #22801

#TimeUsernameProblemLanguageResultExecution timeMemory
22801버거킹 송죽SK점 우수고객 (#40)Window Xor (KRIII5_WX)C++11
7 / 7
279 ms3288 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pp; typedef pair<ll,ll> pll; #define all(x) (x).begin(),(x).end() #define pb push_back #define x first #define y second int n, k; ll t; int a[2][100010]; bool found[100010]; int cyc[100010]; int cn; void trans(int h, int F, int T){ ll w = (1ll << h) % n; if(w == 0){ if(k%2 == 0) for(int i=0; i<n; ++i) a[T][i]=0; else for(int i=0; i<n; ++i) a[T][i]=a[F][i]; return; } fill(found, found+n, false); for(int i=0; i<n; ++i) if(!found[i]){ cn=0; for(int j=i;;){ if(found[j]) break; cyc[cn++]=j; found[j]=1; j=(j+w)%n; } int init_k = k % (2*cn); int val=0; int l=0, r=init_k % cn; for(int i=0; i<init_k; ++i){ val ^= a[F][cyc[i%cn]]; } for(int i=0; i<cn; ++i){ a[T][cyc[i]] = val; val ^= a[F][cyc[l]]; val ^= a[F][cyc[r]]; l=(l+1)%cn; r=(r+1)%cn; } } } //#define DBG int main() { #ifdef DBG freopen("out.txt", "w", stdout); n=1e5; k=n/2; t=12345678987654; #else scanf("%d%d%lld", &n, &k, &t); #endif int F=0, T=1; for(int i=0; i<n; ++i){ #ifdef DBG a[F][i]=rand()%int(1e9); #else scanf("%d", &a[F][i]); #endif } for(int i=62; 0<=i; --i){ if(1 & (t>>i)){ trans(i, F, T); swap(F, T); } } for(int i=0; i<n; ++i){ printf("%d ", a[F][i]); } return 0; }

Compilation message (stderr)

WX.cpp: In function 'int main()':
WX.cpp:58:31: 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:65:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[F][i]);
                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...