結果
| 問題 |
No.1576 織姫と彦星
|
| ユーザー |
y05h1k1ng
|
| 提出日時 | 2021-07-01 12:23:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 551 bytes |
| コンパイル時間 | 162 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 76,288 KB |
| 最終ジャッジ日時 | 2024-06-28 01:32:02 |
| 合計ジャッジ時間 | 9,752 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 53 WA * 1 |
ソースコード
from collections import deque
def hamming_distance(a: int, b: int) -> int:
x = a ^ b
return bin(x)[2:].count("1")
n = int(input())
start, end = map(int, input().split(" "))
stones = list(map(int, input().split(" ")))
que = deque([])
que.append((0, start))
while len(que):
cnt, now = que.popleft()
if hamming_distance(now, end) == 1:
print(cnt)
break
for stone in stones:
if hamming_distance(now, stone) == 1:
que.append((cnt+1, stone))
stones.remove(stone)
else:
print(-1)
y05h1k1ng