Submission #22267

#TimeUsernameProblemLanguageResultExecution timeMemory
22267크리콘 B번 문제는 그리디로 풀려요 (#40)Window Xor (KRIII5_WX)C++98
7 / 7
386 ms3484 KiB
#include<stdio.h>
#include<memory.h>

typedef long long lld;
int N, K;
lld T, ba[101010], im[101010], chk[101010];

lld gcd(lld a, lld b){ return b?gcd(b,a%b):a; }

void trans(int ji){
	lld per = (1ll<<ji) % N, K2 = K;
	lld tmp = N / gcd(N, per); K2 %= 2*tmp;
	memset(chk, 0, sizeof(chk));
	int cnt=0;
	for(lld i=0; i<N; i++){
		if(chk[i])continue;
		lld xo=0;
		for(lld j=0; j<K2; j++)xo ^= ba[(i+j*per) % N];
		for(lld j=0; j<tmp; j++){
			im[(i+j*per) % N] = xo, chk[(i+j*per) % N] = 1;
			xo ^= ba[(i+j*per) % N];
			xo ^= ba[(i+(j+K2)*per) % N];
		}
	}
	memcpy(ba, im, sizeof(ba));
}

int main(){
	scanf("%d%d%lld", &N, &K, &T);
	for(int i=0; i<N; i++)scanf("%lld", &ba[i]);
	for(int i=0; i<63; i++){
		if((1ll<<i) & T) trans(i);
	}
	for(int i=0; i<N; i++)printf("%lld ", ba[i]);
	return 0;
}

Compilation message (stderr)

WX.cpp: In function 'void trans(int)':
WX.cpp:14:6: warning: unused variable 'cnt' [-Wunused-variable]
  int cnt=0;
      ^
WX.cpp: In function 'int main()':
WX.cpp:29: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:30:45: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<N; i++)scanf("%lld", &ba[i]);
                                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...