forked from subhojit-mukherjee/pythoncodes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXorSubSequence.py
More file actions
74 lines (58 loc) · 1.28 KB
/
XorSubSequence.py
File metadata and controls
74 lines (58 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'''
Created on May 7, 2015
@author: Chocolate
'''
'''
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int n;
cin >> n;
unsigned short* a = new unsigned short[n];
for(int i = 0;i < n;i++)
cin >> a[i];
int partial[65536];
fill(partial, partial + 65536, 0);
int xsum = 0;
partial[xsum]++;
for(int i = 0;i < n;i++) {
xsum ^= a[i];
partial[xsum]++;
}
int count[65536];
fill(count, count + 65536, 0);
for(int i = 0;i < 65536;i++)
for(int j = 0;j < i;j++)
count[i ^ j] += partial[i] * partial[j];
int max = 0;
for(int i = 0;i < 65536;i++)
if(count[i] > count[max])
max = i;
cout << max << ' ' << count[max] << endl;
delete[] a;
return 0;
}
'''
ll=[];
n=input();
for _ in xrange(n):
ll.append(input());
partial=[0]*n;
xsum=0;
partial[xsum]+=1;
for i in xrange(0,n):
xsum^=ll[i];
partial[xsum]+=1;
count1=[0]*n;
for i in xrange(0,n):
for j in xrange(0,i):
count1[i^j]+=partial[i] * partial[j];
max1=0;
for i in xrange(0,n):
if count1[i] > count1[max1]:
max1 = i;
print(str(max1)+" "+str(count1[max1]));