結果

問題 No.1254 補強への架け橋
ユーザー marroncastlemarroncastle
提出日時 2020-11-26 02:56:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 2,064 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 108,580 KB
最終ジャッジ日時 2023-10-01 03:11:16
合計ジャッジ時間 29,683 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
71,764 KB
testcase_01 AC 88 ms
71,600 KB
testcase_02 AC 92 ms
71,456 KB
testcase_03 AC 89 ms
71,564 KB
testcase_04 AC 87 ms
71,712 KB
testcase_05 AC 87 ms
71,748 KB
testcase_06 AC 89 ms
71,724 KB
testcase_07 AC 88 ms
71,824 KB
testcase_08 AC 90 ms
71,688 KB
testcase_09 AC 92 ms
71,788 KB
testcase_10 AC 94 ms
71,596 KB
testcase_11 AC 91 ms
71,652 KB
testcase_12 AC 88 ms
71,664 KB
testcase_13 AC 88 ms
71,888 KB
testcase_14 AC 91 ms
71,540 KB
testcase_15 AC 90 ms
71,780 KB
testcase_16 AC 91 ms
71,660 KB
testcase_17 AC 89 ms
71,544 KB
testcase_18 AC 93 ms
71,660 KB
testcase_19 AC 89 ms
71,628 KB
testcase_20 AC 89 ms
71,780 KB
testcase_21 AC 90 ms
71,780 KB
testcase_22 AC 89 ms
71,712 KB
testcase_23 AC 91 ms
71,632 KB
testcase_24 AC 89 ms
71,392 KB
testcase_25 AC 88 ms
71,632 KB
testcase_26 AC 87 ms
71,852 KB
testcase_27 AC 89 ms
71,860 KB
testcase_28 AC 89 ms
71,716 KB
testcase_29 AC 89 ms
71,860 KB
testcase_30 AC 90 ms
71,648 KB
testcase_31 AC 89 ms
71,388 KB
testcase_32 AC 91 ms
71,756 KB
testcase_33 AC 88 ms
71,648 KB
testcase_34 AC 94 ms
71,548 KB
testcase_35 AC 89 ms
71,684 KB
testcase_36 AC 87 ms
71,756 KB
testcase_37 AC 89 ms
71,396 KB
testcase_38 AC 90 ms
71,500 KB
testcase_39 AC 91 ms
71,608 KB
testcase_40 AC 90 ms
71,756 KB
testcase_41 AC 90 ms
71,720 KB
testcase_42 AC 90 ms
71,552 KB
testcase_43 AC 103 ms
77,432 KB
testcase_44 AC 98 ms
76,816 KB
testcase_45 AC 98 ms
77,132 KB
testcase_46 AC 105 ms
77,040 KB
testcase_47 AC 99 ms
76,480 KB
testcase_48 AC 104 ms
77,224 KB
testcase_49 AC 93 ms
71,624 KB
testcase_50 AC 109 ms
77,348 KB
testcase_51 AC 107 ms
77,236 KB
testcase_52 AC 109 ms
77,168 KB
testcase_53 AC 106 ms
77,088 KB
testcase_54 AC 107 ms
77,096 KB
testcase_55 AC 106 ms
77,352 KB
testcase_56 AC 91 ms
71,728 KB
testcase_57 AC 101 ms
77,068 KB
testcase_58 AC 104 ms
76,900 KB
testcase_59 AC 93 ms
71,712 KB
testcase_60 AC 99 ms
76,352 KB
testcase_61 AC 107 ms
77,060 KB
testcase_62 AC 93 ms
71,692 KB
testcase_63 AC 135 ms
78,312 KB
testcase_64 AC 125 ms
78,080 KB
testcase_65 AC 130 ms
78,520 KB
testcase_66 AC 128 ms
78,600 KB
testcase_67 AC 117 ms
78,164 KB
testcase_68 AC 127 ms
78,528 KB
testcase_69 AC 128 ms
78,472 KB
testcase_70 AC 123 ms
78,572 KB
testcase_71 AC 118 ms
78,144 KB
testcase_72 AC 126 ms
78,400 KB
testcase_73 AC 123 ms
78,484 KB
testcase_74 AC 128 ms
78,584 KB
testcase_75 AC 123 ms
78,144 KB
testcase_76 AC 113 ms
78,104 KB
testcase_77 AC 124 ms
78,488 KB
testcase_78 AC 136 ms
79,852 KB
testcase_79 AC 126 ms
78,712 KB
testcase_80 AC 129 ms
78,656 KB
testcase_81 AC 129 ms
78,592 KB
testcase_82 AC 140 ms
80,048 KB
testcase_83 AC 280 ms
95,524 KB
testcase_84 AC 270 ms
95,252 KB
testcase_85 AC 206 ms
88,952 KB
testcase_86 AC 253 ms
93,100 KB
testcase_87 AC 260 ms
94,464 KB
testcase_88 AC 133 ms
80,940 KB
testcase_89 AC 279 ms
95,532 KB
testcase_90 AC 217 ms
89,468 KB
testcase_91 AC 201 ms
87,412 KB
testcase_92 AC 159 ms
83,012 KB
testcase_93 AC 245 ms
92,060 KB
testcase_94 AC 226 ms
90,960 KB
testcase_95 AC 229 ms
91,072 KB
testcase_96 AC 270 ms
94,880 KB
testcase_97 AC 173 ms
84,828 KB
testcase_98 AC 257 ms
94,972 KB
testcase_99 AC 201 ms
88,388 KB
testcase_100 AC 270 ms
95,984 KB
testcase_101 AC 156 ms
82,528 KB
testcase_102 AC 139 ms
80,380 KB
testcase_103 AC 153 ms
82,820 KB
testcase_104 AC 165 ms
84,252 KB
testcase_105 AC 249 ms
92,248 KB
testcase_106 AC 189 ms
86,528 KB
testcase_107 AC 275 ms
95,644 KB
testcase_108 AC 272 ms
95,608 KB
testcase_109 AC 240 ms
92,040 KB
testcase_110 AC 229 ms
91,112 KB
testcase_111 AC 235 ms
91,592 KB
testcase_112 AC 163 ms
84,016 KB
testcase_113 AC 221 ms
90,460 KB
testcase_114 AC 196 ms
86,428 KB
testcase_115 AC 141 ms
80,740 KB
testcase_116 AC 200 ms
87,424 KB
testcase_117 AC 168 ms
84,188 KB
testcase_118 AC 271 ms
94,652 KB
testcase_119 AC 208 ms
88,292 KB
testcase_120 AC 259 ms
94,260 KB
testcase_121 AC 163 ms
83,536 KB
testcase_122 AC 206 ms
87,288 KB
testcase_123 AC 92 ms
71,716 KB
testcase_124 AC 357 ms
108,512 KB
testcase_125 AC 348 ms
108,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
  
  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)

  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
    self.cnts = [0]*self.V
    cnt = 1
    while stack:
      v = stack[-1]
      for u in self.edge[v]:
        if u==self.parent[v]:
          continue
        if self.order[u]<self.order[v]: #後退辺の処理
          self.low[v] = min(self.low[v], self.order[u])
        elif self.cnts[u]==0: #行きがけ
          self.order[u] = self.low[u] = cnt
          self.parent[u] = v
          self.cnts[u] += 1
          stack.append(u)
          cnt += 1
          break
        elif self.cnts[u]==1: #帰りがけ
          self.low[v] = min(self.low[v], self.low[u])
          self.cnts[u] += 1
      else:
        stack.pop() #帰り
    return
  
  def bridge(self):
    res = []
    for i,(a,b) in enumerate(self.edges):
      if G.order[a]>G.order[b]:
        a,b = b,a
      if G.low[b]<=G.order[a]:
        res.append(i+1)
    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