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

Submission #6380614

Source Code Expand

Copy
```from collections import deque

def dfs(graph, start):
stack = deque()
push, pop = stack.append, stack.pop
visited = [False for i in range(N+1)]
push(start)
visited[start] = True

ans = []
cnt = 0
while stack:
a = pop()
keys = [i for i in graph[a].keys()]
if len(keys) % 2 == 1 and cnt < M - 1:
b = keys.pop()
ans.append([b,a])
cnt += 1
del graph[b][a], graph[a][b]
if not visited[b]:
push(b)
visited[b] = True
for b in keys:
ans.append([a,b])
cnt += 1
del graph[b][a], graph[a][b]
if not visited[b]:
push(b)
visited[b] = True
[print(a,b) for a,b in ans]

N,M = map(int, input().split())
graph = {}
bridge = []
for i in range(M):
a,b = map(int, input().split())
if a not in graph:
graph[a] = {}
if b not in graph:
graph[b] = {}
graph[a][b] = graph[b][a] = 1
bridge.append([a,b])

if M % 2 == 1:
print(-1)
exit()
start = bridge[0][0]
dfs(graph, start)
```

#### Submission Info

Submission Time 2019-07-14 22:49:39+0900 B - Even Degrees kinetock Python (3.4.3) 0 1182 Byte WA 860 ms 69436 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
 AC × 2
 AC × 12 WA × 24
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 851 ms 69296 KB
02.txt WA 860 ms 69316 KB
03.txt WA 858 ms 69416 KB
04.txt WA 842 ms 69420 KB
05.txt AC 541 ms 55976 KB
06.txt WA 745 ms 52668 KB
07.txt WA 732 ms 52664 KB
08.txt WA 744 ms 52660 KB
09.txt WA 736 ms 52684 KB
10.txt AC 471 ms 39988 KB
11.txt WA 692 ms 44108 KB
12.txt WA 676 ms 44084 KB
13.txt WA 670 ms 44212 KB
14.txt WA 678 ms 44096 KB
15.txt AC 445 ms 32704 KB
16.txt WA 695 ms 43520 KB
17.txt WA 648 ms 43528 KB
18.txt WA 642 ms 43612 KB
19.txt WA 645 ms 43452 KB
20.txt AC 430 ms 32768 KB
21.txt WA 608 ms 41480 KB
22.txt WA 578 ms 41444 KB
23.txt WA 606 ms 41120 KB
24.txt WA 581 ms 41464 KB
25.txt AC 398 ms 30328 KB
26.txt AC 500 ms 55860 KB
27.txt AC 519 ms 55860 KB
28.txt WA 816 ms 69436 KB
29.txt WA 788 ms 69308 KB
30.txt WA 21 ms 3316 KB
31.txt AC 20 ms 3316 KB
32.txt AC 21 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