Submission #6625036


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=[]
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 ans:
          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
Task B - Even Degrees
User tanon710
Language Python (3.4.3)
Score 0
Code Size 978 Byte
Status TLE
Exec Time 2106 ms
Memory 137400 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 2
AC × 20
TLE × 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 949 ms 53424 KB
02.txt AC 979 ms 53868 KB
03.txt AC 933 ms 53980 KB
04.txt AC 963 ms 53540 KB
05.txt AC 471 ms 36292 KB
06.txt TLE 2106 ms 54856 KB
07.txt TLE 2106 ms 54760 KB
08.txt TLE 2106 ms 54636 KB
09.txt TLE 2106 ms 54728 KB
10.txt AC 403 ms 23664 KB
11.txt TLE 2104 ms 22388 KB
12.txt TLE 2105 ms 22516 KB
13.txt TLE 2105 ms 22388 KB
14.txt TLE 2105 ms 22388 KB
15.txt AC 338 ms 13684 KB
16.txt TLE 2104 ms 12772 KB
17.txt TLE 2104 ms 14448 KB
18.txt TLE 2104 ms 12768 KB
19.txt TLE 2104 ms 12776 KB
20.txt AC 320 ms 10988 KB
21.txt TLE 2104 ms 9440 KB
22.txt TLE 2104 ms 9316 KB
23.txt TLE 2104 ms 9292 KB
24.txt TLE 2104 ms 9308 KB
25.txt AC 309 ms 8280 KB
26.txt AC 458 ms 36168 KB
27.txt AC 461 ms 36204 KB
28.txt AC 1391 ms 137400 KB
29.txt AC 1386 ms 137052 KB
30.txt AC 18 ms 3064 KB
31.txt AC 17 ms 3188 KB
32.txt AC 18 ms 3188 KB
33.txt AC 18 ms 3188 KB
34.txt AC 18 ms 3064 KB
s1.txt AC 18 ms 3188 KB
s2.txt AC 18 ms 3188 KB