結果
問題 | No.1640 簡単な色塗り |
ユーザー | puzneko |
提出日時 | 2021-12-03 00:11:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 244 ms / 2,000 ms |
コード長 | 1,450 bytes |
コンパイル時間 | 2,339 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 117,244 KB |
最終ジャッジ日時 | 2024-07-05 02:32:11 |
合計ジャッジ時間 | 18,305 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
52,424 KB |
testcase_01 | AC | 37 ms
52,484 KB |
testcase_02 | AC | 40 ms
52,608 KB |
testcase_03 | AC | 36 ms
52,224 KB |
testcase_04 | AC | 164 ms
117,120 KB |
testcase_05 | AC | 158 ms
117,244 KB |
testcase_06 | AC | 36 ms
52,752 KB |
testcase_07 | AC | 37 ms
52,608 KB |
testcase_08 | AC | 39 ms
52,096 KB |
testcase_09 | AC | 37 ms
52,608 KB |
testcase_10 | AC | 180 ms
103,180 KB |
testcase_11 | AC | 158 ms
98,532 KB |
testcase_12 | AC | 144 ms
96,304 KB |
testcase_13 | AC | 231 ms
113,088 KB |
testcase_14 | AC | 235 ms
112,960 KB |
testcase_15 | AC | 127 ms
90,452 KB |
testcase_16 | AC | 145 ms
94,360 KB |
testcase_17 | AC | 203 ms
108,764 KB |
testcase_18 | AC | 92 ms
78,016 KB |
testcase_19 | AC | 141 ms
96,572 KB |
testcase_20 | AC | 169 ms
100,932 KB |
testcase_21 | AC | 157 ms
98,764 KB |
testcase_22 | AC | 90 ms
77,696 KB |
testcase_23 | AC | 178 ms
102,656 KB |
testcase_24 | AC | 106 ms
84,136 KB |
testcase_25 | AC | 148 ms
96,512 KB |
testcase_26 | AC | 196 ms
105,728 KB |
testcase_27 | AC | 119 ms
90,668 KB |
testcase_28 | AC | 233 ms
112,384 KB |
testcase_29 | AC | 191 ms
105,564 KB |
testcase_30 | AC | 63 ms
73,264 KB |
testcase_31 | AC | 129 ms
116,668 KB |
testcase_32 | AC | 123 ms
112,456 KB |
testcase_33 | AC | 108 ms
100,816 KB |
testcase_34 | AC | 113 ms
106,256 KB |
testcase_35 | AC | 108 ms
101,184 KB |
testcase_36 | AC | 63 ms
72,372 KB |
testcase_37 | AC | 63 ms
76,800 KB |
testcase_38 | AC | 127 ms
113,280 KB |
testcase_39 | AC | 93 ms
94,344 KB |
testcase_40 | AC | 94 ms
94,600 KB |
testcase_41 | AC | 118 ms
108,752 KB |
testcase_42 | AC | 99 ms
96,740 KB |
testcase_43 | AC | 104 ms
98,356 KB |
testcase_44 | AC | 98 ms
96,772 KB |
testcase_45 | AC | 73 ms
86,076 KB |
testcase_46 | AC | 63 ms
74,624 KB |
testcase_47 | AC | 58 ms
70,016 KB |
testcase_48 | AC | 129 ms
112,896 KB |
testcase_49 | AC | 57 ms
67,148 KB |
testcase_50 | AC | 37 ms
52,608 KB |
testcase_51 | AC | 38 ms
52,224 KB |
testcase_52 | AC | 244 ms
116,992 KB |
testcase_53 | AC | 231 ms
117,072 KB |
07_evil_01.txt | AC | 505 ms
150,496 KB |
07_evil_02.txt | AC | 780 ms
179,528 KB |
ソースコード
from sys import stdin n, *indata = map(int, stdin.read().split()) remained = [0 for i in range(n+1)] g = [[] for i in range(n+1)] offset = 0 for i in range(n): s, t = indata[offset + 2*i],indata[offset + 2*i+1] g[s].append((t,i)) g[t].append((s,i)) remained[s] += 1 remained[t] += 1 que = [] for i in range(1,n+1): if remained[i] == 0: print("No") exit() if remained[i] == 1: que.append(i) used = [False for i in range(n)] ans = [0 for i in range(n)] check = [False for i in range(n+1)] while que: now = que.pop() check[now] = True if remained[now] == 0: print("No") exit() for i, ind in g[now]: if not used[ind]: used[ind] = True ans[ind] = now remained[i] -= 1 if remained[i] == 1: que.append(i) break for i in range(1,n+1): if not check[i]: que.append(i) while que: now = que.pop() check[now] = True if remained[now] == 0: print("No") exit() for i, ind in g[now]: if not used[ind]: used[ind] = True ans[ind] = now remained[i] -= 1 if remained[i] == 1: que.append(i) break print("Yes") for i in range(n): print("{}".format(ans[i]))