結果

問題 No.1254 補強への架け橋
ユーザー tanon710tanon710
提出日時 2020-10-10 01:50:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 714 ms / 2,000 ms
コード長 1,280 bytes
コンパイル時間 564 ms
コンパイル使用メモリ 86,796 KB
実行使用メモリ 211,100 KB
最終ジャッジ日時 2023-09-27 20:53:07
合計ジャッジ時間 32,217 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,324 KB
testcase_01 AC 72 ms
71,324 KB
testcase_02 AC 74 ms
71,260 KB
testcase_03 AC 75 ms
71,432 KB
testcase_04 AC 71 ms
71,364 KB
testcase_05 AC 73 ms
71,200 KB
testcase_06 AC 72 ms
71,172 KB
testcase_07 AC 73 ms
71,056 KB
testcase_08 AC 73 ms
71,456 KB
testcase_09 AC 74 ms
71,116 KB
testcase_10 AC 73 ms
71,124 KB
testcase_11 AC 73 ms
71,144 KB
testcase_12 AC 74 ms
71,432 KB
testcase_13 AC 74 ms
71,204 KB
testcase_14 AC 76 ms
71,260 KB
testcase_15 AC 73 ms
71,008 KB
testcase_16 AC 74 ms
71,232 KB
testcase_17 AC 72 ms
71,124 KB
testcase_18 AC 74 ms
70,944 KB
testcase_19 AC 73 ms
71,264 KB
testcase_20 AC 75 ms
71,264 KB
testcase_21 AC 73 ms
71,312 KB
testcase_22 AC 73 ms
71,268 KB
testcase_23 AC 74 ms
71,364 KB
testcase_24 AC 75 ms
71,204 KB
testcase_25 AC 75 ms
71,148 KB
testcase_26 AC 73 ms
71,008 KB
testcase_27 AC 72 ms
71,356 KB
testcase_28 AC 73 ms
71,208 KB
testcase_29 AC 74 ms
71,464 KB
testcase_30 AC 75 ms
71,392 KB
testcase_31 AC 74 ms
71,272 KB
testcase_32 AC 74 ms
71,372 KB
testcase_33 AC 74 ms
71,400 KB
testcase_34 AC 75 ms
71,336 KB
testcase_35 AC 75 ms
71,524 KB
testcase_36 AC 74 ms
71,368 KB
testcase_37 AC 73 ms
71,432 KB
testcase_38 AC 74 ms
71,332 KB
testcase_39 AC 76 ms
71,204 KB
testcase_40 AC 75 ms
71,148 KB
testcase_41 AC 75 ms
71,400 KB
testcase_42 AC 73 ms
71,400 KB
testcase_43 AC 90 ms
75,576 KB
testcase_44 AC 79 ms
71,008 KB
testcase_45 AC 76 ms
71,016 KB
testcase_46 AC 91 ms
75,884 KB
testcase_47 AC 80 ms
71,464 KB
testcase_48 AC 93 ms
76,288 KB
testcase_49 AC 74 ms
71,412 KB
testcase_50 AC 93 ms
75,840 KB
testcase_51 AC 95 ms
76,400 KB
testcase_52 AC 98 ms
76,524 KB
testcase_53 AC 91 ms
76,228 KB
testcase_54 AC 98 ms
76,456 KB
testcase_55 AC 91 ms
75,320 KB
testcase_56 AC 74 ms
71,528 KB
testcase_57 AC 85 ms
75,184 KB
testcase_58 AC 86 ms
74,856 KB
testcase_59 AC 75 ms
71,304 KB
testcase_60 AC 78 ms
71,192 KB
testcase_61 AC 91 ms
75,480 KB
testcase_62 AC 75 ms
71,476 KB
testcase_63 AC 171 ms
82,140 KB
testcase_64 AC 131 ms
78,772 KB
testcase_65 AC 163 ms
81,592 KB
testcase_66 AC 159 ms
80,732 KB
testcase_67 AC 129 ms
79,148 KB
testcase_68 AC 156 ms
80,736 KB
testcase_69 AC 168 ms
81,340 KB
testcase_70 AC 138 ms
79,176 KB
testcase_71 AC 130 ms
78,352 KB
testcase_72 AC 158 ms
82,256 KB
testcase_73 AC 139 ms
78,928 KB
testcase_74 AC 157 ms
80,872 KB
testcase_75 AC 159 ms
81,064 KB
testcase_76 AC 113 ms
78,064 KB
testcase_77 AC 154 ms
81,180 KB
testcase_78 AC 184 ms
82,480 KB
testcase_79 AC 171 ms
82,108 KB
testcase_80 AC 161 ms
81,556 KB
testcase_81 AC 166 ms
81,504 KB
testcase_82 AC 164 ms
81,020 KB
testcase_83 AC 459 ms
124,340 KB
testcase_84 AC 443 ms
120,640 KB
testcase_85 AC 341 ms
106,672 KB
testcase_86 AC 411 ms
114,600 KB
testcase_87 AC 452 ms
120,556 KB
testcase_88 AC 186 ms
84,528 KB
testcase_89 AC 463 ms
124,592 KB
testcase_90 AC 349 ms
107,232 KB
testcase_91 AC 304 ms
102,976 KB
testcase_92 AC 228 ms
89,088 KB
testcase_93 AC 395 ms
113,964 KB
testcase_94 AC 381 ms
110,492 KB
testcase_95 AC 368 ms
111,028 KB
testcase_96 AC 440 ms
120,148 KB
testcase_97 AC 277 ms
97,180 KB
testcase_98 AC 457 ms
120,020 KB
testcase_99 AC 328 ms
103,684 KB
testcase_100 AC 489 ms
125,076 KB
testcase_101 AC 228 ms
87,932 KB
testcase_102 AC 182 ms
82,832 KB
testcase_103 AC 238 ms
90,760 KB
testcase_104 AC 269 ms
93,484 KB
testcase_105 AC 392 ms
113,868 KB
testcase_106 AC 297 ms
99,604 KB
testcase_107 AC 465 ms
124,292 KB
testcase_108 AC 464 ms
123,792 KB
testcase_109 AC 386 ms
113,336 KB
testcase_110 AC 387 ms
110,432 KB
testcase_111 AC 401 ms
111,500 KB
testcase_112 AC 259 ms
93,584 KB
testcase_113 AC 390 ms
110,952 KB
testcase_114 AC 305 ms
100,040 KB
testcase_115 AC 203 ms
84,876 KB
testcase_116 AC 309 ms
101,320 KB
testcase_117 AC 255 ms
92,856 KB
testcase_118 AC 454 ms
119,772 KB
testcase_119 AC 342 ms
103,128 KB
testcase_120 AC 451 ms
119,068 KB
testcase_121 AC 238 ms
90,100 KB
testcase_122 AC 315 ms
102,572 KB
testcase_123 AC 72 ms
71,304 KB
testcase_124 AC 710 ms
205,060 KB
testcase_125 AC 714 ms
211,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)

class LowLink:
  def __init__(self, g):
    self.n=len(g)
    self.used=[0]*n
    self.ords=[0]*n
    self.lows=[0]*n
    self.aps=[]
    self.bridges=[]
    self.k=0
    for i in range(self.n):
      if self.used[i]==0:
        self.k=self.dfs(i,self.k,-1)
  def dfs(self,id,k,par):
    self.used[id]=1
    k+=1
    self.ords[id]=k
    self.lows[id]=self.ords[id]
    is_aps=0
    count=0
    for v in g[id]:
      if self.used[v]==0:
        count+=1
        k=self.dfs(v,k,id)
        self.lows[id]=min(self.lows[id],self.lows[v])
        if par!=-1 and self.ords[id]<=self.lows[v]:
          is_aps=1
        if self.ords[id]<self.lows[v]:
          self.bridges.append((min(id,v),max(id,v)))
      elif v!=par:
        self.lows[id]=min(self.lows[id],self.ords[v])
    if par==-1 and count>=2:
      is_aps=1
    if is_aps==1:
      self.aps.append(id)
    return k

n=int(input())
g=[[] for _ in range(n)]
edges=[]
for i in range(1,n+1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    edges.append([a,b,i])
    g[a].append(b)
    g[b].append(a)
ll=LowLink(g)
prior=set(ll.bridges)
ans=[]
for u,v,i in edges:
    if (u,v) in prior or (v,u) in prior:
        continue
    else:
        ans.append(i)
print(len(ans))
print(*ans)
0