結果
| 問題 | No.1577 織姫と彦星2 |
| ユーザー |
👑 |
| 提出日時 | 2022-03-23 14:55:32 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 104 ms / 2,000 ms |
| + 242µs | |
| コード長 | 415 bytes |
| 記録 | |
| コンパイル時間 | 70 ms |
| コンパイル使用メモリ | 80,896 KB |
| 実行使用メモリ | 94,336 KB |
| 最終ジャッジ日時 | 2026-09-14 00:16:53 |
| 合計ジャッジ時間 | 6,798 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 53 |
ソースコード
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)