結果
問題 | No.1254 補強への架け橋 |
ユーザー | marroncastle |
提出日時 | 2020-11-26 02:56:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 293 ms / 2,000 ms |
コード長 | 2,064 bytes |
コンパイル時間 | 359 ms |
コンパイル使用メモリ | 82,316 KB |
実行使用メモリ | 105,200 KB |
最終ジャッジ日時 | 2024-07-23 20:39:07 |
合計ジャッジ時間 | 22,292 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
55,564 KB |
testcase_01 | AC | 42 ms
54,580 KB |
testcase_02 | AC | 40 ms
54,468 KB |
testcase_03 | AC | 42 ms
55,436 KB |
testcase_04 | AC | 42 ms
55,900 KB |
testcase_05 | AC | 41 ms
54,520 KB |
testcase_06 | AC | 42 ms
54,752 KB |
testcase_07 | AC | 42 ms
55,524 KB |
testcase_08 | AC | 43 ms
55,932 KB |
testcase_09 | AC | 43 ms
54,532 KB |
testcase_10 | AC | 42 ms
55,136 KB |
testcase_11 | AC | 42 ms
54,116 KB |
testcase_12 | AC | 42 ms
54,720 KB |
testcase_13 | AC | 44 ms
54,588 KB |
testcase_14 | AC | 42 ms
54,300 KB |
testcase_15 | AC | 42 ms
54,868 KB |
testcase_16 | AC | 41 ms
55,784 KB |
testcase_17 | AC | 41 ms
54,176 KB |
testcase_18 | AC | 42 ms
56,020 KB |
testcase_19 | AC | 41 ms
54,480 KB |
testcase_20 | AC | 43 ms
54,956 KB |
testcase_21 | AC | 41 ms
55,108 KB |
testcase_22 | AC | 42 ms
54,664 KB |
testcase_23 | AC | 42 ms
54,632 KB |
testcase_24 | AC | 43 ms
54,784 KB |
testcase_25 | AC | 42 ms
54,444 KB |
testcase_26 | AC | 43 ms
55,164 KB |
testcase_27 | AC | 42 ms
55,328 KB |
testcase_28 | AC | 42 ms
55,412 KB |
testcase_29 | AC | 44 ms
55,260 KB |
testcase_30 | AC | 42 ms
55,052 KB |
testcase_31 | AC | 43 ms
54,600 KB |
testcase_32 | AC | 42 ms
55,008 KB |
testcase_33 | AC | 43 ms
55,192 KB |
testcase_34 | AC | 43 ms
55,128 KB |
testcase_35 | AC | 42 ms
54,928 KB |
testcase_36 | AC | 43 ms
56,352 KB |
testcase_37 | AC | 42 ms
55,372 KB |
testcase_38 | AC | 43 ms
54,236 KB |
testcase_39 | AC | 42 ms
55,664 KB |
testcase_40 | AC | 42 ms
54,864 KB |
testcase_41 | AC | 42 ms
55,320 KB |
testcase_42 | AC | 42 ms
55,204 KB |
testcase_43 | AC | 58 ms
66,784 KB |
testcase_44 | AC | 48 ms
61,108 KB |
testcase_45 | AC | 48 ms
62,520 KB |
testcase_46 | AC | 56 ms
66,704 KB |
testcase_47 | AC | 49 ms
63,576 KB |
testcase_48 | AC | 53 ms
64,312 KB |
testcase_49 | AC | 42 ms
55,884 KB |
testcase_50 | AC | 59 ms
67,232 KB |
testcase_51 | AC | 59 ms
66,772 KB |
testcase_52 | AC | 66 ms
67,344 KB |
testcase_53 | AC | 57 ms
66,020 KB |
testcase_54 | AC | 59 ms
67,332 KB |
testcase_55 | AC | 57 ms
66,940 KB |
testcase_56 | AC | 42 ms
55,348 KB |
testcase_57 | AC | 55 ms
64,072 KB |
testcase_58 | AC | 54 ms
65,288 KB |
testcase_59 | AC | 42 ms
55,436 KB |
testcase_60 | AC | 47 ms
61,284 KB |
testcase_61 | AC | 58 ms
66,304 KB |
testcase_62 | AC | 44 ms
56,268 KB |
testcase_63 | AC | 95 ms
78,596 KB |
testcase_64 | AC | 76 ms
74,800 KB |
testcase_65 | AC | 86 ms
77,984 KB |
testcase_66 | AC | 85 ms
77,572 KB |
testcase_67 | AC | 71 ms
74,348 KB |
testcase_68 | AC | 88 ms
78,104 KB |
testcase_69 | AC | 88 ms
78,044 KB |
testcase_70 | AC | 75 ms
74,580 KB |
testcase_71 | AC | 74 ms
73,172 KB |
testcase_72 | AC | 85 ms
78,288 KB |
testcase_73 | AC | 83 ms
77,184 KB |
testcase_74 | AC | 89 ms
77,832 KB |
testcase_75 | AC | 83 ms
77,912 KB |
testcase_76 | AC | 68 ms
71,336 KB |
testcase_77 | AC | 85 ms
77,328 KB |
testcase_78 | AC | 92 ms
78,756 KB |
testcase_79 | AC | 87 ms
78,472 KB |
testcase_80 | AC | 87 ms
78,088 KB |
testcase_81 | AC | 90 ms
78,528 KB |
testcase_82 | AC | 98 ms
78,696 KB |
testcase_83 | AC | 235 ms
94,532 KB |
testcase_84 | AC | 213 ms
93,436 KB |
testcase_85 | AC | 149 ms
87,244 KB |
testcase_86 | AC | 214 ms
91,908 KB |
testcase_87 | AC | 210 ms
92,944 KB |
testcase_88 | AC | 95 ms
79,300 KB |
testcase_89 | AC | 240 ms
94,368 KB |
testcase_90 | AC | 161 ms
87,340 KB |
testcase_91 | AC | 150 ms
85,536 KB |
testcase_92 | AC | 106 ms
80,608 KB |
testcase_93 | AC | 188 ms
90,548 KB |
testcase_94 | AC | 171 ms
89,252 KB |
testcase_95 | AC | 175 ms
89,248 KB |
testcase_96 | AC | 219 ms
93,368 KB |
testcase_97 | AC | 129 ms
84,268 KB |
testcase_98 | AC | 223 ms
93,384 KB |
testcase_99 | AC | 155 ms
86,812 KB |
testcase_100 | AC | 223 ms
94,412 KB |
testcase_101 | AC | 111 ms
80,124 KB |
testcase_102 | AC | 96 ms
78,696 KB |
testcase_103 | AC | 108 ms
81,060 KB |
testcase_104 | AC | 116 ms
81,384 KB |
testcase_105 | AC | 202 ms
90,676 KB |
testcase_106 | AC | 143 ms
85,368 KB |
testcase_107 | AC | 215 ms
94,236 KB |
testcase_108 | AC | 215 ms
93,756 KB |
testcase_109 | AC | 195 ms
90,876 KB |
testcase_110 | AC | 171 ms
89,192 KB |
testcase_111 | AC | 190 ms
89,936 KB |
testcase_112 | AC | 110 ms
81,264 KB |
testcase_113 | AC | 171 ms
88,000 KB |
testcase_114 | AC | 143 ms
84,716 KB |
testcase_115 | AC | 94 ms
79,168 KB |
testcase_116 | AC | 143 ms
85,656 KB |
testcase_117 | AC | 118 ms
81,392 KB |
testcase_118 | AC | 214 ms
92,940 KB |
testcase_119 | AC | 158 ms
86,996 KB |
testcase_120 | AC | 204 ms
92,424 KB |
testcase_121 | AC | 108 ms
81,000 KB |
testcase_122 | AC | 157 ms
86,388 KB |
testcase_123 | AC | 42 ms
55,376 KB |
testcase_124 | AC | 293 ms
105,200 KB |
testcase_125 | AC | 275 ms
104,924 KB |
ソースコード
import sys input = sys.stdin.readline from collections import deque class LowLink: def __init__(self, N, M): self.V = N self.E = M self.edge = [[] for _ in range(self.V)] self.edges = [0]*M self.visited = [False]*N self.parent = [N]*N self.order = [N]*N self.low = [N]*N def add_edges(self, ind=1): for i in range(self.E): a,b = map(int, input().split()) a -= ind b -= ind self.edge[a].append(b) self.edge[b].append(a) self.edges[i] = (a,b) def add_edge(self, a, b): self.edge[a].append(b) self.edge[b].append(a) def low_link(self, start): self.start = start stack = deque([start]) self.parent[start] = -1 self.order[start] = 0 self.cnts = [0]*self.V cnt = 1 while stack: v = stack[-1] for u in self.edge[v]: if u==self.parent[v]: continue if self.order[u]<self.order[v]: #後退辺の処理 self.low[v] = min(self.low[v], self.order[u]) elif self.cnts[u]==0: #行きがけ self.order[u] = self.low[u] = cnt self.parent[u] = v self.cnts[u] += 1 stack.append(u) cnt += 1 break elif self.cnts[u]==1: #帰りがけ self.low[v] = min(self.low[v], self.low[u]) self.cnts[u] += 1 else: stack.pop() #帰り return def bridge(self): res = [] for i,(a,b) in enumerate(self.edges): if G.order[a]>G.order[b]: a,b = b,a if G.low[b]<=G.order[a]: res.append(i+1) return res def articulation(self): res = [] for v in range(self.V): cnt = 0 for u in self.edge[v]: if self.parent[v]==u or self.parent[u]!=v: continue if self.order[v]<=self.low[u]: cnt += 1 if v==self.start: if cnt>=2: res.append(v) elif cnt>=1: res.append(v) return res N = int(input()) G = LowLink(N, N) G.add_edges(1) G.low_link(0) ans = G.bridge() print(len(ans)) print(*ans)