結果
問題 | No.1254 補強への架け橋 |
ユーザー | marroncastle |
提出日時 | 2020-11-26 03:28:28 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 301 ms / 2,000 ms |
コード長 | 2,082 bytes |
コンパイル時間 | 609 ms |
コンパイル使用メモリ | 82,288 KB |
実行使用メモリ | 105,076 KB |
最終ジャッジ日時 | 2024-07-23 20:39:56 |
合計ジャッジ時間 | 21,193 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
54,992 KB |
testcase_01 | AC | 42 ms
54,668 KB |
testcase_02 | AC | 42 ms
54,004 KB |
testcase_03 | AC | 43 ms
54,604 KB |
testcase_04 | AC | 43 ms
54,752 KB |
testcase_05 | AC | 44 ms
54,820 KB |
testcase_06 | AC | 42 ms
54,236 KB |
testcase_07 | AC | 42 ms
55,700 KB |
testcase_08 | AC | 42 ms
55,264 KB |
testcase_09 | AC | 42 ms
54,760 KB |
testcase_10 | AC | 42 ms
54,680 KB |
testcase_11 | AC | 42 ms
54,456 KB |
testcase_12 | AC | 41 ms
55,620 KB |
testcase_13 | AC | 42 ms
55,536 KB |
testcase_14 | AC | 42 ms
54,040 KB |
testcase_15 | AC | 44 ms
56,116 KB |
testcase_16 | AC | 42 ms
54,876 KB |
testcase_17 | AC | 42 ms
54,332 KB |
testcase_18 | AC | 42 ms
54,588 KB |
testcase_19 | AC | 44 ms
54,656 KB |
testcase_20 | AC | 43 ms
55,260 KB |
testcase_21 | AC | 42 ms
54,536 KB |
testcase_22 | AC | 42 ms
55,544 KB |
testcase_23 | AC | 43 ms
55,980 KB |
testcase_24 | AC | 42 ms
56,192 KB |
testcase_25 | AC | 43 ms
54,820 KB |
testcase_26 | AC | 44 ms
55,340 KB |
testcase_27 | AC | 43 ms
55,116 KB |
testcase_28 | AC | 41 ms
55,060 KB |
testcase_29 | AC | 42 ms
54,104 KB |
testcase_30 | AC | 42 ms
55,316 KB |
testcase_31 | AC | 42 ms
55,080 KB |
testcase_32 | AC | 41 ms
55,052 KB |
testcase_33 | AC | 42 ms
55,380 KB |
testcase_34 | AC | 42 ms
54,872 KB |
testcase_35 | AC | 42 ms
55,776 KB |
testcase_36 | AC | 44 ms
54,528 KB |
testcase_37 | AC | 43 ms
54,844 KB |
testcase_38 | AC | 43 ms
55,520 KB |
testcase_39 | AC | 41 ms
54,872 KB |
testcase_40 | AC | 44 ms
55,324 KB |
testcase_41 | AC | 43 ms
54,860 KB |
testcase_42 | AC | 42 ms
55,444 KB |
testcase_43 | AC | 58 ms
66,320 KB |
testcase_44 | AC | 48 ms
61,672 KB |
testcase_45 | AC | 50 ms
63,140 KB |
testcase_46 | AC | 60 ms
66,436 KB |
testcase_47 | AC | 49 ms
63,648 KB |
testcase_48 | AC | 53 ms
64,300 KB |
testcase_49 | AC | 44 ms
55,560 KB |
testcase_50 | AC | 58 ms
66,264 KB |
testcase_51 | AC | 60 ms
66,560 KB |
testcase_52 | AC | 61 ms
67,012 KB |
testcase_53 | AC | 59 ms
66,540 KB |
testcase_54 | AC | 59 ms
67,644 KB |
testcase_55 | AC | 60 ms
67,236 KB |
testcase_56 | AC | 44 ms
54,824 KB |
testcase_57 | AC | 54 ms
64,280 KB |
testcase_58 | AC | 54 ms
63,852 KB |
testcase_59 | AC | 43 ms
54,928 KB |
testcase_60 | AC | 47 ms
61,276 KB |
testcase_61 | AC | 57 ms
65,424 KB |
testcase_62 | AC | 42 ms
54,864 KB |
testcase_63 | AC | 94 ms
78,480 KB |
testcase_64 | AC | 74 ms
74,392 KB |
testcase_65 | AC | 88 ms
77,700 KB |
testcase_66 | AC | 87 ms
77,292 KB |
testcase_67 | AC | 73 ms
73,832 KB |
testcase_68 | AC | 89 ms
78,120 KB |
testcase_69 | AC | 91 ms
77,960 KB |
testcase_70 | AC | 75 ms
75,252 KB |
testcase_71 | AC | 71 ms
74,548 KB |
testcase_72 | AC | 86 ms
78,072 KB |
testcase_73 | AC | 84 ms
77,128 KB |
testcase_74 | AC | 90 ms
78,104 KB |
testcase_75 | AC | 82 ms
77,316 KB |
testcase_76 | AC | 69 ms
72,008 KB |
testcase_77 | AC | 86 ms
77,140 KB |
testcase_78 | AC | 95 ms
78,272 KB |
testcase_79 | AC | 89 ms
78,240 KB |
testcase_80 | AC | 90 ms
77,944 KB |
testcase_81 | AC | 90 ms
78,332 KB |
testcase_82 | AC | 98 ms
78,380 KB |
testcase_83 | AC | 239 ms
94,568 KB |
testcase_84 | AC | 225 ms
93,424 KB |
testcase_85 | AC | 150 ms
87,168 KB |
testcase_86 | AC | 191 ms
91,496 KB |
testcase_87 | AC | 215 ms
92,580 KB |
testcase_88 | AC | 94 ms
79,396 KB |
testcase_89 | AC | 237 ms
93,920 KB |
testcase_90 | AC | 170 ms
87,592 KB |
testcase_91 | AC | 153 ms
85,468 KB |
testcase_92 | AC | 111 ms
80,504 KB |
testcase_93 | AC | 201 ms
90,572 KB |
testcase_94 | AC | 175 ms
89,252 KB |
testcase_95 | AC | 174 ms
89,232 KB |
testcase_96 | AC | 221 ms
92,988 KB |
testcase_97 | AC | 129 ms
84,132 KB |
testcase_98 | AC | 226 ms
93,060 KB |
testcase_99 | AC | 166 ms
87,084 KB |
testcase_100 | AC | 240 ms
94,288 KB |
testcase_101 | AC | 113 ms
80,516 KB |
testcase_102 | AC | 96 ms
79,288 KB |
testcase_103 | AC | 108 ms
80,704 KB |
testcase_104 | AC | 119 ms
81,220 KB |
testcase_105 | AC | 212 ms
90,808 KB |
testcase_106 | AC | 140 ms
84,980 KB |
testcase_107 | AC | 213 ms
93,976 KB |
testcase_108 | AC | 221 ms
93,620 KB |
testcase_109 | AC | 179 ms
90,740 KB |
testcase_110 | AC | 179 ms
89,420 KB |
testcase_111 | AC | 196 ms
90,064 KB |
testcase_112 | AC | 116 ms
81,380 KB |
testcase_113 | AC | 175 ms
88,112 KB |
testcase_114 | AC | 148 ms
84,784 KB |
testcase_115 | AC | 97 ms
79,160 KB |
testcase_116 | AC | 146 ms
85,880 KB |
testcase_117 | AC | 117 ms
81,128 KB |
testcase_118 | AC | 213 ms
92,920 KB |
testcase_119 | AC | 152 ms
86,716 KB |
testcase_120 | AC | 216 ms
92,376 KB |
testcase_121 | AC | 111 ms
80,688 KB |
testcase_122 | AC | 153 ms
85,724 KB |
testcase_123 | AC | 43 ms
55,248 KB |
testcase_124 | AC | 301 ms
105,076 KB |
testcase_125 | AC | 271 ms
104,940 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 order = 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] = order self.parent[u] = v self.cnts[u] += 1 stack.append(u) order += 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 self.order[a]>self.order[b]: a,b = b,a if self.low[b]<=self.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)