Submission #386787
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 | tozangezan |
Language | C++ (GCC 4.4.7) |
Score | 100 |
Code Size | 1085 Byte |
Status | AC |
Exec Time | 109 ms |
Memory | 10104 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 | 45 ms | 9692 KB |
10 | AC | 45 ms | 9684 KB |
11 | AC | 44 ms | 9724 KB |
12 | AC | 47 ms | 9744 KB |
13 | AC | 50 ms | 9712 KB |
14 | AC | 49 ms | 9724 KB |
15 | AC | 53 ms | 9724 KB |
16 | AC | 75 ms | 9980 KB |
17 | AC | 67 ms | 9848 KB |
18 | AC | 109 ms | 10104 KB |
19 | AC | 44 ms | 9728 KB |
2 | AC | 44 ms | 9720 KB |
20 | AC | 45 ms | 9700 KB |
21 | AC | 46 ms | 9720 KB |
22 | AC | 43 ms | 9720 KB |
23 | AC | 44 ms | 9724 KB |
24 | AC | 49 ms | 9720 KB |
25 | AC | 51 ms | 9736 KB |
26 | AC | 49 ms | 9708 KB |
27 | AC | 50 ms | 9828 KB |
28 | AC | 88 ms | 10068 KB |
29 | AC | 94 ms | 10060 KB |
3 | AC | 47 ms | 9712 KB |
30 | AC | 74 ms | 9840 KB |
31 | AC | 107 ms | 10092 KB |
4 | AC | 47 ms | 9724 KB |
5 | AC | 51 ms | 9712 KB |
6 | AC | 49 ms | 9712 KB |
7 | AC | 47 ms | 9704 KB |
8 | AC | 46 ms | 9720 KB |
9 | AC | 46 ms | 9728 KB |