Submission #4805

# Submission time Handle Problem Language Result Execution time Memory
4805 2014-01-04T09:05:33 Z cki86201 XOR (IZhO12_xor) C++
0 / 100
144 ms 92892 KB
#include<stdio.h>
#include<algorithm>
using namespace std;

int N,U;
int Trie[250020*31][2],Len;
int M[250020*31], inp[250020];
int ans[2];

int main(){
	scanf("%d%d",&N,&U);
	int i;
	for(i=1;i<=N;i++){
		int x;
		scanf("%d",&x);
		inp[i] = inp[i-1] ^ x;
	}
	for(i=0;i<=N;i++){
		int now = 0;
		for(int j=30;j>=0;j--){
			int tmp = (inp[i]&1<<j)?1:0;
			if(!Trie[now][tmp])Trie[now][tmp] = ++Len;
			now = Trie[now][tmp];
			M[now] = i;
		}
	}
	for(i=0;i<N;i++){
		int now = 0, mx = 0;
		for(int j=30;j>=0;j--){
			int tmp = (inp[i]&1<<j);
			int u = (U&1<<j);
			if(tmp == u)mx = max(mx, M[Trie[now][!tmp]]);
			if(!(now = Trie[now][u?1:0]))break;
		}
		mx = max(mx, M[now]);
		if(ans[1] < mx-i)ans[1]=mx-i,ans[0]=i+1;
	}
	printf("%d %d",ans[0],ans[1]);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 92892 KB Output isn't correct
2 Incorrect 0 ms 92892 KB Output isn't correct
3 Incorrect 0 ms 92892 KB Output isn't correct
4 Incorrect 0 ms 92892 KB Output isn't correct
5 Incorrect 8 ms 92892 KB Output isn't correct
6 Incorrect 0 ms 92892 KB Output isn't correct
7 Incorrect 12 ms 92892 KB Output isn't correct
8 Incorrect 12 ms 92892 KB Output isn't correct
9 Incorrect 48 ms 92892 KB Output isn't correct
10 Incorrect 44 ms 92892 KB Output isn't correct
11 Incorrect 44 ms 92892 KB Output isn't correct
12 Incorrect 40 ms 92892 KB Output isn't correct
13 Incorrect 44 ms 92892 KB Output isn't correct
14 Incorrect 56 ms 92892 KB Output isn't correct
15 Incorrect 40 ms 92892 KB Output isn't correct
16 Incorrect 36 ms 92892 KB Output isn't correct
17 Incorrect 124 ms 92892 KB Output isn't correct
18 Incorrect 144 ms 92892 KB Output isn't correct
19 Incorrect 116 ms 92892 KB Output isn't correct
20 Incorrect 140 ms 92892 KB Output isn't correct