結果

問題 No.1254 補強への架け橋
ユーザー H3PO4H3PO4
提出日時 2020-10-09 22:51:15
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,336 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 112,452 KB
最終ジャッジ日時 2023-09-27 18:52:10
合計ジャッジ時間 27,283 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,148 KB
testcase_01 AC 67 ms
71,204 KB
testcase_02 AC 67 ms
71,380 KB
testcase_03 AC 67 ms
71,184 KB
testcase_04 AC 64 ms
71,040 KB
testcase_05 AC 66 ms
71,484 KB
testcase_06 AC 65 ms
71,036 KB
testcase_07 AC 65 ms
71,148 KB
testcase_08 AC 66 ms
71,152 KB
testcase_09 AC 66 ms
71,164 KB
testcase_10 AC 68 ms
71,304 KB
testcase_11 AC 67 ms
71,392 KB
testcase_12 AC 69 ms
71,388 KB
testcase_13 AC 66 ms
71,248 KB
testcase_14 AC 68 ms
71,212 KB
testcase_15 AC 66 ms
71,244 KB
testcase_16 AC 67 ms
71,452 KB
testcase_17 AC 67 ms
71,264 KB
testcase_18 AC 67 ms
71,572 KB
testcase_19 AC 67 ms
71,064 KB
testcase_20 AC 66 ms
71,376 KB
testcase_21 AC 65 ms
71,328 KB
testcase_22 AC 66 ms
71,244 KB
testcase_23 AC 67 ms
71,376 KB
testcase_24 AC 66 ms
71,148 KB
testcase_25 AC 66 ms
71,060 KB
testcase_26 AC 68 ms
71,148 KB
testcase_27 AC 67 ms
71,560 KB
testcase_28 AC 66 ms
71,476 KB
testcase_29 AC 67 ms
71,452 KB
testcase_30 AC 68 ms
71,216 KB
testcase_31 AC 66 ms
71,540 KB
testcase_32 AC 67 ms
71,284 KB
testcase_33 AC 68 ms
71,372 KB
testcase_34 AC 66 ms
71,172 KB
testcase_35 AC 65 ms
71,248 KB
testcase_36 AC 67 ms
71,140 KB
testcase_37 AC 68 ms
71,364 KB
testcase_38 AC 65 ms
71,376 KB
testcase_39 AC 69 ms
71,220 KB
testcase_40 AC 66 ms
71,424 KB
testcase_41 AC 66 ms
71,324 KB
testcase_42 AC 67 ms
71,268 KB
testcase_43 AC 78 ms
76,540 KB
testcase_44 AC 72 ms
75,176 KB
testcase_45 AC 74 ms
71,320 KB
testcase_46 AC 81 ms
76,644 KB
testcase_47 AC 70 ms
74,872 KB
testcase_48 AC 78 ms
76,556 KB
testcase_49 AC 64 ms
71,064 KB
testcase_50 AC 81 ms
76,356 KB
testcase_51 AC 82 ms
76,592 KB
testcase_52 AC 89 ms
76,640 KB
testcase_53 AC 81 ms
76,380 KB
testcase_54 AC 85 ms
76,504 KB
testcase_55 AC 78 ms
76,508 KB
testcase_56 AC 68 ms
71,424 KB
testcase_57 AC 75 ms
75,460 KB
testcase_58 AC 73 ms
75,436 KB
testcase_59 AC 67 ms
71,344 KB
testcase_60 AC 70 ms
71,380 KB
testcase_61 AC 80 ms
76,268 KB
testcase_62 AC 68 ms
71,280 KB
testcase_63 AC 135 ms
82,280 KB
testcase_64 AC 106 ms
78,624 KB
testcase_65 AC 126 ms
80,588 KB
testcase_66 AC 124 ms
79,048 KB
testcase_67 AC 102 ms
78,508 KB
testcase_68 AC 118 ms
79,088 KB
testcase_69 AC 129 ms
80,392 KB
testcase_70 AC 114 ms
78,964 KB
testcase_71 AC 104 ms
78,432 KB
testcase_72 AC 126 ms
80,892 KB
testcase_73 AC 109 ms
78,192 KB
testcase_74 AC 127 ms
80,216 KB
testcase_75 AC 124 ms
79,104 KB
testcase_76 AC 91 ms
76,824 KB
testcase_77 AC 119 ms
79,108 KB
testcase_78 AC 145 ms
81,528 KB
testcase_79 AC 135 ms
81,036 KB
testcase_80 AC 128 ms
80,368 KB
testcase_81 AC 130 ms
80,696 KB
testcase_82 AC 130 ms
80,368 KB
testcase_83 AC 367 ms
112,180 KB
testcase_84 AC 362 ms
109,304 KB
testcase_85 AC 272 ms
99,248 KB
testcase_86 AC 323 ms
105,036 KB
testcase_87 AC 357 ms
108,724 KB
testcase_88 AC 150 ms
83,252 KB
testcase_89 AC 385 ms
110,888 KB
testcase_90 AC 296 ms
100,288 KB
testcase_91 AC 254 ms
96,268 KB
testcase_92 AC 178 ms
88,132 KB
testcase_93 AC 319 ms
104,344 KB
testcase_94 AC 319 ms
101,868 KB
testcase_95 AC 307 ms
101,820 KB
testcase_96 AC 351 ms
109,092 KB
testcase_97 AC 219 ms
92,704 KB
testcase_98 AC 373 ms
108,492 KB
testcase_99 AC 255 ms
98,488 KB
testcase_100 AC 387 ms
112,452 KB
testcase_101 AC 178 ms
86,872 KB
testcase_102 AC 139 ms
81,960 KB
testcase_103 AC 189 ms
86,996 KB
testcase_104 AC 216 ms
90,228 KB
testcase_105 AC 321 ms
103,928 KB
testcase_106 AC 236 ms
93,808 KB
testcase_107 AC 379 ms
110,780 KB
testcase_108 AC 382 ms
110,664 KB
testcase_109 AC 316 ms
103,392 KB
testcase_110 AC 309 ms
102,400 KB
testcase_111 AC 319 ms
102,840 KB
testcase_112 AC 197 ms
89,496 KB
testcase_113 AC 311 ms
101,772 KB
testcase_114 AC 242 ms
92,956 KB
testcase_115 AC 163 ms
83,956 KB
testcase_116 AC 255 ms
96,696 KB
testcase_117 AC 199 ms
90,500 KB
testcase_118 AC 379 ms
108,828 KB
testcase_119 AC 258 ms
97,620 KB
testcase_120 AC 341 ms
107,408 KB
testcase_121 AC 187 ms
87,740 KB
testcase_122 AC 252 ms
96,184 KB
testcase_123 AC 66 ms
70,992 KB
testcase_124 RE -
testcase_125 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0