結果

問題 No.1254 補強への架け橋
ユーザー marroncastlemarroncastle
提出日時 2020-10-10 07:33:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 443 ms / 2,000 ms
コード長 2,040 bytes
コンパイル時間 339 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 128,580 KB
最終ジャッジ日時 2023-09-27 21:07:04
合計ジャッジ時間 28,020 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
71,408 KB
testcase_01 AC 89 ms
71,164 KB
testcase_02 AC 87 ms
71,452 KB
testcase_03 AC 88 ms
71,420 KB
testcase_04 AC 89 ms
71,504 KB
testcase_05 AC 85 ms
71,416 KB
testcase_06 AC 86 ms
71,400 KB
testcase_07 AC 89 ms
71,420 KB
testcase_08 AC 86 ms
71,352 KB
testcase_09 AC 86 ms
71,532 KB
testcase_10 AC 86 ms
71,300 KB
testcase_11 AC 86 ms
71,488 KB
testcase_12 AC 86 ms
71,300 KB
testcase_13 AC 85 ms
71,476 KB
testcase_14 AC 86 ms
71,552 KB
testcase_15 AC 87 ms
71,244 KB
testcase_16 AC 89 ms
71,404 KB
testcase_17 AC 88 ms
71,532 KB
testcase_18 AC 86 ms
71,360 KB
testcase_19 AC 88 ms
71,552 KB
testcase_20 AC 86 ms
71,524 KB
testcase_21 AC 87 ms
71,300 KB
testcase_22 AC 85 ms
71,112 KB
testcase_23 AC 88 ms
71,500 KB
testcase_24 AC 86 ms
71,440 KB
testcase_25 AC 90 ms
71,300 KB
testcase_26 AC 89 ms
71,544 KB
testcase_27 AC 85 ms
71,168 KB
testcase_28 AC 87 ms
71,516 KB
testcase_29 AC 85 ms
71,388 KB
testcase_30 AC 86 ms
71,392 KB
testcase_31 AC 87 ms
71,504 KB
testcase_32 AC 90 ms
71,576 KB
testcase_33 AC 88 ms
71,112 KB
testcase_34 AC 87 ms
71,408 KB
testcase_35 AC 87 ms
71,400 KB
testcase_36 AC 94 ms
71,512 KB
testcase_37 AC 88 ms
71,160 KB
testcase_38 AC 89 ms
71,408 KB
testcase_39 AC 86 ms
71,580 KB
testcase_40 AC 91 ms
71,404 KB
testcase_41 AC 92 ms
71,244 KB
testcase_42 AC 89 ms
71,504 KB
testcase_43 AC 105 ms
76,968 KB
testcase_44 AC 96 ms
76,300 KB
testcase_45 AC 96 ms
76,772 KB
testcase_46 AC 100 ms
77,024 KB
testcase_47 AC 94 ms
76,152 KB
testcase_48 AC 99 ms
77,004 KB
testcase_49 AC 88 ms
71,292 KB
testcase_50 AC 103 ms
76,800 KB
testcase_51 AC 105 ms
76,772 KB
testcase_52 AC 105 ms
76,824 KB
testcase_53 AC 100 ms
76,816 KB
testcase_54 AC 100 ms
76,904 KB
testcase_55 AC 99 ms
77,028 KB
testcase_56 AC 94 ms
71,260 KB
testcase_57 AC 108 ms
76,556 KB
testcase_58 AC 97 ms
76,884 KB
testcase_59 AC 89 ms
71,244 KB
testcase_60 AC 98 ms
76,308 KB
testcase_61 AC 104 ms
76,836 KB
testcase_62 AC 90 ms
71,400 KB
testcase_63 AC 139 ms
84,132 KB
testcase_64 AC 123 ms
78,276 KB
testcase_65 AC 136 ms
81,836 KB
testcase_66 AC 130 ms
79,688 KB
testcase_67 AC 120 ms
78,056 KB
testcase_68 AC 137 ms
81,292 KB
testcase_69 AC 131 ms
80,600 KB
testcase_70 AC 126 ms
78,772 KB
testcase_71 AC 121 ms
78,312 KB
testcase_72 AC 137 ms
82,344 KB
testcase_73 AC 125 ms
78,592 KB
testcase_74 AC 137 ms
82,328 KB
testcase_75 AC 120 ms
79,480 KB
testcase_76 AC 111 ms
77,480 KB
testcase_77 AC 128 ms
79,316 KB
testcase_78 AC 139 ms
83,596 KB
testcase_79 AC 141 ms
83,368 KB
testcase_80 AC 140 ms
82,784 KB
testcase_81 AC 143 ms
83,336 KB
testcase_82 AC 142 ms
83,004 KB
testcase_83 AC 344 ms
122,864 KB
testcase_84 AC 344 ms
122,668 KB
testcase_85 AC 252 ms
110,184 KB
testcase_86 AC 310 ms
113,344 KB
testcase_87 AC 326 ms
119,668 KB
testcase_88 AC 149 ms
87,284 KB
testcase_89 AC 347 ms
123,064 KB
testcase_90 AC 258 ms
110,460 KB
testcase_91 AC 225 ms
104,824 KB
testcase_92 AC 168 ms
90,604 KB
testcase_93 AC 295 ms
112,252 KB
testcase_94 AC 271 ms
111,192 KB
testcase_95 AC 278 ms
111,300 KB
testcase_96 AC 324 ms
121,716 KB
testcase_97 AC 214 ms
100,540 KB
testcase_98 AC 347 ms
122,252 KB
testcase_99 AC 244 ms
109,952 KB
testcase_100 AC 370 ms
123,456 KB
testcase_101 AC 176 ms
91,628 KB
testcase_102 AC 152 ms
85,080 KB
testcase_103 AC 169 ms
91,760 KB
testcase_104 AC 183 ms
92,624 KB
testcase_105 AC 308 ms
112,020 KB
testcase_106 AC 213 ms
101,248 KB
testcase_107 AC 350 ms
122,868 KB
testcase_108 AC 342 ms
122,604 KB
testcase_109 AC 298 ms
112,092 KB
testcase_110 AC 273 ms
111,128 KB
testcase_111 AC 285 ms
111,596 KB
testcase_112 AC 183 ms
92,808 KB
testcase_113 AC 270 ms
110,924 KB
testcase_114 AC 222 ms
101,208 KB
testcase_115 AC 148 ms
87,204 KB
testcase_116 AC 226 ms
105,264 KB
testcase_117 AC 178 ms
92,612 KB
testcase_118 AC 336 ms
121,888 KB
testcase_119 AC 237 ms
108,468 KB
testcase_120 AC 322 ms
119,168 KB
testcase_121 AC 172 ms
90,708 KB
testcase_122 AC 240 ms
104,756 KB
testcase_123 AC 88 ms
71,544 KB
testcase_124 AC 443 ms
128,468 KB
testcase_125 AC 437 ms
128,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import deque
class LowLink:
  def __init__(self, N, M):
    self.V = N
    self.E = M
    self.edge = [[] for _ in range(self.V)]
    self.edges = [0]*M
    self.visited = [False]*N
    self.parent = [N]*N
    self.order = [N]*N
    self.low = [N]*N
    self.dic = dict()
  
  def add_edges(self, ind=1):
    for i in range(self.E):
      a,b = map(int, input().split())
      a -= ind
      b -= ind
      self.edge[a].append(b)
      self.edge[b].append(a)
      self.edges[i] = (a,b)
      self.dic[(a,b)] = i+1
      self.dic[(b,a)] = i+1

  def add_edge(self, a, b):
    self.edge[a].append(b)
    self.edge[b].append(a)

  def low_link(self, start):
    self.start = start
    stack = deque([start])
    self.parent[start] = -1
    self.order[start] = 0
    cnt = 1
    while stack:
      v = stack[-1]
      for u in self.edge[v]:
        if u==self.parent[v]:
          pass
        elif self.order[u]<self.order[v]: #後退辺の処理
          self.low[v] = min(self.low[v], self.order[u])
        elif self.parent[u]==N: #行きがけ
          self.order[u] = self.low[u] = cnt
          self.parent[u] = v
          stack.append(u)
          cnt += 1
          break
        else: #帰りがけ
          self.low[v] = min(self.low[v], self.low[u])
      else:
        stack.pop() #帰り
    return
  
  def bridge(self):
    res = []
    for a,b in self.edges:
      if G.order[a]>G.order[b]:
        a,b = b,a
      if G.low[b]<=G.order[a]:
        res.append(self.dic[(a,b)])
    return res
  
  def articulation(self):
    res = []
    for v in range(self.V):
      cnt = 0
      for u in self.edge[v]:
        if self.parent[v]==u or self.parent[u]!=v:
          continue
        if self.order[v]<=self.low[u]:
          cnt += 1
      if v==self.start:
        if cnt>=2:
          res.append(v)
      elif cnt>=1:
          res.append(v)
    return res


N = int(input())
G = LowLink(N, N)
G.add_edges(1)
G.low_link(0)
ans = G.bridge()
print(len(ans))
print(*ans)
0