Submission #101972
Source Code Expand
#include <iostream> #include <vector> #include <string> #include <cstring> #include <queue> #include <map> #include <set> #include <algorithm> using namespace std; #define rep(i,n) for(int i=0;i<(int)n;++i) #define pb(a) push_back(a) #define mp(a,b) make_pair(a,b) #define ALL(a) a.begin(),a.end() #define SZ(a) (int)((a).size()) #define F first #define S second typedef pair<int,int> PI; int a[200000]; vector<int> app[1<<20]; int main(int argc, char *argv[]) { int n; cin >> n; int ans=0; rep(i,n){ cin >> a[i]; ans |= a[i]>>19; } for(int i=2;i<=20;++i){ int xs=0; rep(j,(1<<i)) app[j].clear(); app[xs].pb(0); for(int j=0;j<n;++j){ xs ^= a[j]; app[xs>>(20-i)].pb(j+1); } ans <<= 1; rep(j,(1<<i)) if(SZ(app[(ans|1)^j]) && SZ(app[j])){ ans |= 1; break; } } cout << ans << ' '; if(ans==0){ cout << "1 1" << endl; return 0; } PI ansp(n+1,n+1); rep(j,(1<<20)) if(SZ(app[ans^j]) && SZ(app[j])){ int s=min(app[ans^j][0],app[j][0]); int t=max(app[ans^j][0],app[j][0]); ansp=min(ansp,mp(s,t)); } cout << ansp.F+1 << ' ' << ansp.S << endl; }
Submission Info
Submission Time | |
---|---|
Task | F - Maximum Segment XOR |
User | plusplusw |
Language | C++ (GCC 4.4.7) |
Score | 100 |
Code Size | 1230 Byte |
Status | AC |
Exec Time | 334 ms |
Memory | 38824 KB |
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 | 81 ms | 25336 KB |
10 | AC | 86 ms | 25508 KB |
11 | AC | 82 ms | 25512 KB |
12 | AC | 84 ms | 25380 KB |
13 | AC | 97 ms | 26652 KB |
14 | AC | 101 ms | 26908 KB |
15 | AC | 105 ms | 27300 KB |
16 | AC | 182 ms | 31004 KB |
17 | AC | 154 ms | 30628 KB |
18 | AC | 304 ms | 38172 KB |
19 | AC | 87 ms | 25380 KB |
2 | AC | 85 ms | 25368 KB |
20 | AC | 96 ms | 25336 KB |
21 | AC | 83 ms | 25372 KB |
22 | AC | 98 ms | 25384 KB |
23 | AC | 83 ms | 25292 KB |
24 | AC | 100 ms | 25384 KB |
25 | AC | 90 ms | 25764 KB |
26 | AC | 83 ms | 25500 KB |
27 | AC | 99 ms | 26152 KB |
28 | AC | 250 ms | 35232 KB |
29 | AC | 255 ms | 35488 KB |
3 | AC | 83 ms | 25376 KB |
30 | AC | 209 ms | 32288 KB |
31 | AC | 334 ms | 38824 KB |
4 | AC | 89 ms | 25320 KB |
5 | AC | 81 ms | 25380 KB |
6 | AC | 86 ms | 25376 KB |
7 | AC | 86 ms | 25376 KB |
8 | AC | 86 ms | 25384 KB |
9 | AC | 81 ms | 25500 KB |