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

Submission #6624998

Source Code Expand

Copy
```import sys
sys.setrecursionlimit(10**9)

def dfs1(v):
for u in g[v]:
if checked[u]==0:
checked[u]=1
g2[v].append(u)
dfs1(u)
g3[v].append(u)
g3[u].append(v)

def dfs2(v):
for u in g2[v]:
if checked[u]==0:
checked[u]=1
dfs2(u)
if cnt[u]%2==1:
ans.append((u,v))
cnt[u]+=1
else:
ans.append((v,u))
cnt[v]+=1

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
g2=[[] for _ in range(n+1)]
g3=[[] for _ in range(n+1)]
g4=[[] for _ in range(n+1)]
cnt=[0]*(n+1)
ans=[]
for _ in range(m):
a,b=map(int,input().split())
g[a].append(b)
g[b].append(a)
if m%2==1:
print(-1)
else:
checked=[0]*(n+1)
checked[1]=1
dfs1(1)
for v in range(1,n+1):
for u in g[v]:
if u not in g3[v]:
g4[v].append(u)
for v in range(1,n+1):
for u in g4[v]:
ans.append((v,u))
cnt[v]+=1
g4[v].remove(u)
g4[u].remove(v)
checked=[0]*(n+1)
checked[1]=1
dfs2(1)
for v,u in ans:
print(v,u)```

#### Submission Info

Submission Time 2019-07-31 19:07:55+0900 B - Even Degrees tanon710 Python (3.4.3) 0 1087 Byte WA 1366 ms 144180 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
 AC × 2
 AC × 20 WA × 16
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 AC 973 ms 60616 KB
02.txt AC 955 ms 60584 KB
03.txt AC 1010 ms 60584 KB
04.txt AC 979 ms 60676 KB
05.txt AC 496 ms 43444 KB
06.txt WA 903 ms 67728 KB
07.txt WA 927 ms 67744 KB
08.txt WA 977 ms 67460 KB
09.txt WA 942 ms 67732 KB
10.txt AC 409 ms 27188 KB
11.txt WA 617 ms 31500 KB
12.txt WA 645 ms 31524 KB
13.txt WA 631 ms 31508 KB
14.txt WA 617 ms 31508 KB
15.txt AC 332 ms 14452 KB
16.txt WA 638 ms 20868 KB
17.txt WA 661 ms 20852 KB
18.txt WA 636 ms 20860 KB
19.txt WA 625 ms 20872 KB
20.txt AC 322 ms 11244 KB
21.txt WA 805 ms 16624 KB
22.txt WA 818 ms 16636 KB
23.txt WA 819 ms 16676 KB
24.txt WA 801 ms 16624 KB
25.txt AC 301 ms 8284 KB
26.txt AC 499 ms 43332 KB
27.txt AC 509 ms 43332 KB
28.txt AC 1366 ms 144180 KB
29.txt AC 1362 ms 144136 KB
30.txt AC 18 ms 3188 KB
31.txt AC 17 ms 3188 KB
32.txt AC 17 ms 3188 KB
33.txt AC 18 ms 3188 KB
34.txt AC 18 ms 3188 KB
s1.txt AC 18 ms 3188 KB
s2.txt AC 17 ms 3188 KB