結果

問題 No.1647 Travel in Mitaru city 2
ユーザー ProgrammerryokiProgrammerryoki
提出日時 2021-08-13 22:24:41
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 1,285 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 100,296 KB
最終ジャッジ日時 2023-07-27 05:18:50
合計ジャッジ時間 6,276 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,432 KB
testcase_01 AC 72 ms
71,436 KB
testcase_02 AC 73 ms
71,352 KB
testcase_03 AC 86 ms
76,896 KB
testcase_04 AC 116 ms
77,156 KB
testcase_05 AC 81 ms
76,180 KB
testcase_06 AC 86 ms
76,900 KB
testcase_07 AC 148 ms
77,296 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin, setrecursionlimit
setrecursionlimit(10**6)

input = stdin.readline
H,W,N = [int(i) for i in input().split()]
odd = {}
even = {}
points = []
for ind in range(N):
    x,y = [int(i) for i in input().split()]
    points.append((x,y))
    if x not in even:
        even[x] = set()
    if y not in odd:
        odd[y] = set()
    for i,j in points:
        if i == x:
            even[i].add(ind+1)
            even[x].add(ind+1)
        if j == y:
            odd[j].add(ind+1)
            odd[y].add(ind+1)

# print(odd)
# print(even)

order = []
seen = set()
start = 0
def dfs(x,y):
    global order, seen
    rodd = len(order)&1
    graph = odd if rodd else even
    nxt = y if rodd else x
    # print(x,y,rodd,order,seen)
    for n in graph[nxt]:
        if n not in seen:
            seen.add(n)
            order.append(n)
            i,j = points[n-1]
            dfs(i,j)
            order.pop()
            seen.remove(n)
        else:
            if n == start and len(order) >= 4:
                # print(order)
                raise ConnectionError


try:
    start = 1
    order.append(1)
    seen.add(1)
    dfs(points[0][0], points[0][1])
    print(-1)
except ConnectionError:
    print(len(order))
    print(" ".join(str(i) for i in order))
    exit()
0