Submission #6386314
Source Code Expand
Copy
import collections def printCircuit(v): edge_count=[0]*(n+1) for i in range(1,n+1): edge_count[i]=len(g[i]) curr_path=collections.deque() circuit=[] curr_path.appendleft(v) curr_v=v while len(curr_path)!=0: if edge_count[curr_v]: curr_path.appendleft(curr_v) next_v=g[curr_v].pop(-1) g[next_v].remove(curr_v) edge_count[curr_v]-=1 edge_count[next_v]-=1 curr_v=next_v else: circuit.append(curr_v) curr_v=curr_path.popleft() return circuit n,m=map(int,input().split()) g=[[] 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) cnt[a]+=1 cnt[b]+=1 cnt1=0 cnt2=0 cand=[] for i in range(1,n+1): if cnt[i]%2==0: cnt1+=1 else: cnt2+=1 cand.append(i) if m%2==1: print(-1) else: if cnt1==n: path=printCircuit(1) if len(path)%2==1: for i in range(len(path)): if i%2==1: print(path[i],path[i-1]) print(path[i],path[i+1]) else: print(-1) elif cnt1==n-2 and cnt2==2: if len(g[cand[0]])==1: c=cand[0] else: c=cand[1] path=printCircuit(c) if len(path)%2==1: for i in range(len(path)): if i%2==1: print(path[i],path[i-1]) print(path[i],path[i+1]) else: print(-1) else: print(-1)
Submission Info
Submission Time | |
---|---|
Task | B - Even Degrees |
User | tanon710 |
Language | Python (3.4.3) |
Score | 0 |
Code Size | 1430 Byte |
Status | WA |
Exec Time | 660 ms |
Memory | 25244 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | ||||||
Status |
|
|
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 | 459 ms | 24772 KB |
02.txt | WA | 454 ms | 24788 KB |
03.txt | WA | 453 ms | 24884 KB |
04.txt | WA | 461 ms | 24888 KB |
05.txt | AC | 452 ms | 24896 KB |
06.txt | WA | 407 ms | 18000 KB |
07.txt | WA | 404 ms | 17988 KB |
08.txt | WA | 395 ms | 17992 KB |
09.txt | WA | 408 ms | 17976 KB |
10.txt | AC | 426 ms | 17948 KB |
11.txt | WA | 373 ms | 12772 KB |
12.txt | WA | 382 ms | 12784 KB |
13.txt | WA | 364 ms | 12784 KB |
14.txt | WA | 376 ms | 12784 KB |
15.txt | AC | 367 ms | 12780 KB |
16.txt | WA | 357 ms | 11120 KB |
17.txt | WA | 361 ms | 11116 KB |
18.txt | WA | 363 ms | 11120 KB |
19.txt | WA | 360 ms | 11116 KB |
20.txt | AC | 376 ms | 11116 KB |
21.txt | WA | 350 ms | 8512 KB |
22.txt | WA | 339 ms | 8560 KB |
23.txt | WA | 346 ms | 8540 KB |
24.txt | WA | 346 ms | 8552 KB |
25.txt | AC | 351 ms | 8552 KB |
26.txt | AC | 440 ms | 22232 KB |
27.txt | AC | 432 ms | 22232 KB |
28.txt | AC | 660 ms | 25244 KB |
29.txt | AC | 656 ms | 25240 KB |
30.txt | AC | 20 ms | 3316 KB |
31.txt | AC | 21 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 | 21 ms | 3316 KB |
s2.txt | AC | 21 ms | 3316 KB |