結果

問題 No.1254 補強への架け橋
ユーザー marroncastlemarroncastle
提出日時 2020-10-10 07:33:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 380 ms / 2,000 ms
コード長 2,040 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 129,408 KB
最終ジャッジ日時 2024-07-20 15:37:42
合計ジャッジ時間 22,367 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
54,144 KB
testcase_01 AC 42 ms
53,888 KB
testcase_02 AC 42 ms
53,888 KB
testcase_03 AC 41 ms
54,144 KB
testcase_04 AC 41 ms
53,888 KB
testcase_05 AC 41 ms
54,144 KB
testcase_06 AC 43 ms
53,888 KB
testcase_07 AC 44 ms
54,016 KB
testcase_08 AC 41 ms
54,400 KB
testcase_09 AC 41 ms
54,144 KB
testcase_10 AC 42 ms
53,888 KB
testcase_11 AC 43 ms
53,888 KB
testcase_12 AC 42 ms
54,272 KB
testcase_13 AC 41 ms
54,144 KB
testcase_14 AC 41 ms
54,528 KB
testcase_15 AC 43 ms
54,016 KB
testcase_16 AC 44 ms
54,272 KB
testcase_17 AC 42 ms
54,272 KB
testcase_18 AC 40 ms
54,144 KB
testcase_19 AC 46 ms
53,760 KB
testcase_20 AC 47 ms
54,528 KB
testcase_21 AC 41 ms
54,144 KB
testcase_22 AC 41 ms
54,272 KB
testcase_23 AC 41 ms
54,272 KB
testcase_24 AC 42 ms
54,144 KB
testcase_25 AC 41 ms
54,400 KB
testcase_26 AC 43 ms
54,144 KB
testcase_27 AC 41 ms
54,016 KB
testcase_28 AC 41 ms
54,272 KB
testcase_29 AC 41 ms
54,016 KB
testcase_30 AC 40 ms
54,144 KB
testcase_31 AC 45 ms
54,528 KB
testcase_32 AC 40 ms
54,144 KB
testcase_33 AC 41 ms
54,400 KB
testcase_34 AC 41 ms
54,656 KB
testcase_35 AC 42 ms
54,272 KB
testcase_36 AC 41 ms
54,016 KB
testcase_37 AC 41 ms
54,016 KB
testcase_38 AC 42 ms
54,272 KB
testcase_39 AC 45 ms
54,016 KB
testcase_40 AC 40 ms
54,272 KB
testcase_41 AC 45 ms
53,888 KB
testcase_42 AC 42 ms
53,888 KB
testcase_43 AC 58 ms
65,280 KB
testcase_44 AC 48 ms
61,184 KB
testcase_45 AC 49 ms
61,696 KB
testcase_46 AC 59 ms
65,024 KB
testcase_47 AC 52 ms
61,568 KB
testcase_48 AC 56 ms
64,000 KB
testcase_49 AC 42 ms
54,528 KB
testcase_50 AC 58 ms
65,792 KB
testcase_51 AC 62 ms
66,432 KB
testcase_52 AC 63 ms
66,688 KB
testcase_53 AC 59 ms
64,896 KB
testcase_54 AC 61 ms
66,944 KB
testcase_55 AC 58 ms
65,280 KB
testcase_56 AC 42 ms
54,400 KB
testcase_57 AC 56 ms
63,616 KB
testcase_58 AC 57 ms
63,616 KB
testcase_59 AC 41 ms
54,272 KB
testcase_60 AC 48 ms
60,672 KB
testcase_61 AC 59 ms
65,408 KB
testcase_62 AC 43 ms
54,656 KB
testcase_63 AC 99 ms
81,152 KB
testcase_64 AC 87 ms
77,696 KB
testcase_65 AC 99 ms
80,384 KB
testcase_66 AC 97 ms
79,488 KB
testcase_67 AC 77 ms
75,008 KB
testcase_68 AC 96 ms
79,744 KB
testcase_69 AC 96 ms
80,384 KB
testcase_70 AC 88 ms
78,336 KB
testcase_71 AC 93 ms
77,440 KB
testcase_72 AC 99 ms
81,152 KB
testcase_73 AC 89 ms
77,824 KB
testcase_74 AC 103 ms
80,768 KB
testcase_75 AC 103 ms
79,232 KB
testcase_76 AC 78 ms
70,272 KB
testcase_77 AC 107 ms
78,720 KB
testcase_78 AC 114 ms
81,152 KB
testcase_79 AC 113 ms
81,024 KB
testcase_80 AC 100 ms
80,640 KB
testcase_81 AC 100 ms
81,024 KB
testcase_82 AC 106 ms
80,256 KB
testcase_83 AC 291 ms
119,488 KB
testcase_84 AC 276 ms
117,236 KB
testcase_85 AC 203 ms
106,528 KB
testcase_86 AC 286 ms
116,436 KB
testcase_87 AC 319 ms
116,868 KB
testcase_88 AC 117 ms
83,200 KB
testcase_89 AC 309 ms
119,756 KB
testcase_90 AC 229 ms
106,476 KB
testcase_91 AC 194 ms
105,676 KB
testcase_92 AC 124 ms
90,496 KB
testcase_93 AC 275 ms
114,788 KB
testcase_94 AC 256 ms
109,456 KB
testcase_95 AC 237 ms
109,440 KB
testcase_96 AC 271 ms
117,040 KB
testcase_97 AC 169 ms
104,296 KB
testcase_98 AC 310 ms
117,720 KB
testcase_99 AC 190 ms
105,988 KB
testcase_100 AC 291 ms
120,384 KB
testcase_101 AC 125 ms
89,168 KB
testcase_102 AC 110 ms
82,176 KB
testcase_103 AC 117 ms
89,232 KB
testcase_104 AC 149 ms
98,384 KB
testcase_105 AC 246 ms
115,440 KB
testcase_106 AC 170 ms
105,404 KB
testcase_107 AC 296 ms
119,420 KB
testcase_108 AC 294 ms
117,460 KB
testcase_109 AC 239 ms
114,860 KB
testcase_110 AC 223 ms
109,252 KB
testcase_111 AC 236 ms
110,560 KB
testcase_112 AC 151 ms
98,092 KB
testcase_113 AC 217 ms
108,800 KB
testcase_114 AC 168 ms
105,392 KB
testcase_115 AC 108 ms
83,584 KB
testcase_116 AC 174 ms
105,856 KB
testcase_117 AC 143 ms
98,364 KB
testcase_118 AC 280 ms
117,368 KB
testcase_119 AC 188 ms
106,012 KB
testcase_120 AC 256 ms
116,600 KB
testcase_121 AC 122 ms
90,624 KB
testcase_122 AC 181 ms
105,860 KB
testcase_123 AC 41 ms
54,528 KB
testcase_124 AC 366 ms
129,408 KB
testcase_125 AC 380 ms
128,900 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