結果
問題 | No.1640 簡単な色塗り |
ユーザー | ygd. |
提出日時 | 2021-08-06 22:37:35 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,330 bytes |
コンパイル時間 | 362 ms |
コンパイル使用メモリ | 87,304 KB |
実行使用メモリ | 143,412 KB |
最終ジャッジ日時 | 2023-09-12 02:40:07 |
合計ジャッジ時間 | 26,801 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 100 ms
71,624 KB |
testcase_02 | WA | - |
testcase_03 | AC | 99 ms
71,672 KB |
testcase_04 | AC | 383 ms
124,724 KB |
testcase_05 | AC | 380 ms
142,584 KB |
testcase_06 | WA | - |
testcase_07 | AC | 100 ms
71,776 KB |
testcase_08 | WA | - |
testcase_09 | AC | 100 ms
71,740 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 214 ms
84,496 KB |
testcase_31 | AC | 512 ms
142,160 KB |
testcase_32 | AC | 469 ms
128,680 KB |
testcase_33 | AC | 357 ms
114,096 KB |
testcase_34 | AC | 408 ms
123,812 KB |
testcase_35 | AC | 366 ms
114,540 KB |
testcase_36 | AC | 216 ms
84,972 KB |
testcase_37 | AC | 228 ms
88,904 KB |
testcase_38 | AC | 466 ms
130,436 KB |
testcase_39 | AC | 287 ms
99,368 KB |
testcase_40 | AC | 289 ms
100,024 KB |
testcase_41 | AC | 423 ms
126,952 KB |
testcase_42 | AC | 315 ms
106,148 KB |
testcase_43 | AC | 324 ms
108,932 KB |
testcase_44 | AC | 324 ms
106,220 KB |
testcase_45 | AC | 275 ms
95,644 KB |
testcase_46 | AC | 223 ms
85,780 KB |
testcase_47 | AC | 198 ms
82,228 KB |
testcase_48 | AC | 483 ms
130,776 KB |
testcase_49 | AC | 186 ms
79,860 KB |
testcase_50 | AC | 99 ms
71,896 KB |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
07_evil_01.txt | WA | - |
07_evil_02.txt | WA | - |
ソースコード
from heapq import heapify, heappop, heappush from collections import defaultdict from collections import deque def main(): N = int(input()) deg = [0]*N dic = defaultdict(list) for i in range(N): a,b = map(int,input().split()) a -= 1; b -= 1 deg[a] += 1 deg[b] += 1 dic[a].append((b,i)) #行先、辺の番号 dic[b].append((a,i)) PQ = [] for i in range(N): heappush(PQ,(deg[i],i)) Q = deque([]) #for i in range(N): # heappush(PQ,(deg[i],i)) ret = [] used_point = set([]) used_edge = set([]) while PQ: d,i = heappop(PQ) if i in used_point: continue Q.append(i) while Q: v = Q.popleft() #print("v",v) if v in used_point: continue for u,edge_idx in dic[v]: #print(u,edge_idx,used_edge) if edge_idx in used_edge: continue ret.append(v) used_point.add(v) used_edge.add(edge_idx) if u not in used_point: Q.append(u) break #print(ret) if len(ret) == N: print('Yes') ret = [x+1 for x in ret] print(*ret,sep="\n") else: print('No') if __name__ == '__main__': main()