結果
| 問題 |
No.1576 織姫と彦星
|
| ユーザー |
|
| 提出日時 | 2021-12-23 19:11:04 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 619 bytes |
| コンパイル時間 | 150 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-09-17 17:39:51 |
| 合計ジャッジ時間 | 3,749 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 5 |
| other | RE * 54 |
ソースコード
N = int(input())
s,e = map(int,input().split())
l = list(map(int,input().split()))
l.insert(0,s)
l.append(e)
C = 10 ** 5
dist = [C] * (N + 1)
dist[0] = 0
def hamu(a,b):
count = 0
while a != 0 or b != 0:
if a & 1 != b & 1:
count += 1
a >>= 1
b >>= 1
return count < 2
from collections import deque
q = deque()
q.append(0)
while len(q):
now = q.popleft()
for i in range(N+2):
if memo[i] == C:
if hamu(l[i],l[now]):
memo[i] = memo[now] + 1
q.append(i)
if memo[-1] == C:
print(-1)
else:
print(memo[-1])