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

Submission #6625044

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)
g3[v].append(u)
g3[u].append(v)
dfs1(u)

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)]
cnt=[0]*(n+1)
ans=[]
ansset=set()
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]:
if (u,v) not in ansset:
ans.append((v,u))
cnt[v]+=1
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:14:09+0900 B - Even Degrees tanon710 Python (3.4.3) 700 1024 Byte AC 1365 ms 137012 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
 AC × 2
 AC × 36
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 898 ms 53424 KB
02.txt AC 886 ms 53428 KB
03.txt AC 943 ms 53488 KB
04.txt AC 891 ms 53512 KB
05.txt AC 462 ms 36292 KB
06.txt AC 868 ms 68128 KB
07.txt AC 856 ms 67368 KB
08.txt AC 870 ms 67244 KB
09.txt AC 930 ms 68120 KB
10.txt AC 371 ms 23660 KB
11.txt AC 662 ms 40684 KB
12.txt AC 675 ms 40684 KB
13.txt AC 654 ms 40684 KB
14.txt AC 681 ms 40680 KB
15.txt AC 321 ms 13684 KB
16.txt AC 596 ms 31704 KB
17.txt AC 641 ms 33508 KB
18.txt AC 590 ms 31700 KB
19.txt AC 600 ms 31708 KB
20.txt AC 312 ms 11116 KB
21.txt AC 561 ms 27604 KB
22.txt AC 548 ms 27480 KB
23.txt AC 562 ms 27456 KB
24.txt AC 571 ms 27528 KB
25.txt AC 306 ms 8408 KB
26.txt AC 437 ms 36164 KB
27.txt AC 443 ms 36144 KB
28.txt AC 1365 ms 136992 KB
29.txt AC 1349 ms 137012 KB
30.txt AC 17 ms 3188 KB
31.txt AC 17 ms 3188 KB
32.txt AC 17 ms 3188 KB
33.txt AC 17 ms 3188 KB
34.txt AC 17 ms 3188 KB
s1.txt AC 17 ms 3188 KB
s2.txt AC 17 ms 3188 KB