diff options
| author | Yuval Adam <yuv.adm@gmail.com> | 2011-05-07 03:08:47 +0300 |
|---|---|---|
| committer | Yuval Adam <yuv.adm@gmail.com> | 2011-05-07 03:08:47 +0300 |
| commit | 40d6a93d9065e45f18c217e281936eff57ba37d6 (patch) | |
| tree | c3171e9a3c185d42b0522d512df68b4eaa091b03 /2011/qual/c/c.py | |
| parent | 76aa2308ea962f204475409ee8f6f17055e6f719 (diff) | |
finished c
Diffstat (limited to '2011/qual/c/c.py')
| -rw-r--r-- | 2011/qual/c/c.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/2011/qual/c/c.py b/2011/qual/c/c.py index f3841a7..b081a03 100644 --- a/2011/qual/c/c.py +++ b/2011/qual/c/c.py @@ -1,10 +1,28 @@ -f = open('1.in', 'r') -o = open('1.out', 'w') +f = open('3.in', 'r') +o = open('3.out', 'w') T = int(f.readline().strip()) +xor = lambda x,y: x^y + for t in xrange(T): - (n, k) = map(int, f.readline().strip().split(' ')) + _n = f.readline().strip().split(' ') + C = map(int, f.readline().strip().split(' ')) + + s, p = C, [] + s.sort() + s.reverse() + + p.append(s.pop()) + + res = 'NO' + while s: + ss = reduce(xor, s) + sp = reduce(xor, p) + if ss == sp: + res = str(sum(s)) + break + p.append(s.pop()) s = "Case #%d: %s\n" % (t+1, res) #print s |
