結果
問題 | No.1254 補強への架け橋 |
ユーザー | H3PO4 |
提出日時 | 2020-10-09 22:51:15 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,336 bytes |
コンパイル時間 | 141 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 109,652 KB |
最終ジャッジ日時 | 2024-07-20 13:21:19 |
合計ジャッジ時間 | 22,124 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
52,224 KB |
testcase_01 | AC | 36 ms
52,480 KB |
testcase_02 | AC | 38 ms
52,224 KB |
testcase_03 | AC | 40 ms
52,096 KB |
testcase_04 | AC | 37 ms
52,224 KB |
testcase_05 | AC | 36 ms
52,224 KB |
testcase_06 | AC | 36 ms
51,968 KB |
testcase_07 | AC | 35 ms
52,480 KB |
testcase_08 | AC | 36 ms
52,352 KB |
testcase_09 | AC | 34 ms
52,096 KB |
testcase_10 | AC | 35 ms
52,352 KB |
testcase_11 | AC | 35 ms
51,968 KB |
testcase_12 | AC | 36 ms
52,004 KB |
testcase_13 | AC | 37 ms
52,224 KB |
testcase_14 | AC | 37 ms
52,352 KB |
testcase_15 | AC | 36 ms
52,224 KB |
testcase_16 | AC | 36 ms
52,464 KB |
testcase_17 | AC | 36 ms
52,608 KB |
testcase_18 | AC | 36 ms
52,352 KB |
testcase_19 | AC | 36 ms
52,096 KB |
testcase_20 | AC | 35 ms
52,608 KB |
testcase_21 | AC | 38 ms
52,352 KB |
testcase_22 | AC | 37 ms
52,224 KB |
testcase_23 | AC | 36 ms
52,480 KB |
testcase_24 | AC | 36 ms
52,352 KB |
testcase_25 | AC | 35 ms
52,480 KB |
testcase_26 | AC | 38 ms
52,608 KB |
testcase_27 | AC | 35 ms
52,608 KB |
testcase_28 | AC | 36 ms
52,736 KB |
testcase_29 | AC | 37 ms
52,096 KB |
testcase_30 | AC | 36 ms
52,224 KB |
testcase_31 | AC | 36 ms
52,480 KB |
testcase_32 | AC | 35 ms
52,352 KB |
testcase_33 | AC | 36 ms
52,480 KB |
testcase_34 | AC | 36 ms
52,352 KB |
testcase_35 | AC | 35 ms
52,736 KB |
testcase_36 | AC | 35 ms
52,480 KB |
testcase_37 | AC | 36 ms
52,096 KB |
testcase_38 | AC | 36 ms
52,352 KB |
testcase_39 | AC | 36 ms
52,480 KB |
testcase_40 | AC | 39 ms
52,736 KB |
testcase_41 | AC | 36 ms
52,736 KB |
testcase_42 | AC | 36 ms
52,608 KB |
testcase_43 | AC | 50 ms
63,744 KB |
testcase_44 | AC | 38 ms
53,504 KB |
testcase_45 | AC | 38 ms
53,632 KB |
testcase_46 | AC | 50 ms
63,360 KB |
testcase_47 | AC | 42 ms
59,392 KB |
testcase_48 | AC | 55 ms
65,152 KB |
testcase_49 | AC | 35 ms
52,352 KB |
testcase_50 | AC | 53 ms
64,384 KB |
testcase_51 | AC | 57 ms
65,408 KB |
testcase_52 | AC | 59 ms
67,200 KB |
testcase_53 | AC | 53 ms
63,872 KB |
testcase_54 | AC | 58 ms
67,328 KB |
testcase_55 | AC | 50 ms
62,848 KB |
testcase_56 | AC | 40 ms
52,992 KB |
testcase_57 | AC | 50 ms
61,440 KB |
testcase_58 | AC | 50 ms
60,672 KB |
testcase_59 | AC | 38 ms
52,864 KB |
testcase_60 | AC | 38 ms
53,504 KB |
testcase_61 | AC | 54 ms
63,488 KB |
testcase_62 | AC | 37 ms
52,864 KB |
testcase_63 | AC | 111 ms
79,904 KB |
testcase_64 | AC | 85 ms
77,556 KB |
testcase_65 | AC | 104 ms
78,376 KB |
testcase_66 | AC | 103 ms
78,720 KB |
testcase_67 | AC | 82 ms
77,176 KB |
testcase_68 | AC | 102 ms
78,612 KB |
testcase_69 | AC | 107 ms
79,248 KB |
testcase_70 | AC | 93 ms
77,868 KB |
testcase_71 | AC | 85 ms
77,184 KB |
testcase_72 | AC | 104 ms
79,076 KB |
testcase_73 | AC | 88 ms
77,312 KB |
testcase_74 | AC | 103 ms
78,592 KB |
testcase_75 | AC | 100 ms
78,720 KB |
testcase_76 | AC | 65 ms
70,272 KB |
testcase_77 | AC | 99 ms
77,952 KB |
testcase_78 | AC | 120 ms
79,844 KB |
testcase_79 | AC | 108 ms
79,196 KB |
testcase_80 | AC | 103 ms
78,976 KB |
testcase_81 | AC | 107 ms
79,524 KB |
testcase_82 | AC | 106 ms
79,332 KB |
testcase_83 | AC | 319 ms
108,812 KB |
testcase_84 | AC | 326 ms
106,608 KB |
testcase_85 | AC | 229 ms
98,048 KB |
testcase_86 | AC | 307 ms
103,716 KB |
testcase_87 | AC | 332 ms
105,980 KB |
testcase_88 | AC | 125 ms
82,180 KB |
testcase_89 | AC | 334 ms
109,272 KB |
testcase_90 | AC | 245 ms
98,504 KB |
testcase_91 | AC | 204 ms
93,952 KB |
testcase_92 | AC | 145 ms
86,280 KB |
testcase_93 | AC | 279 ms
103,252 KB |
testcase_94 | AC | 264 ms
100,616 KB |
testcase_95 | AC | 259 ms
99,856 KB |
testcase_96 | AC | 315 ms
106,464 KB |
testcase_97 | AC | 187 ms
90,612 KB |
testcase_98 | AC | 338 ms
107,156 KB |
testcase_99 | AC | 227 ms
95,720 KB |
testcase_100 | AC | 350 ms
109,652 KB |
testcase_101 | AC | 153 ms
85,744 KB |
testcase_102 | AC | 118 ms
80,368 KB |
testcase_103 | AC | 156 ms
85,776 KB |
testcase_104 | AC | 182 ms
88,880 KB |
testcase_105 | AC | 280 ms
102,916 KB |
testcase_106 | AC | 199 ms
91,672 KB |
testcase_107 | AC | 345 ms
109,208 KB |
testcase_108 | AC | 328 ms
108,200 KB |
testcase_109 | AC | 265 ms
102,060 KB |
testcase_110 | AC | 257 ms
100,112 KB |
testcase_111 | AC | 266 ms
101,048 KB |
testcase_112 | AC | 173 ms
88,160 KB |
testcase_113 | AC | 260 ms
99,692 KB |
testcase_114 | AC | 194 ms
91,864 KB |
testcase_115 | AC | 139 ms
82,560 KB |
testcase_116 | AC | 222 ms
94,300 KB |
testcase_117 | AC | 166 ms
88,248 KB |
testcase_118 | AC | 333 ms
106,840 KB |
testcase_119 | AC | 225 ms
95,088 KB |
testcase_120 | AC | 296 ms
105,480 KB |
testcase_121 | AC | 163 ms
86,872 KB |
testcase_122 | AC | 213 ms
94,720 KB |
testcase_123 | AC | 37 ms
52,224 KB |
testcase_124 | RE | - |
testcase_125 | RE | - |
ソースコード
import sys input = sys.stdin.buffer.readline int1 = lambda x: int(x) - 1 def bridge(G, N): """ 橋検出 https://tjkendev.github.io/procon-library/python/graph/bridge.html より拝借しています。 networkxが使えないサイト用 """ result = set() label = [None] * N gen = 0 cost = [0] * N def dfs(u, p): nonlocal gen res = 0 for v in G[u]: if v == p: continue if label[v] is not None: if label[v] < label[u]: cost[v] += 1 res += 1 else: label[v] = gen; gen += 1 r = dfs(v, u) if r == 0: result.add((u, v) if u < v else (v, u)) res += r res -= cost[u] return res for v in range(N): if not label[v]: label[v] = gen gen += 1 r = dfs(v, -1) assert r == 0, r return result N = int(input()) G = [[] for _ in range(N)] AB = [tuple(sorted(list(map(int1, input().split())))) for _ in range(N)] for a, b in AB: G[a].append(b) G[b].append(a) res = bridge(G, N) ans = [] for i in range(N): if AB[i] not in res: ans.append(i + 1) print(len(ans)) print(*ans)