結果

問題 No.1254 補強への架け橋
ユーザー brthyyjpbrthyyjp
提出日時 2020-10-09 23:02:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 316 ms / 2,000 ms
コード長 1,743 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 86,820 KB
実行使用メモリ 130,584 KB
最終ジャッジ日時 2023-09-27 19:20:26
合計ジャッジ時間 24,234 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,056 KB
testcase_01 AC 63 ms
71,052 KB
testcase_02 AC 65 ms
71,168 KB
testcase_03 AC 63 ms
71,116 KB
testcase_04 AC 63 ms
71,340 KB
testcase_05 AC 64 ms
71,348 KB
testcase_06 AC 64 ms
71,128 KB
testcase_07 AC 65 ms
70,820 KB
testcase_08 AC 66 ms
71,108 KB
testcase_09 AC 61 ms
71,404 KB
testcase_10 AC 63 ms
71,324 KB
testcase_11 AC 64 ms
71,120 KB
testcase_12 AC 63 ms
71,048 KB
testcase_13 AC 64 ms
71,160 KB
testcase_14 AC 64 ms
71,260 KB
testcase_15 AC 64 ms
71,276 KB
testcase_16 AC 67 ms
71,312 KB
testcase_17 AC 70 ms
71,108 KB
testcase_18 AC 65 ms
71,248 KB
testcase_19 AC 64 ms
71,184 KB
testcase_20 AC 65 ms
71,372 KB
testcase_21 AC 63 ms
71,188 KB
testcase_22 AC 65 ms
71,420 KB
testcase_23 AC 65 ms
70,884 KB
testcase_24 AC 69 ms
71,364 KB
testcase_25 AC 66 ms
71,052 KB
testcase_26 AC 68 ms
71,316 KB
testcase_27 AC 66 ms
71,168 KB
testcase_28 AC 65 ms
71,364 KB
testcase_29 AC 66 ms
71,324 KB
testcase_30 AC 67 ms
71,180 KB
testcase_31 AC 65 ms
70,884 KB
testcase_32 AC 64 ms
71,052 KB
testcase_33 AC 65 ms
71,324 KB
testcase_34 AC 65 ms
71,264 KB
testcase_35 AC 64 ms
71,400 KB
testcase_36 AC 62 ms
71,176 KB
testcase_37 AC 64 ms
71,172 KB
testcase_38 AC 62 ms
71,308 KB
testcase_39 AC 64 ms
71,160 KB
testcase_40 AC 64 ms
71,016 KB
testcase_41 AC 64 ms
70,872 KB
testcase_42 AC 64 ms
70,932 KB
testcase_43 AC 73 ms
75,732 KB
testcase_44 AC 65 ms
71,388 KB
testcase_45 AC 64 ms
71,420 KB
testcase_46 AC 77 ms
75,384 KB
testcase_47 AC 69 ms
71,328 KB
testcase_48 AC 70 ms
75,668 KB
testcase_49 AC 63 ms
71,308 KB
testcase_50 AC 78 ms
75,824 KB
testcase_51 AC 74 ms
75,980 KB
testcase_52 AC 76 ms
75,608 KB
testcase_53 AC 75 ms
75,592 KB
testcase_54 AC 73 ms
75,928 KB
testcase_55 AC 71 ms
75,668 KB
testcase_56 AC 64 ms
71,352 KB
testcase_57 AC 71 ms
75,180 KB
testcase_58 AC 71 ms
75,668 KB
testcase_59 AC 65 ms
71,272 KB
testcase_60 AC 65 ms
71,228 KB
testcase_61 AC 74 ms
75,968 KB
testcase_62 AC 70 ms
71,260 KB
testcase_63 AC 128 ms
80,500 KB
testcase_64 AC 112 ms
78,440 KB
testcase_65 AC 125 ms
79,620 KB
testcase_66 AC 119 ms
78,876 KB
testcase_67 AC 100 ms
78,188 KB
testcase_68 AC 120 ms
79,228 KB
testcase_69 AC 123 ms
80,080 KB
testcase_70 AC 111 ms
78,652 KB
testcase_71 AC 107 ms
78,312 KB
testcase_72 AC 127 ms
79,536 KB
testcase_73 AC 109 ms
78,288 KB
testcase_74 AC 127 ms
79,608 KB
testcase_75 AC 116 ms
79,172 KB
testcase_76 AC 88 ms
77,344 KB
testcase_77 AC 115 ms
78,308 KB
testcase_78 AC 126 ms
80,360 KB
testcase_79 AC 132 ms
81,104 KB
testcase_80 AC 122 ms
79,676 KB
testcase_81 AC 131 ms
80,884 KB
testcase_82 AC 120 ms
79,768 KB
testcase_83 AC 296 ms
125,272 KB
testcase_84 AC 290 ms
122,712 KB
testcase_85 AC 211 ms
107,076 KB
testcase_86 AC 262 ms
120,828 KB
testcase_87 AC 292 ms
125,128 KB
testcase_88 AC 131 ms
82,844 KB
testcase_89 AC 316 ms
126,984 KB
testcase_90 AC 218 ms
108,716 KB
testcase_91 AC 195 ms
101,408 KB
testcase_92 AC 154 ms
89,284 KB
testcase_93 AC 260 ms
119,268 KB
testcase_94 AC 239 ms
114,012 KB
testcase_95 AC 234 ms
113,340 KB
testcase_96 AC 281 ms
124,924 KB
testcase_97 AC 192 ms
96,736 KB
testcase_98 AC 288 ms
122,252 KB
testcase_99 AC 207 ms
105,676 KB
testcase_100 AC 305 ms
125,796 KB
testcase_101 AC 149 ms
88,324 KB
testcase_102 AC 131 ms
82,536 KB
testcase_103 AC 156 ms
89,628 KB
testcase_104 AC 167 ms
93,456 KB
testcase_105 AC 252 ms
119,120 KB
testcase_106 AC 180 ms
99,508 KB
testcase_107 AC 301 ms
125,108 KB
testcase_108 AC 300 ms
130,584 KB
testcase_109 AC 256 ms
117,608 KB
testcase_110 AC 238 ms
113,480 KB
testcase_111 AC 248 ms
114,700 KB
testcase_112 AC 164 ms
93,364 KB
testcase_113 AC 238 ms
112,796 KB
testcase_114 AC 180 ms
96,684 KB
testcase_115 AC 133 ms
83,048 KB
testcase_116 AC 200 ms
102,104 KB
testcase_117 AC 172 ms
93,212 KB
testcase_118 AC 283 ms
125,384 KB
testcase_119 AC 211 ms
104,860 KB
testcase_120 AC 284 ms
124,804 KB
testcase_121 AC 160 ms
90,224 KB
testcase_122 AC 203 ms
101,828 KB
testcase_123 AC 62 ms
71,176 KB
testcase_124 AC 278 ms
122,324 KB
testcase_125 AC 275 ms
122,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def lowlink(g, root=0):
    n = len(g)
    order = [n]*n
    low = [n]*n

    s = [root]
    cnt = 0
    par = [-1]*n
    seq = []
    while s:
        v = s.pop()
        if order[v] != n:
            continue
        order[v] = cnt
        seq.append(v)
        low[v] = cnt
        cnt += 1
        for u in g[v]:
            if order[u] < cnt:
                if par[v] != u:
                    low[v] = min(low[v], order[u])
                    continue
            else:
                par[u] = v
                s.append(u)
    child = [[] for _ in range(n)]
    for v in range(n):
        if par[v] != -1:
            child[par[v]].append(v)
    seq.reverse()
    for v in seq:
        for u in child[v]:
            low[v] = min(low[v], low[u])
    # bridge
    bridge = []
    for p in range(n):
        for c in child[p]:
            if order[p] < low[c]:
                bridge.append((p, c))

    # articulation points
    AP = []
    for v in range(n):
        if v == root:
            if len(child[v]) >= 2:
                AP.append(v)
        else:
            for c in child[v]:
                if order[v] <= low[c]:
                    AP.append(v)
                    break
    return AP, bridge

import sys
import io, os
input = sys.stdin.buffer.readline

n = int(input())
g = [[] for _ in range(n)]
d = {}
for i in range(n):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    if a > b:
        a, b = b, a
    g[a].append(b)
    g[b].append(a)
    d[(a, b)] = i
#print(d)
_, bridge = lowlink(g, 0)
s = set()
for u, v in bridge:
    if u > v:
        u, v = v, u
    s.add((u, v))

res = []
for k, v in d.items():
    if k in s:
        continue
    else:
        res.append(v+1)
print(len(res))
print(*res)
0