結果

問題 No.1577 織姫と彦星2
ユーザー 👑 rin204rin204
提出日時 2022-03-23 14:55:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 177 ms / 2,000 ms
コード長 415 bytes
コンパイル時間 490 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 92,032 KB
最終ジャッジ日時 2024-04-19 20:53:04
合計ジャッジ時間 8,428 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
53,376 KB
testcase_01 AC 49 ms
53,248 KB
testcase_02 AC 52 ms
53,376 KB
testcase_03 AC 48 ms
53,248 KB
testcase_04 AC 47 ms
53,248 KB
testcase_05 AC 53 ms
63,232 KB
testcase_06 AC 53 ms
60,032 KB
testcase_07 AC 151 ms
84,096 KB
testcase_08 AC 96 ms
71,808 KB
testcase_09 AC 177 ms
92,032 KB
testcase_10 AC 72 ms
68,608 KB
testcase_11 AC 59 ms
63,104 KB
testcase_12 AC 101 ms
76,032 KB
testcase_13 AC 66 ms
67,200 KB
testcase_14 AC 110 ms
78,464 KB
testcase_15 AC 79 ms
69,632 KB
testcase_16 AC 134 ms
83,072 KB
testcase_17 AC 91 ms
73,728 KB
testcase_18 AC 49 ms
59,264 KB
testcase_19 AC 127 ms
81,024 KB
testcase_20 AC 118 ms
78,208 KB
testcase_21 AC 134 ms
82,944 KB
testcase_22 AC 124 ms
82,304 KB
testcase_23 AC 82 ms
71,040 KB
testcase_24 AC 125 ms
85,632 KB
testcase_25 AC 77 ms
67,200 KB
testcase_26 AC 91 ms
71,680 KB
testcase_27 AC 84 ms
76,672 KB
testcase_28 AC 111 ms
77,440 KB
testcase_29 AC 80 ms
71,168 KB
testcase_30 AC 88 ms
73,472 KB
testcase_31 AC 122 ms
81,536 KB
testcase_32 AC 60 ms
63,104 KB
testcase_33 AC 59 ms
62,208 KB
testcase_34 AC 82 ms
71,808 KB
testcase_35 AC 120 ms
80,896 KB
testcase_36 AC 124 ms
81,920 KB
testcase_37 AC 168 ms
91,136 KB
testcase_38 AC 157 ms
89,600 KB
testcase_39 AC 96 ms
72,448 KB
testcase_40 AC 85 ms
71,424 KB
testcase_41 AC 122 ms
82,816 KB
testcase_42 AC 75 ms
72,960 KB
testcase_43 AC 78 ms
72,832 KB
testcase_44 AC 63 ms
62,848 KB
testcase_45 AC 75 ms
66,816 KB
testcase_46 AC 69 ms
65,920 KB
testcase_47 AC 78 ms
77,568 KB
testcase_48 AC 71 ms
68,608 KB
testcase_49 AC 93 ms
74,112 KB
testcase_50 AC 80 ms
69,248 KB
testcase_51 AC 58 ms
62,208 KB
testcase_52 AC 125 ms
85,376 KB
testcase_53 AC 128 ms
86,400 KB
testcase_54 AC 74 ms
71,296 KB
testcase_55 AC 116 ms
84,352 KB
testcase_56 AC 82 ms
69,760 KB
testcase_57 AC 59 ms
65,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

n = int(input())
s, e = map(int, input().split())
stone = set(map(int, input().split()))
stone.add(e)
dist = {s:0}
queue = deque()
queue.append(s)
while queue:
    pos = queue.popleft()
    for i in range(30):
        npos = pos ^ (1 << i)
        if npos not in dist and npos in stone:
            dist[npos] = dist[pos] + 1
            queue.append(npos)

print(dist.get(e, 0) - 1)
0