Submission #101891
Source Code Expand
#include<bits/stdc++.h> using namespace std; int b[100000]; int segtree[2200000]; int INF=999999999; void add(int a,int b){ a+=(1<<20); while(a){ segtree[a]=min(segtree[a],b); a/=2; } } int query(int a){ int left=0; int right=(1<<20); int u=1; int K=19; while(left+1<right){ int M=(left+right)/2; if(a&(1<<K)){ if(segtree[u*2]<INF){ u=u*2; right=M; }else{ u=u*2+1; left=M; } }else{ if(segtree[u*2+1]<INF){ u=u*2+1; left=M; }else{ u=u*2; right=M; } } K--; } return left; } int main(){ int a; for(int i=0;i<2200000;i++)segtree[i]=INF; scanf("%d",&a); for(int i=0;i<a;i++)scanf("%d",b+i); int ret=-1; int left=0; int right=0; int now=0; add(0,0); for(int i=0;i<a;i++){ now^=b[i]; int V=query(now); if(ret<(now^V)){ ret=(now^V); left=segtree[(1<<20)+V]; right=i+1; }else if(ret==(now^V)&&left>segtree[(1<<20)+V]){ left=segtree[(1<<20)+V]; right=i+1; } add(now,i+1); } printf("%d %d %d\n",ret,left+1,right); }
Submission Info
Submission Time | |
---|---|
Task | F - Maximum Segment XOR |
User | wakaba |
Language | C++ (GCC 4.4.7) |
Score | 100 |
Code Size | 1084 Byte |
Status | AC |
Exec Time | 101 ms |
Memory | 9888 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:45: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result ./Main.cpp:46: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 3, 30, 31, 4, 5, 6, 7, 8, 9 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
1 | AC | 35 ms | 9376 KB |
10 | AC | 35 ms | 9376 KB |
11 | AC | 35 ms | 9512 KB |
12 | AC | 35 ms | 9376 KB |
13 | AC | 39 ms | 9380 KB |
14 | AC | 39 ms | 9384 KB |
15 | AC | 41 ms | 9364 KB |
16 | AC | 64 ms | 9512 KB |
17 | AC | 57 ms | 9504 KB |
18 | AC | 101 ms | 9888 KB |
19 | AC | 35 ms | 9388 KB |
2 | AC | 35 ms | 9384 KB |
20 | AC | 34 ms | 9332 KB |
21 | AC | 35 ms | 9380 KB |
22 | AC | 34 ms | 9384 KB |
23 | AC | 35 ms | 9384 KB |
24 | AC | 35 ms | 9384 KB |
25 | AC | 37 ms | 9388 KB |
26 | AC | 36 ms | 9508 KB |
27 | AC | 39 ms | 9388 KB |
28 | AC | 79 ms | 9584 KB |
29 | AC | 86 ms | 9648 KB |
3 | AC | 35 ms | 9372 KB |
30 | AC | 66 ms | 9504 KB |
31 | AC | 94 ms | 9768 KB |
4 | AC | 34 ms | 9496 KB |
5 | AC | 36 ms | 9316 KB |
6 | AC | 34 ms | 9336 KB |
7 | AC | 36 ms | 9376 KB |
8 | AC | 34 ms | 9380 KB |
9 | AC | 35 ms | 9384 KB |