結果
| 問題 |
No.1576 織姫と彦星
|
| ユーザー |
sugar_sentan
|
| 提出日時 | 2021-06-20 16:24:04 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 557 bytes |
| コンパイル時間 | 178 ms |
| コンパイル使用メモリ | 82,560 KB |
| 実行使用メモリ | 84,608 KB |
| 最終ジャッジ日時 | 2024-06-22 22:28:49 |
| 合計ジャッジ時間 | 4,021 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 2 TLE * 1 -- * 51 |
ソースコード
def checkhamming(n, m):
return bin(n ^ m).count('1')
N = int(input())
start, end = map(int, input().split())
stones = list(map(int, input().split()))
stones.append(end)
q = [[start, 0]]
while len(q):
# print(q)
now, count = q.pop(0)
if count > len(stones)+1:
break
# print(now, count)
for stone in stones:
if checkhamming(now, stone) <= 1 and now != stone:
if stone == end:
print(count)
exit()
else:
q.append([stone, count+1])
print(-1)
sugar_sentan