結果
問題 | No.1254 補強への架け橋 |
ユーザー | nehan_der_thal |
提出日時 | 2020-10-09 22:52:34 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,118 bytes |
コンパイル時間 | 223 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 140,456 KB |
最終ジャッジ日時 | 2024-07-20 13:26:04 |
合計ジャッジ時間 | 28,228 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
52,224 KB |
testcase_01 | AC | 37 ms
52,096 KB |
testcase_02 | AC | 37 ms
51,840 KB |
testcase_03 | AC | 36 ms
52,096 KB |
testcase_04 | AC | 36 ms
52,524 KB |
testcase_05 | AC | 39 ms
52,268 KB |
testcase_06 | AC | 38 ms
52,240 KB |
testcase_07 | AC | 37 ms
52,224 KB |
testcase_08 | AC | 39 ms
52,096 KB |
testcase_09 | AC | 38 ms
52,352 KB |
testcase_10 | AC | 38 ms
52,352 KB |
testcase_11 | AC | 38 ms
52,096 KB |
testcase_12 | AC | 37 ms
52,224 KB |
testcase_13 | AC | 38 ms
52,352 KB |
testcase_14 | AC | 38 ms
52,992 KB |
testcase_15 | AC | 39 ms
52,352 KB |
testcase_16 | AC | 37 ms
52,352 KB |
testcase_17 | AC | 36 ms
52,608 KB |
testcase_18 | AC | 37 ms
52,480 KB |
testcase_19 | AC | 37 ms
51,968 KB |
testcase_20 | AC | 38 ms
52,736 KB |
testcase_21 | AC | 38 ms
52,608 KB |
testcase_22 | AC | 39 ms
52,480 KB |
testcase_23 | AC | 38 ms
52,480 KB |
testcase_24 | AC | 38 ms
52,736 KB |
testcase_25 | AC | 38 ms
52,864 KB |
testcase_26 | AC | 38 ms
52,480 KB |
testcase_27 | AC | 36 ms
52,608 KB |
testcase_28 | AC | 38 ms
52,480 KB |
testcase_29 | AC | 37 ms
52,096 KB |
testcase_30 | AC | 37 ms
52,608 KB |
testcase_31 | AC | 39 ms
52,352 KB |
testcase_32 | AC | 36 ms
52,352 KB |
testcase_33 | AC | 38 ms
53,052 KB |
testcase_34 | AC | 38 ms
52,992 KB |
testcase_35 | AC | 38 ms
52,608 KB |
testcase_36 | AC | 40 ms
52,736 KB |
testcase_37 | AC | 38 ms
52,352 KB |
testcase_38 | AC | 38 ms
52,480 KB |
testcase_39 | AC | 37 ms
52,480 KB |
testcase_40 | AC | 37 ms
52,608 KB |
testcase_41 | AC | 38 ms
52,992 KB |
testcase_42 | AC | 38 ms
52,736 KB |
testcase_43 | AC | 56 ms
63,616 KB |
testcase_44 | AC | 42 ms
54,016 KB |
testcase_45 | AC | 55 ms
54,144 KB |
testcase_46 | AC | 54 ms
63,104 KB |
testcase_47 | AC | 45 ms
55,040 KB |
testcase_48 | AC | 59 ms
65,024 KB |
testcase_49 | AC | 38 ms
52,608 KB |
testcase_50 | AC | 60 ms
64,896 KB |
testcase_51 | AC | 60 ms
65,664 KB |
testcase_52 | AC | 72 ms
67,712 KB |
testcase_53 | AC | 64 ms
63,744 KB |
testcase_54 | AC | 63 ms
66,944 KB |
testcase_55 | AC | 61 ms
62,336 KB |
testcase_56 | AC | 45 ms
52,992 KB |
testcase_57 | AC | 57 ms
60,928 KB |
testcase_58 | AC | 58 ms
60,800 KB |
testcase_59 | AC | 44 ms
52,608 KB |
testcase_60 | AC | 46 ms
53,760 KB |
testcase_61 | AC | 55 ms
62,848 KB |
testcase_62 | AC | 39 ms
52,992 KB |
testcase_63 | AC | 138 ms
83,200 KB |
testcase_64 | AC | 99 ms
77,440 KB |
testcase_65 | AC | 130 ms
81,024 KB |
testcase_66 | AC | 118 ms
79,232 KB |
testcase_67 | AC | 105 ms
77,312 KB |
testcase_68 | AC | 124 ms
79,360 KB |
testcase_69 | AC | 129 ms
81,536 KB |
testcase_70 | AC | 110 ms
78,080 KB |
testcase_71 | AC | 99 ms
77,440 KB |
testcase_72 | AC | 124 ms
81,408 KB |
testcase_73 | AC | 104 ms
77,568 KB |
testcase_74 | AC | 126 ms
81,280 KB |
testcase_75 | AC | 123 ms
79,488 KB |
testcase_76 | AC | 84 ms
74,624 KB |
testcase_77 | AC | 117 ms
79,104 KB |
testcase_78 | AC | 140 ms
82,944 KB |
testcase_79 | AC | 129 ms
82,560 KB |
testcase_80 | AC | 140 ms
82,048 KB |
testcase_81 | AC | 135 ms
82,688 KB |
testcase_82 | AC | 130 ms
81,920 KB |
testcase_83 | AC | 492 ms
139,836 KB |
testcase_84 | AC | 500 ms
131,620 KB |
testcase_85 | AC | 323 ms
110,776 KB |
testcase_86 | AC | 408 ms
124,904 KB |
testcase_87 | AC | 416 ms
127,192 KB |
testcase_88 | AC | 150 ms
85,760 KB |
testcase_89 | AC | 467 ms
139,328 KB |
testcase_90 | AC | 359 ms
113,548 KB |
testcase_91 | AC | 299 ms
105,228 KB |
testcase_92 | AC | 193 ms
94,336 KB |
testcase_93 | AC | 435 ms
122,580 KB |
testcase_94 | AC | 345 ms
118,156 KB |
testcase_95 | AC | 348 ms
117,988 KB |
testcase_96 | AC | 427 ms
131,140 KB |
testcase_97 | AC | 263 ms
99,908 KB |
testcase_98 | AC | 457 ms
131,444 KB |
testcase_99 | AC | 297 ms
108,484 KB |
testcase_100 | AC | 496 ms
140,456 KB |
testcase_101 | AC | 189 ms
92,032 KB |
testcase_102 | AC | 142 ms
84,608 KB |
testcase_103 | AC | 200 ms
92,928 KB |
testcase_104 | AC | 238 ms
96,692 KB |
testcase_105 | AC | 417 ms
122,784 KB |
testcase_106 | AC | 260 ms
102,896 KB |
testcase_107 | AC | 473 ms
139,164 KB |
testcase_108 | AC | 447 ms
134,640 KB |
testcase_109 | AC | 359 ms
122,072 KB |
testcase_110 | AC | 351 ms
119,108 KB |
testcase_111 | AC | 358 ms
120,368 KB |
testcase_112 | AC | 217 ms
95,616 KB |
testcase_113 | AC | 347 ms
117,760 KB |
testcase_114 | AC | 277 ms
100,792 KB |
testcase_115 | AC | 173 ms
85,632 KB |
testcase_116 | AC | 275 ms
105,496 KB |
testcase_117 | AC | 216 ms
96,124 KB |
testcase_118 | AC | 438 ms
130,720 KB |
testcase_119 | AC | 303 ms
108,420 KB |
testcase_120 | AC | 407 ms
127,976 KB |
testcase_121 | AC | 200 ms
94,336 KB |
testcase_122 | AC | 285 ms
105,608 KB |
testcase_123 | AC | 35 ms
51,968 KB |
testcase_124 | RE | - |
testcase_125 | RE | - |
ソースコード
# 単純に橋となる辺を返す def bridge(G, N): 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, = map(int, input().split()) G = [[] for _ in range(N)] E = dict() for i in range(N): a, b = map(int, input().split()) G[a-1].append(b-1) G[b-1].append(a-1) E[(a-1, b-1)] = i+1 E[(b-1, a-1)] = i+1 es = set([E[x] for x in bridge(G, N)]) R =[i for i in range(1, N+1) if i not in es] print(len(R)) print(*R)