結果
問題 | No.1577 織姫と彦星2 |
ユーザー |
👑 |
提出日時 | 2022-03-23 14:53:01 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 411 bytes |
コンパイル時間 | 1,584 ms |
コンパイル使用メモリ | 82,068 KB |
実行使用メモリ | 92,032 KB |
最終ジャッジ日時 | 2024-10-11 13:08:13 |
合計ジャッジ時間 | 8,128 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 19 WA * 34 |
ソースコード
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.pop() 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)