結果

問題 No.1576 織姫と彦星
ユーザー ああいいああいい
提出日時 2021-12-23 19:13:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 622 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 10,244 KB
最終ジャッジ日時 2023-10-17 20:31:40
合計ジャッジ時間 32,408 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,016 KB
testcase_01 AC 30 ms
10,016 KB
testcase_02 AC 29 ms
10,016 KB
testcase_03 AC 29 ms
10,016 KB
testcase_04 AC 30 ms
10,016 KB
testcase_05 AC 29 ms
10,016 KB
testcase_06 AC 30 ms
10,016 KB
testcase_07 AC 299 ms
10,080 KB
testcase_08 AC 125 ms
10,064 KB
testcase_09 AC 37 ms
10,036 KB
testcase_10 AC 1,228 ms
10,128 KB
testcase_11 AC 36 ms
10,036 KB
testcase_12 AC 680 ms
10,104 KB
testcase_13 AC 751 ms
10,140 KB
testcase_14 AC 1,060 ms
10,120 KB
testcase_15 AC 959 ms
10,120 KB
testcase_16 AC 521 ms
10,132 KB
testcase_17 AC 823 ms
10,116 KB
testcase_18 AC 162 ms
10,056 KB
testcase_19 AC 353 ms
10,064 KB
testcase_20 AC 52 ms
10,116 KB
testcase_21 AC 886 ms
10,116 KB
testcase_22 AC 221 ms
10,128 KB
testcase_23 AC 64 ms
10,048 KB
testcase_24 AC 124 ms
10,048 KB
testcase_25 AC 801 ms
10,132 KB
testcase_26 AC 462 ms
10,072 KB
testcase_27 AC 40 ms
10,036 KB
testcase_28 AC 752 ms
10,128 KB
testcase_29 AC 455 ms
10,076 KB
testcase_30 AC 32 ms
10,032 KB
testcase_31 AC 448 ms
10,080 KB
testcase_32 AC 789 ms
10,112 KB
testcase_33 TLE -
testcase_34 AC 36 ms
10,036 KB
testcase_35 AC 594 ms
10,092 KB
testcase_36 AC 122 ms
10,048 KB
testcase_37 TLE -
testcase_38 AC 1,021 ms
10,128 KB
testcase_39 AC 699 ms
10,104 KB
testcase_40 AC 484 ms
10,084 KB
testcase_41 AC 591 ms
10,092 KB
testcase_42 AC 56 ms
10,036 KB
testcase_43 AC 167 ms
10,056 KB
testcase_44 TLE -
testcase_45 AC 356 ms
10,080 KB
testcase_46 AC 1,297 ms
10,124 KB
testcase_47 AC 53 ms
10,056 KB
testcase_48 AC 738 ms
10,100 KB
testcase_49 AC 670 ms
10,100 KB
testcase_50 AC 46 ms
10,036 KB
testcase_51 AC 59 ms
10,048 KB
testcase_52 AC 177 ms
10,148 KB
testcase_53 AC 1,172 ms
10,120 KB
testcase_54 AC 920 ms
10,132 KB
testcase_55 AC 968 ms
10,148 KB
testcase_56 AC 1,057 ms
10,148 KB
testcase_57 AC 36 ms
10,032 KB
testcase_58 AC 277 ms
10,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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
memo = [C] * (N + 2)
memo[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]-1)
0