結果
| 問題 | No.1577 織姫と彦星2 |
| ユーザー |
|
| 提出日時 | 2021-06-19 00:42:03 |
| 言語 | Python3 (3.14.3 + numpy 2.4.2 + scipy 1.17.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 792 bytes |
| 記録 | |
| コンパイル時間 | 1,708 ms |
| コンパイル使用メモリ | 20,828 KB |
| 実行使用メモリ | 35,676 KB |
| 最終ジャッジ日時 | 2026-03-07 05:14:46 |
| 合計ジャッジ時間 | 143,445 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 8 TLE * 45 |
ソースコード
import queue
def get_hd(a,b):
return bin(a^b).count('1')
def solve_slower(start, end, stones):
checked_set = set()
que = queue.Queue()
que.put((start, 0))
while not que.empty():
current, distance = que.get()
next_distance = distance + 1
if get_hd(current, end) == 1:
return next_distance - 1
for candidate in stones:
if candidate in checked_set:
continue
if get_hd(current, candidate) == 1:
checked_set.add(candidate)
que.put((candidate, next_distance))
return -1
if __name__ == '__main__':
N = int(input())
start, end = list(map(int, input().split()))
stones = list(map(int, input().split()))
print(solve_slower(start, end, stones))