結果
| 問題 |
No.1254 補強への架け橋
|
| コンテスト | |
| ユーザー |
ayaoni
|
| 提出日時 | 2020-10-29 23:39:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 831 bytes |
| コンパイル時間 | 407 ms |
| コンパイル使用メモリ | 82,360 KB |
| 実行使用メモリ | 118,896 KB |
| 最終ジャッジ日時 | 2024-07-21 22:46:29 |
| 合計ジャッジ時間 | 19,918 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 121 RE * 2 |
ソースコード
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
N = I()
Graph = [[] for _ in range(N+1)]
dict_edge = {}
for i in range(1,N+1):
a,b = MI()
Graph[a].append(b)
Graph[b].append(a)
dict_edge[(a,b)] = i
dict_edge[(b,a)] = i
flag = [0]*(N+1)
previous = [0]*(N+1)
ANS = []
def dfs(i,par):
flag[i] = 1
for j in Graph[i]:
if j == par:
continue
elif flag[j] == 0:
flag[j] = 1
previous[j] = i
dfs(j,i)
else:
ANS.append(dict_edge[(i,j)])
k = i
while k != j:
ANS.append(dict_edge[k,previous[k]])
k = previous[k]
print(len(ANS))
print(*ANS)
exit()
dfs(1,0)
ayaoni