結果
| 問題 |
No.1254 補強への架け橋
|
| コンテスト | |
| ユーザー |
proribone
|
| 提出日時 | 2020-10-10 14:55:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 867 bytes |
| コンパイル時間 | 225 ms |
| コンパイル使用メモリ | 82,560 KB |
| 実行使用メモリ | 205,056 KB |
| 最終ジャッジ日時 | 2024-07-20 15:58:51 |
| 合計ジャッジ時間 | 20,608 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 123 |
ソースコード
import sys
sys.setrecursionlimit(10**9)
pos=-1
def dfs(G,v,p):
global pos
seen[v]=True
hist.append(v)
for nv in G[v]:
if nv==p:
continue
if finished[nv]:
continue
if seen[nv] and (not finished[nv]):
pos=nv
return
dfs(G,nv,v)
if pos!=-1:
return
hist.pop()
finished[v]=True
N=int(input())
G=[[] for _ in range(N)]
Edge=[]
for i in range(N):
a,b=map(lambda x:int(x)-1,input().split())
G[a].append(b)
G[b].append(a)
Edge.append((a,b))
seen=[False]*N
finished=[False]*N
hist=[]
dfs(G,0,-1)
print(hist)
cycle=set()
while(hist):
t=hist[-1]
cycle.add(t)
hist.pop()
if t==pos:
break
ans=[]
for i,e in enumerate(Edge):
if e[0] in cycle and e[1] in cycle:
ans.append(i+1)
print(len(ans))
print(*ans)
proribone