結果

問題 No.1254 補強への架け橋
ユーザー marroncastlemarroncastle
提出日時 2020-11-26 03:28:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 366 ms / 2,000 ms
コード長 2,082 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 108,564 KB
最終ジャッジ日時 2023-10-01 03:12:12
合計ジャッジ時間 29,060 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,548 KB
testcase_01 AC 93 ms
71,200 KB
testcase_02 AC 94 ms
71,688 KB
testcase_03 AC 94 ms
71,568 KB
testcase_04 AC 94 ms
71,584 KB
testcase_05 AC 96 ms
71,568 KB
testcase_06 AC 93 ms
71,684 KB
testcase_07 AC 94 ms
71,344 KB
testcase_08 AC 93 ms
71,732 KB
testcase_09 AC 91 ms
71,428 KB
testcase_10 AC 91 ms
71,688 KB
testcase_11 AC 93 ms
71,728 KB
testcase_12 AC 92 ms
71,436 KB
testcase_13 AC 93 ms
71,572 KB
testcase_14 AC 96 ms
71,528 KB
testcase_15 AC 95 ms
71,612 KB
testcase_16 AC 94 ms
71,564 KB
testcase_17 AC 94 ms
71,608 KB
testcase_18 AC 94 ms
71,184 KB
testcase_19 AC 94 ms
71,424 KB
testcase_20 AC 92 ms
71,688 KB
testcase_21 AC 98 ms
71,524 KB
testcase_22 AC 94 ms
71,732 KB
testcase_23 AC 93 ms
71,688 KB
testcase_24 AC 95 ms
71,788 KB
testcase_25 AC 94 ms
71,612 KB
testcase_26 AC 93 ms
71,688 KB
testcase_27 AC 95 ms
71,200 KB
testcase_28 AC 95 ms
71,604 KB
testcase_29 AC 92 ms
71,572 KB
testcase_30 AC 92 ms
71,468 KB
testcase_31 AC 97 ms
71,568 KB
testcase_32 AC 91 ms
71,464 KB
testcase_33 AC 93 ms
71,744 KB
testcase_34 AC 95 ms
71,492 KB
testcase_35 AC 98 ms
71,148 KB
testcase_36 AC 93 ms
71,684 KB
testcase_37 AC 94 ms
71,460 KB
testcase_38 AC 97 ms
71,620 KB
testcase_39 AC 96 ms
71,584 KB
testcase_40 AC 92 ms
71,536 KB
testcase_41 AC 94 ms
71,728 KB
testcase_42 AC 91 ms
71,768 KB
testcase_43 AC 109 ms
76,796 KB
testcase_44 AC 104 ms
76,500 KB
testcase_45 AC 102 ms
77,236 KB
testcase_46 AC 111 ms
77,064 KB
testcase_47 AC 104 ms
76,296 KB
testcase_48 AC 108 ms
76,928 KB
testcase_49 AC 94 ms
71,536 KB
testcase_50 AC 111 ms
76,700 KB
testcase_51 AC 110 ms
76,764 KB
testcase_52 AC 113 ms
77,024 KB
testcase_53 AC 111 ms
77,176 KB
testcase_54 AC 112 ms
77,004 KB
testcase_55 AC 116 ms
76,988 KB
testcase_56 AC 92 ms
71,432 KB
testcase_57 AC 105 ms
77,196 KB
testcase_58 AC 107 ms
76,944 KB
testcase_59 AC 98 ms
71,748 KB
testcase_60 AC 101 ms
76,596 KB
testcase_61 AC 108 ms
77,152 KB
testcase_62 AC 91 ms
71,552 KB
testcase_63 AC 135 ms
78,404 KB
testcase_64 AC 125 ms
78,068 KB
testcase_65 AC 137 ms
78,492 KB
testcase_66 AC 132 ms
78,544 KB
testcase_67 AC 124 ms
77,628 KB
testcase_68 AC 139 ms
78,612 KB
testcase_69 AC 134 ms
78,360 KB
testcase_70 AC 128 ms
78,456 KB
testcase_71 AC 124 ms
77,536 KB
testcase_72 AC 133 ms
78,480 KB
testcase_73 AC 130 ms
78,096 KB
testcase_74 AC 134 ms
78,376 KB
testcase_75 AC 130 ms
77,932 KB
testcase_76 AC 123 ms
77,892 KB
testcase_77 AC 134 ms
78,632 KB
testcase_78 AC 143 ms
79,736 KB
testcase_79 AC 139 ms
78,424 KB
testcase_80 AC 139 ms
78,444 KB
testcase_81 AC 139 ms
78,668 KB
testcase_82 AC 147 ms
79,908 KB
testcase_83 AC 290 ms
95,480 KB
testcase_84 AC 276 ms
94,768 KB
testcase_85 AC 216 ms
88,648 KB
testcase_86 AC 267 ms
93,088 KB
testcase_87 AC 266 ms
94,172 KB
testcase_88 AC 143 ms
80,804 KB
testcase_89 AC 283 ms
95,660 KB
testcase_90 AC 226 ms
89,396 KB
testcase_91 AC 197 ms
87,160 KB
testcase_92 AC 157 ms
82,884 KB
testcase_93 AC 252 ms
92,148 KB
testcase_94 AC 235 ms
90,828 KB
testcase_95 AC 239 ms
91,008 KB
testcase_96 AC 283 ms
94,700 KB
testcase_97 AC 184 ms
84,916 KB
testcase_98 AC 274 ms
94,896 KB
testcase_99 AC 208 ms
88,344 KB
testcase_100 AC 287 ms
95,868 KB
testcase_101 AC 165 ms
82,280 KB
testcase_102 AC 145 ms
80,264 KB
testcase_103 AC 161 ms
82,924 KB
testcase_104 AC 179 ms
84,104 KB
testcase_105 AC 263 ms
92,072 KB
testcase_106 AC 199 ms
86,368 KB
testcase_107 AC 288 ms
95,772 KB
testcase_108 AC 292 ms
95,300 KB
testcase_109 AC 255 ms
91,808 KB
testcase_110 AC 240 ms
90,816 KB
testcase_111 AC 253 ms
91,308 KB
testcase_112 AC 172 ms
83,972 KB
testcase_113 AC 236 ms
90,212 KB
testcase_114 AC 204 ms
86,488 KB
testcase_115 AC 151 ms
80,788 KB
testcase_116 AC 206 ms
87,320 KB
testcase_117 AC 177 ms
83,880 KB
testcase_118 AC 281 ms
94,364 KB
testcase_119 AC 211 ms
87,948 KB
testcase_120 AC 268 ms
94,132 KB
testcase_121 AC 166 ms
83,656 KB
testcase_122 AC 213 ms
87,436 KB
testcase_123 AC 92 ms
71,628 KB
testcase_124 AC 366 ms
108,564 KB
testcase_125 AC 362 ms
108,464 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
    order = 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] = order
          self.parent[u] = v
          self.cnts[u] += 1
          stack.append(u)
          order += 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 self.order[a]>self.order[b]:
        a,b = b,a
      if self.low[b]<=self.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