結果
| 問題 | No.1647 Travel in Mitaru city 2 |
| コンテスト | |
| ユーザー |
回転
|
| 提出日時 | 2026-01-13 20:56:28 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 919 bytes |
| 記録 | |
| コンパイル時間 | 348 ms |
| コンパイル使用メモリ | 82,220 KB |
| 実行使用メモリ | 110,312 KB |
| 最終ジャッジ日時 | 2026-01-13 20:57:04 |
| 合計ジャッジ時間 | 31,960 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 11 RE * 33 J_TLE * 1 |
ソースコード
from collections import defaultdict
H,W,N = list(map(int,input().split()))
city = []
x_is = defaultdict(list)
y_is = defaultdict(list)
sy,sx = -1,-1
for i in range(N):
y,x = list(map(int,input().split()))
y -= 1;x -= 1
city.append((y,x))
y_is[y].append((x,i))
x_is[x].append((y,i))
if(sy == sx == -1):
sy = y
sx = x
visited = set()
ans = []
def dfs(n,odd):
if(n == 0 and visited):
print(len(ans))
print(*ans)
exit()
if(visited or n != 0):visited.add((n,odd))
ans.append(n+1)
y,x = city[n]
if(odd):
for y,idx in x_is[x]:
if((idx,not odd) in visited):continue
if(n == idx):continue
dfs(idx,not odd)
else:
for x,idx in y_is[y]:
if((idx, not odd) in visited):continue
if(n == idx):continue
dfs(idx,not odd)
ans.pop()
dfs(0,True)
print(-1)
回転