結果
問題 | No.1254 補強への架け橋 |
ユーザー | H3PO4 |
提出日時 | 2020-10-09 23:46:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 505 ms / 2,000 ms |
コード長 | 1,367 bytes |
コンパイル時間 | 237 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 191,232 KB |
最終ジャッジ日時 | 2024-07-20 14:36:57 |
合計ジャッジ時間 | 27,096 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
51,840 KB |
testcase_01 | AC | 42 ms
51,712 KB |
testcase_02 | AC | 40 ms
51,584 KB |
testcase_03 | AC | 40 ms
51,840 KB |
testcase_04 | AC | 40 ms
51,840 KB |
testcase_05 | AC | 41 ms
52,352 KB |
testcase_06 | AC | 41 ms
51,712 KB |
testcase_07 | AC | 41 ms
51,584 KB |
testcase_08 | AC | 41 ms
51,712 KB |
testcase_09 | AC | 41 ms
51,840 KB |
testcase_10 | AC | 40 ms
51,712 KB |
testcase_11 | AC | 40 ms
51,840 KB |
testcase_12 | AC | 40 ms
52,096 KB |
testcase_13 | AC | 41 ms
52,096 KB |
testcase_14 | AC | 41 ms
51,840 KB |
testcase_15 | AC | 41 ms
52,224 KB |
testcase_16 | AC | 42 ms
52,224 KB |
testcase_17 | AC | 40 ms
51,840 KB |
testcase_18 | AC | 40 ms
52,096 KB |
testcase_19 | AC | 41 ms
52,096 KB |
testcase_20 | AC | 42 ms
52,096 KB |
testcase_21 | AC | 41 ms
52,096 KB |
testcase_22 | AC | 41 ms
52,096 KB |
testcase_23 | AC | 42 ms
51,968 KB |
testcase_24 | AC | 41 ms
52,352 KB |
testcase_25 | AC | 42 ms
51,712 KB |
testcase_26 | AC | 41 ms
52,224 KB |
testcase_27 | AC | 41 ms
52,096 KB |
testcase_28 | AC | 41 ms
51,968 KB |
testcase_29 | AC | 41 ms
52,096 KB |
testcase_30 | AC | 41 ms
52,224 KB |
testcase_31 | AC | 41 ms
52,608 KB |
testcase_32 | AC | 40 ms
51,968 KB |
testcase_33 | AC | 41 ms
52,480 KB |
testcase_34 | AC | 40 ms
52,224 KB |
testcase_35 | AC | 42 ms
52,480 KB |
testcase_36 | AC | 42 ms
52,224 KB |
testcase_37 | AC | 42 ms
52,096 KB |
testcase_38 | AC | 42 ms
52,224 KB |
testcase_39 | AC | 41 ms
51,840 KB |
testcase_40 | AC | 42 ms
52,480 KB |
testcase_41 | AC | 41 ms
51,968 KB |
testcase_42 | AC | 42 ms
51,968 KB |
testcase_43 | AC | 58 ms
63,744 KB |
testcase_44 | AC | 44 ms
53,504 KB |
testcase_45 | AC | 44 ms
53,120 KB |
testcase_46 | AC | 58 ms
62,976 KB |
testcase_47 | AC | 48 ms
58,752 KB |
testcase_48 | AC | 62 ms
65,024 KB |
testcase_49 | AC | 42 ms
52,224 KB |
testcase_50 | AC | 61 ms
64,512 KB |
testcase_51 | AC | 63 ms
65,536 KB |
testcase_52 | AC | 68 ms
67,072 KB |
testcase_53 | AC | 59 ms
64,000 KB |
testcase_54 | AC | 68 ms
66,944 KB |
testcase_55 | AC | 59 ms
62,720 KB |
testcase_56 | AC | 43 ms
52,480 KB |
testcase_57 | AC | 52 ms
60,416 KB |
testcase_58 | AC | 53 ms
60,928 KB |
testcase_59 | AC | 43 ms
52,608 KB |
testcase_60 | AC | 44 ms
53,248 KB |
testcase_61 | AC | 59 ms
63,104 KB |
testcase_62 | AC | 43 ms
52,864 KB |
testcase_63 | AC | 133 ms
79,616 KB |
testcase_64 | AC | 97 ms
77,056 KB |
testcase_65 | AC | 117 ms
78,336 KB |
testcase_66 | AC | 116 ms
78,464 KB |
testcase_67 | AC | 93 ms
77,312 KB |
testcase_68 | AC | 114 ms
78,720 KB |
testcase_69 | AC | 123 ms
78,976 KB |
testcase_70 | AC | 106 ms
77,568 KB |
testcase_71 | AC | 96 ms
77,312 KB |
testcase_72 | AC | 118 ms
79,232 KB |
testcase_73 | AC | 99 ms
77,056 KB |
testcase_74 | AC | 116 ms
78,592 KB |
testcase_75 | AC | 117 ms
78,976 KB |
testcase_76 | AC | 76 ms
69,632 KB |
testcase_77 | AC | 113 ms
77,440 KB |
testcase_78 | AC | 138 ms
79,488 KB |
testcase_79 | AC | 127 ms
79,872 KB |
testcase_80 | AC | 121 ms
79,232 KB |
testcase_81 | AC | 123 ms
79,488 KB |
testcase_82 | AC | 122 ms
79,872 KB |
testcase_83 | AC | 377 ms
109,696 KB |
testcase_84 | AC | 389 ms
107,648 KB |
testcase_85 | AC | 272 ms
97,664 KB |
testcase_86 | AC | 342 ms
104,320 KB |
testcase_87 | AC | 367 ms
106,880 KB |
testcase_88 | AC | 146 ms
81,408 KB |
testcase_89 | AC | 409 ms
111,616 KB |
testcase_90 | AC | 282 ms
99,328 KB |
testcase_91 | AC | 251 ms
94,592 KB |
testcase_92 | AC | 175 ms
85,888 KB |
testcase_93 | AC | 329 ms
102,912 KB |
testcase_94 | AC | 317 ms
102,016 KB |
testcase_95 | AC | 321 ms
100,608 KB |
testcase_96 | AC | 372 ms
108,416 KB |
testcase_97 | AC | 227 ms
91,008 KB |
testcase_98 | AC | 402 ms
108,288 KB |
testcase_99 | AC | 272 ms
95,616 KB |
testcase_100 | AC | 406 ms
110,336 KB |
testcase_101 | AC | 183 ms
85,248 KB |
testcase_102 | AC | 136 ms
80,128 KB |
testcase_103 | AC | 189 ms
85,248 KB |
testcase_104 | AC | 217 ms
89,088 KB |
testcase_105 | AC | 330 ms
102,912 KB |
testcase_106 | AC | 238 ms
92,544 KB |
testcase_107 | AC | 410 ms
111,232 KB |
testcase_108 | AC | 401 ms
108,672 KB |
testcase_109 | AC | 329 ms
103,808 KB |
testcase_110 | AC | 320 ms
101,632 KB |
testcase_111 | AC | 325 ms
102,400 KB |
testcase_112 | AC | 198 ms
87,680 KB |
testcase_113 | AC | 310 ms
100,352 KB |
testcase_114 | AC | 238 ms
92,160 KB |
testcase_115 | AC | 155 ms
82,816 KB |
testcase_116 | AC | 255 ms
94,080 KB |
testcase_117 | AC | 199 ms
88,704 KB |
testcase_118 | AC | 394 ms
108,032 KB |
testcase_119 | AC | 275 ms
95,744 KB |
testcase_120 | AC | 366 ms
106,624 KB |
testcase_121 | AC | 184 ms
86,656 KB |
testcase_122 | AC | 262 ms
94,080 KB |
testcase_123 | AC | 41 ms
51,712 KB |
testcase_124 | AC | 505 ms
191,232 KB |
testcase_125 | AC | 502 ms
190,848 KB |
ソースコード
import sys sys.setrecursionlimit(10 ** 9) 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)