結果
| 問題 |
No.1647 Travel in Mitaru city 2
|
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2023-12-11 12:36:01 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,120 bytes |
| コンパイル時間 | 544 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 105,756 KB |
| 最終ジャッジ日時 | 2024-09-27 04:27:53 |
| 合計ジャッジ時間 | 42,731 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 17 |
ソースコード
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import *
H, W, N = map(int, input().split())
G = [[] for i in range(H + W)]
D = dict()
for i in range(N):
x, y = map(int, input().split())
x, y = x - 1, y - 1
if i == 0:
s, g = x, y + H
G[x].append(y + H)
G[y + H].append(x)
D[(x, y+H)] = i + 1
D[(y+H, x)] = i + 1
seen = [0] * (H + W)
seen2 = [0] * (H + W)
temp = []
def dfs(s, p):
for u in G[s]:
if u == p:
continue
if seen[u]:
if seen2[u] == 0:
ans = []
now = u
while temp:
ans.append(D[(now, temp[-1])])
now = temp.pop()
ans.reverse()
print(len(ans))
print(*ans)
exit()
continue
seen[u] = 1
seen2[u] = 1
temp.append(u)
dfs(u, s)
seen2[u] = 0
temp.pop()
return
for i in range(H):
if seen[i]:
continue
temp = [i]
seen[i] = 1
dfs(i, -1)
print(-1)
rlangevin