結果

問題 No.1254 補強への架け橋
ユーザー DrDrpilotDrDrpilot
提出日時 2022-01-29 12:55:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 828 ms / 2,000 ms
コード長 1,422 bytes
コンパイル時間 1,153 ms
コンパイル使用メモリ 11,064 KB
実行使用メモリ 73,732 KB
最終ジャッジ日時 2023-08-30 10:33:41
合計ジャッジ時間 35,549 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,080 KB
testcase_01 AC 16 ms
8,016 KB
testcase_02 AC 17 ms
8,076 KB
testcase_03 AC 17 ms
8,076 KB
testcase_04 AC 17 ms
8,028 KB
testcase_05 AC 17 ms
8,220 KB
testcase_06 AC 16 ms
8,136 KB
testcase_07 AC 16 ms
8,096 KB
testcase_08 AC 17 ms
8,076 KB
testcase_09 AC 17 ms
7,988 KB
testcase_10 AC 16 ms
8,132 KB
testcase_11 AC 16 ms
8,100 KB
testcase_12 AC 16 ms
7,996 KB
testcase_13 AC 17 ms
8,132 KB
testcase_14 AC 17 ms
8,156 KB
testcase_15 AC 17 ms
8,000 KB
testcase_16 AC 16 ms
8,040 KB
testcase_17 AC 16 ms
8,020 KB
testcase_18 AC 17 ms
8,136 KB
testcase_19 AC 16 ms
8,060 KB
testcase_20 AC 17 ms
8,096 KB
testcase_21 AC 16 ms
8,056 KB
testcase_22 AC 16 ms
8,000 KB
testcase_23 AC 16 ms
7,992 KB
testcase_24 AC 16 ms
8,200 KB
testcase_25 AC 16 ms
8,092 KB
testcase_26 AC 17 ms
8,148 KB
testcase_27 AC 17 ms
8,076 KB
testcase_28 AC 17 ms
8,056 KB
testcase_29 AC 17 ms
8,060 KB
testcase_30 AC 16 ms
8,076 KB
testcase_31 AC 17 ms
8,100 KB
testcase_32 AC 16 ms
8,148 KB
testcase_33 AC 17 ms
8,084 KB
testcase_34 AC 16 ms
8,196 KB
testcase_35 AC 16 ms
8,032 KB
testcase_36 AC 17 ms
8,136 KB
testcase_37 AC 17 ms
8,140 KB
testcase_38 AC 18 ms
8,060 KB
testcase_39 AC 17 ms
8,036 KB
testcase_40 AC 16 ms
8,148 KB
testcase_41 AC 17 ms
8,140 KB
testcase_42 AC 17 ms
8,156 KB
testcase_43 AC 21 ms
8,732 KB
testcase_44 AC 18 ms
8,552 KB
testcase_45 AC 18 ms
8,444 KB
testcase_46 AC 21 ms
8,812 KB
testcase_47 AC 19 ms
8,552 KB
testcase_48 AC 20 ms
8,640 KB
testcase_49 AC 17 ms
8,036 KB
testcase_50 AC 22 ms
8,856 KB
testcase_51 AC 21 ms
8,856 KB
testcase_52 AC 22 ms
8,744 KB
testcase_53 AC 20 ms
8,848 KB
testcase_54 AC 22 ms
8,772 KB
testcase_55 AC 21 ms
8,848 KB
testcase_56 AC 17 ms
8,148 KB
testcase_57 AC 19 ms
8,732 KB
testcase_58 AC 19 ms
8,728 KB
testcase_59 AC 16 ms
8,124 KB
testcase_60 AC 18 ms
8,056 KB
testcase_61 AC 21 ms
8,820 KB
testcase_62 AC 17 ms
8,152 KB
testcase_63 AC 76 ms
14,096 KB
testcase_64 AC 31 ms
9,792 KB
testcase_65 AC 55 ms
12,248 KB
testcase_66 AC 46 ms
11,624 KB
testcase_67 AC 28 ms
9,440 KB
testcase_68 AC 48 ms
11,724 KB
testcase_69 AC 59 ms
12,712 KB
testcase_70 AC 35 ms
10,244 KB
testcase_71 AC 30 ms
9,664 KB
testcase_72 AC 60 ms
12,788 KB
testcase_73 AC 33 ms
9,916 KB
testcase_74 AC 57 ms
12,636 KB
testcase_75 AC 46 ms
11,684 KB
testcase_76 AC 23 ms
8,848 KB
testcase_77 AC 41 ms
10,740 KB
testcase_78 AC 73 ms
13,508 KB
testcase_79 AC 70 ms
13,644 KB
testcase_80 AC 62 ms
13,004 KB
testcase_81 AC 70 ms
13,792 KB
testcase_82 AC 67 ms
13,388 KB
testcase_83 AC 825 ms
62,948 KB
testcase_84 AC 805 ms
60,696 KB
testcase_85 AC 458 ms
40,064 KB
testcase_86 AC 700 ms
55,520 KB
testcase_87 AC 805 ms
58,212 KB
testcase_88 AC 106 ms
16,260 KB
testcase_89 AC 824 ms
61,544 KB
testcase_90 AC 493 ms
41,632 KB
testcase_91 AC 409 ms
35,432 KB
testcase_92 AC 188 ms
23,828 KB
testcase_93 AC 638 ms
49,212 KB
testcase_94 AC 559 ms
45,592 KB
testcase_95 AC 552 ms
45,624 KB
testcase_96 AC 782 ms
59,156 KB
testcase_97 AC 307 ms
31,760 KB
testcase_98 AC 773 ms
59,728 KB
testcase_99 AC 429 ms
38,896 KB
testcase_100 AC 828 ms
62,880 KB
testcase_101 AC 172 ms
22,508 KB
testcase_102 AC 88 ms
15,012 KB
testcase_103 AC 188 ms
23,700 KB
testcase_104 AC 250 ms
28,436 KB
testcase_105 AC 709 ms
48,296 KB
testcase_106 AC 334 ms
33,636 KB
testcase_107 AC 822 ms
61,660 KB
testcase_108 AC 779 ms
62,028 KB
testcase_109 AC 615 ms
48,844 KB
testcase_110 AC 528 ms
45,128 KB
testcase_111 AC 599 ms
47,488 KB
testcase_112 AC 238 ms
27,540 KB
testcase_113 AC 533 ms
44,276 KB
testcase_114 AC 323 ms
33,008 KB
testcase_115 AC 110 ms
16,956 KB
testcase_116 AC 400 ms
36,284 KB
testcase_117 AC 248 ms
27,592 KB
testcase_118 AC 774 ms
59,992 KB
testcase_119 AC 433 ms
38,592 KB
testcase_120 AC 741 ms
58,492 KB
testcase_121 AC 234 ms
25,088 KB
testcase_122 AC 392 ms
35,932 KB
testcase_123 AC 16 ms
8,196 KB
testcase_124 AC 820 ms
73,732 KB
testcase_125 AC 824 ms
73,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**6)
def construct(G, N):
    P = [0]*N
    G0 = [[] for i in range(N)]
    V = []

    lb = [0]*N
    def dfs(v, p):
        P[v] = p
        V.append(v)
        lb[v] = len(V)
        for w in G[v]:
            if w == p:
                continue
            if lb[w]:
                if lb[v] < lb[w]:
                    G0[v].append(w)
                continue
            dfs(w, v)
    dfs(0, -1)

    B = []
    ap = [0]*N

    used = [0]*N
    first = 1
    used[0] = 1
    for u in V:
        if not used[u]:
            p = P[u]
            B.append((u, p) if u < p else (p, u))
            if len(G[u]) > 1:
                ap[u] = 1
            if len(G[p]) > 1:
                ap[p] = 1

        cycle = 0
        for v in G0[u]:
            w = v
            while w != u and not used[w]:
                used[w] = 1
                w = P[w]
            if w == u:
                cycle = 1

        if cycle:
            if not first:
                ap[u] = 1
            first = 0

    A = [v for v in range(N) if ap[v]]
    return B
n=int(input())
g=[[] for _ in range(n)]
bridge=[]
for _ in range(n):
    a,b=map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
    if a>b:
        a,b=b,a
    bridge.append((a-1,b-1))
l=construct(g,n)
l=set(l)
ans=[]
for i in range(n):
    if bridge[i] not in l:
        ans.append(i+1)
print(len(ans))
print(*ans)
0