Submission #6419171


Source Code Expand

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

def dfs2(v):
  if len(g2[v])==0:
    return 0
  for u in g2[v]:
    g2[u].remove(v)
    dfs2(u)
    if cnt[u]%2==1:
      print(u,v)
      cnt[u]+=1
    else:
      print(v,u)
      cnt[v]+=1

n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
g2=[[] 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)
if m%2==1:
  print(-1)
else:
  checked=[0]*(n+1)
  checked[1]=1
  dfs1(1)
  for v in range(1,n+1):
    if len(g[v])==0:
      continue
    else:
      for u in g[v]:
        print(u,v)
        g[u].remove(v)
        g[v].remove(u)
        cnt[u]+=1
  dfs2(1)

Submission Info

Submission Time
Task B - Even Degrees
User tanon710
Language Python (3.4.3)
Score 0
Code Size 885 Byte
Status RE
Exec Time 782 ms
Memory 31400 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 2
AC × 14
WA × 8
RE × 14
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 627 ms 31332 KB
02.txt WA 599 ms 31332 KB
03.txt WA 585 ms 31400 KB
04.txt WA 617 ms 31272 KB
05.txt AC 420 ms 29164 KB
06.txt RE 419 ms 21432 KB
07.txt RE 430 ms 21440 KB
08.txt RE 425 ms 21436 KB
09.txt RE 443 ms 21436 KB
10.txt AC 384 ms 20016 KB
11.txt RE 398 ms 14028 KB
12.txt RE 385 ms 14024 KB
13.txt RE 394 ms 14012 KB
14.txt RE 382 ms 14016 KB
15.txt AC 338 ms 13020 KB
16.txt RE 381 ms 11888 KB
17.txt RE 378 ms 11876 KB
18.txt RE 386 ms 11884 KB
19.txt RE 374 ms 11876 KB
20.txt AC 325 ms 10864 KB
21.txt WA 750 ms 9620 KB
22.txt WA 756 ms 9724 KB
23.txt WA 774 ms 9632 KB
24.txt WA 782 ms 9744 KB
25.txt AC 296 ms 8280 KB
26.txt AC 397 ms 29104 KB
27.txt AC 413 ms 29104 KB
28.txt RE 481 ms 30796 KB
29.txt RE 480 ms 30800 KB
30.txt AC 17 ms 3064 KB
31.txt AC 18 ms 3064 KB
32.txt AC 17 ms 3064 KB
33.txt AC 18 ms 3064 KB
34.txt AC 17 ms 3064 KB
s1.txt AC 17 ms 3064 KB
s2.txt AC 17 ms 3064 KB