結果
問題 | No.1640 簡単な色塗り |
ユーザー | ygd. |
提出日時 | 2021-08-06 22:21:42 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,747 bytes |
コンパイル時間 | 485 ms |
コンパイル使用メモリ | 87,268 KB |
実行使用メモリ | 138,808 KB |
最終ジャッジ日時 | 2023-09-12 02:17:38 |
合計ジャッジ時間 | 21,535 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 91 ms
71,868 KB |
testcase_02 | WA | - |
testcase_03 | AC | 92 ms
71,376 KB |
testcase_04 | AC | 277 ms
123,228 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 90 ms
71,624 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 | 165 ms
83,004 KB |
testcase_31 | AC | 386 ms
133,824 KB |
testcase_32 | AC | 359 ms
119,736 KB |
testcase_33 | AC | 278 ms
110,760 KB |
testcase_34 | AC | 313 ms
117,436 KB |
testcase_35 | AC | 279 ms
108,928 KB |
testcase_36 | AC | 169 ms
83,004 KB |
testcase_37 | AC | 178 ms
86,180 KB |
testcase_38 | AC | 362 ms
126,328 KB |
testcase_39 | AC | 223 ms
95,828 KB |
testcase_40 | AC | 226 ms
96,792 KB |
testcase_41 | AC | 329 ms
120,492 KB |
testcase_42 | AC | 238 ms
101,788 KB |
testcase_43 | AC | 242 ms
104,244 KB |
testcase_44 | AC | 241 ms
101,780 KB |
testcase_45 | AC | 214 ms
94,076 KB |
testcase_46 | AC | 169 ms
84,000 KB |
testcase_47 | AC | 156 ms
81,252 KB |
testcase_48 | AC | 375 ms
127,292 KB |
testcase_49 | AC | 148 ms
79,352 KB |
testcase_50 | AC | 94 ms
71,884 KB |
testcase_51 | AC | 94 ms
71,548 KB |
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 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)) ret = [] used_point = set([]) used_edge = set([]) for i in range(N): if i in used_point: continue heappush(PQ,(deg[i],i)) while PQ: #print(PQ) d,v = heappop(PQ) #print(d,v) for u,edge_idx in dic[v]: if v in used_point and u in used_point: continue if edge_idx in used_edge: continue if v in used_point: ret.append(u) used_point.add(u) used_edge.add(edge_idx) deg[v] -= 1 deg[u] -= 1 elif u in used_point: ret.append(v) used_point.add(v) used_edge.add(edge_idx) deg[v] -= 1 deg[u] -= 1 else: ret.append(v) deg[v] -= 1 deg[u] -= 1 used_point.add(v) used_edge.add(edge_idx) #print("push",u,edge_idx) heappush(PQ,(deg[u],u)) if len(ret) == N: print('Yes') ret = [x+1 for x in ret] print(*ret,sep="\n") else: print('No') if __name__ == '__main__': main()