Contest Duration: - (local time) (130 minutes) Back to Home

Submission #6384220

Source Code Expand

Copy
```import collections

def printCircuit(v):
edge_count=[0]*(n+1)
for i in range(1,n+1):
edge_count[i]=len(g[i])
curr_path=collections.deque()
circuit=[]
curr_path.appendleft(v)
curr_v=v
while len(curr_path)!=0:
if edge_count[curr_v]:
curr_path.appendleft(curr_v)
next_v=g[curr_v].pop(-1)
g[next_v].remove(curr_v)
edge_count[curr_v]-=1
edge_count[next_v]-=1
curr_v=next_v
else:
circuit.append(curr_v)
curr_v=curr_path.popleft()
return circuit

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
cnt=[0]*(n+1)
for _ in range(m):
a,b=map(int,input().split())
g[a].append(b)
g[b].append(a)
cnt[a]+=1
cnt[b]+=1
cnt1=0
cnt2=0
cand=[]
for i in range(1,n+1):
if cnt[i]%2==0:
cnt1+=1
else:
cnt2+=1
cand.append(i)
if m%2==1:
print(-1)
else:
if cnt1==n:
path=printCircuit(1)
for i in range(len(path)):
if i%2==1:
print(path[i],path[i-1])
print(path[i],path[i+1])
elif cnt1==n-2 and cnt2==2:
path=printCircuit(cand[0])
for i in range(len(path)):
if i%2==1:
print(path[i],path[i-1])
print(path[i],path[i+1])
else:
print(-1)```

#### Submission Info

Submission Time 2019-07-14 23:25:33+0900 B - Even Degrees tanon710 Python (3.4.3) 0 1243 Byte WA 693 ms 25244 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
 AC × 2
 AC × 15 WA × 21
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt WA 437 ms 24776 KB
02.txt WA 469 ms 24892 KB
03.txt WA 443 ms 24884 KB
04.txt WA 452 ms 24768 KB
05.txt AC 446 ms 24768 KB
06.txt WA 400 ms 17956 KB
07.txt WA 401 ms 17940 KB
08.txt WA 413 ms 17992 KB
09.txt WA 409 ms 17976 KB
10.txt AC 421 ms 17948 KB
11.txt WA 378 ms 12772 KB
12.txt WA 369 ms 12784 KB
13.txt WA 368 ms 12784 KB
14.txt WA 363 ms 12784 KB
15.txt AC 364 ms 12780 KB
16.txt WA 355 ms 11120 KB
17.txt WA 372 ms 13036 KB
18.txt WA 351 ms 11120 KB
19.txt WA 367 ms 11116 KB
20.txt AC 362 ms 11116 KB
21.txt WA 344 ms 8640 KB
22.txt WA 346 ms 8560 KB
23.txt WA 338 ms 8540 KB
24.txt WA 354 ms 8552 KB
25.txt AC 336 ms 8552 KB
26.txt AC 421 ms 22232 KB
27.txt AC 431 ms 22232 KB
28.txt AC 693 ms 25244 KB
29.txt AC 670 ms 25120 KB
30.txt AC 20 ms 3316 KB
31.txt AC 20 ms 3316 KB
32.txt AC 20 ms 3316 KB
33.txt AC 20 ms 3316 KB
34.txt WA 20 ms 3316 KB
s1.txt AC 20 ms 3316 KB
s2.txt AC 20 ms 3316 KB