blob: f65c04fdca73031d3d2040a1163d224459f1eb69 (
plain)
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
|
carteV = []
carteOut = []
def cOutPresente(x):
s = False
for i in carteOut:
if i == x:
s = True
if not s:
carteOut.append(x)
def fCarte(N, start):
c = carteV[:]
while len(c) > 1:
tot = len(c)
for i in range(start, tot - 1):
x = c[i]
x1 = c[i + 1]
x2 = x + x1
if ((x2 % 2) != 0):
c.remove(x)
c.remove(x1)
break
start = 0
cOutPresente(c[0])
with open('input.txt', 'r') as fin:
N = int(fin.readline())
carteV = fin.readline().split(' ')
for i in range(N):
carteV[i] = int(carteV[i])
for i in range(N):
fCarte(N, start=i)
with open('output.txt', 'w') as fout:
fout.write(str(len(carteOut)))
fout.write('\n')
for i in carteOut:
fout.write(str(i) + ' ')
|