結果

問題 No.1254 補強への架け橋
ユーザー DrDrpilotDrDrpilot
提出日時 2022-01-29 12:53:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 1,382 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 11,060 KB
実行使用メモリ 62,960 KB
最終ジャッジ日時 2023-08-30 10:31:09
合計ジャッジ時間 33,761 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,072 KB
testcase_01 AC 17 ms
8,132 KB
testcase_02 AC 17 ms
8,024 KB
testcase_03 AC 17 ms
8,004 KB
testcase_04 AC 16 ms
8,004 KB
testcase_05 AC 17 ms
8,112 KB
testcase_06 AC 16 ms
8,100 KB
testcase_07 AC 16 ms
8,112 KB
testcase_08 AC 16 ms
8,112 KB
testcase_09 AC 16 ms
8,180 KB
testcase_10 AC 17 ms
8,176 KB
testcase_11 AC 17 ms
8,132 KB
testcase_12 AC 16 ms
8,116 KB
testcase_13 AC 17 ms
8,084 KB
testcase_14 AC 16 ms
8,080 KB
testcase_15 AC 16 ms
8,132 KB
testcase_16 AC 16 ms
8,004 KB
testcase_17 AC 16 ms
8,180 KB
testcase_18 AC 16 ms
8,132 KB
testcase_19 AC 17 ms
8,104 KB
testcase_20 AC 17 ms
8,124 KB
testcase_21 AC 17 ms
8,172 KB
testcase_22 AC 17 ms
8,072 KB
testcase_23 AC 16 ms
8,188 KB
testcase_24 AC 17 ms
8,068 KB
testcase_25 AC 17 ms
8,236 KB
testcase_26 AC 17 ms
8,120 KB
testcase_27 AC 16 ms
8,004 KB
testcase_28 AC 16 ms
8,032 KB
testcase_29 AC 16 ms
8,088 KB
testcase_30 AC 16 ms
8,108 KB
testcase_31 AC 16 ms
8,124 KB
testcase_32 AC 16 ms
8,100 KB
testcase_33 AC 16 ms
8,076 KB
testcase_34 AC 17 ms
8,028 KB
testcase_35 AC 17 ms
8,184 KB
testcase_36 AC 16 ms
8,044 KB
testcase_37 AC 17 ms
8,064 KB
testcase_38 AC 17 ms
8,072 KB
testcase_39 AC 17 ms
8,032 KB
testcase_40 AC 17 ms
8,032 KB
testcase_41 AC 16 ms
8,172 KB
testcase_42 AC 17 ms
8,072 KB
testcase_43 AC 21 ms
8,824 KB
testcase_44 AC 18 ms
8,168 KB
testcase_45 AC 18 ms
8,032 KB
testcase_46 AC 21 ms
8,768 KB
testcase_47 AC 19 ms
8,592 KB
testcase_48 AC 20 ms
8,600 KB
testcase_49 AC 16 ms
8,176 KB
testcase_50 AC 21 ms
8,888 KB
testcase_51 AC 21 ms
8,752 KB
testcase_52 AC 22 ms
8,708 KB
testcase_53 AC 21 ms
8,704 KB
testcase_54 AC 22 ms
8,688 KB
testcase_55 AC 20 ms
8,808 KB
testcase_56 AC 17 ms
8,172 KB
testcase_57 AC 20 ms
8,700 KB
testcase_58 AC 20 ms
8,672 KB
testcase_59 AC 17 ms
8,176 KB
testcase_60 AC 18 ms
8,024 KB
testcase_61 AC 21 ms
8,728 KB
testcase_62 AC 17 ms
8,128 KB
testcase_63 AC 74 ms
14,156 KB
testcase_64 AC 31 ms
9,844 KB
testcase_65 AC 52 ms
12,248 KB
testcase_66 AC 44 ms
11,424 KB
testcase_67 AC 28 ms
9,520 KB
testcase_68 AC 48 ms
11,728 KB
testcase_69 AC 57 ms
12,764 KB
testcase_70 AC 34 ms
10,068 KB
testcase_71 AC 30 ms
9,596 KB
testcase_72 AC 59 ms
12,864 KB
testcase_73 AC 32 ms
10,036 KB
testcase_74 AC 56 ms
12,460 KB
testcase_75 AC 45 ms
11,572 KB
testcase_76 AC 22 ms
8,912 KB
testcase_77 AC 40 ms
10,740 KB
testcase_78 AC 67 ms
13,520 KB
testcase_79 AC 69 ms
13,768 KB
testcase_80 AC 62 ms
12,988 KB
testcase_81 AC 71 ms
13,616 KB
testcase_82 AC 67 ms
13,384 KB
testcase_83 AC 841 ms
62,012 KB
testcase_84 AC 806 ms
60,540 KB
testcase_85 AC 459 ms
40,104 KB
testcase_86 AC 695 ms
55,416 KB
testcase_87 AC 788 ms
58,124 KB
testcase_88 AC 101 ms
16,228 KB
testcase_89 AC 830 ms
61,556 KB
testcase_90 AC 504 ms
41,716 KB
testcase_91 AC 398 ms
35,208 KB
testcase_92 AC 194 ms
23,820 KB
testcase_93 AC 679 ms
49,160 KB
testcase_94 AC 572 ms
45,628 KB
testcase_95 AC 570 ms
45,564 KB
testcase_96 AC 820 ms
59,252 KB
testcase_97 AC 326 ms
31,744 KB
testcase_98 AC 826 ms
60,568 KB
testcase_99 AC 466 ms
38,928 KB
testcase_100 AC 878 ms
62,960 KB
testcase_101 AC 173 ms
22,600 KB
testcase_102 AC 89 ms
14,984 KB
testcase_103 AC 193 ms
23,712 KB
testcase_104 AC 276 ms
28,608 KB
testcase_105 AC 668 ms
48,208 KB
testcase_106 AC 356 ms
33,688 KB
testcase_107 AC 857 ms
61,612 KB
testcase_108 AC 815 ms
62,028 KB
testcase_109 AC 652 ms
48,648 KB
testcase_110 AC 567 ms
45,244 KB
testcase_111 AC 631 ms
47,684 KB
testcase_112 AC 243 ms
27,480 KB
testcase_113 AC 560 ms
44,264 KB
testcase_114 AC 332 ms
32,952 KB
testcase_115 AC 109 ms
16,964 KB
testcase_116 AC 427 ms
36,436 KB
testcase_117 AC 249 ms
27,660 KB
testcase_118 AC 816 ms
59,944 KB
testcase_119 AC 461 ms
38,440 KB
testcase_120 AC 781 ms
58,500 KB
testcase_121 AC 218 ms
25,344 KB
testcase_122 AC 413 ms
35,968 KB
testcase_123 AC 16 ms
8,068 KB
testcase_124 RE -
testcase_125 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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