結果
| 問題 |
No.1576 織姫と彦星
|
| ユーザー |
|
| 提出日時 | 2021-07-13 00:40:54 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 805 bytes |
| コンパイル時間 | 315 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 67,044 KB |
| 最終ジャッジ日時 | 2024-07-02 03:50:54 |
| 合計ジャッジ時間 | 16,064 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 TLE * 1 |
| other | AC * 2 TLE * 1 -- * 51 |
ソースコード
from collections import deque
from scipy.spatial import distance
def nishin(x):
x = format(x, '030b')
x = list(map(int,str(x)))
return x
n = int(input())
start, end = map(int,input().split())
start = nishin(start)
end = nishin(end)
stone = list(map(int,input().split()))
stone.sort()
stone = list(map(nishin,stone))
queue = deque()
queue.append(start)
if distance.hamming(start, end) * 30 <= 1:
print(0)
exit()
cnt = 1
vv = stone[0]
while queue:
v = queue.popleft()
for i in stone:
if distance.hamming(v, i) * 30 <= 1:
if distance.hamming(i, end) * 30 <= 1:
print(cnt)
exit()
queue.append(i)
if int(''.join(map(str, v))) <= int(''.join(map(str, vv))):
cnt += 1
vv = v
print(-1)