結果

問題 No.1576 織姫と彦星
ユーザー d1k0b3od1k0b3o
提出日時 2021-07-18 18:31:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,921 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 10,752 KB
実行使用メモリ 8,996 KB
最終ジャッジ日時 2023-09-22 21:15:25
合計ジャッジ時間 11,172 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,588 KB
testcase_01 AC 19 ms
8,820 KB
testcase_02 AC 18 ms
8,572 KB
testcase_03 AC 19 ms
8,676 KB
testcase_04 AC 18 ms
8,852 KB
testcase_05 AC 18 ms
8,872 KB
testcase_06 AC 19 ms
8,732 KB
testcase_07 AC 41 ms
8,736 KB
testcase_08 AC 26 ms
8,884 KB
testcase_09 AC 20 ms
8,688 KB
testcase_10 AC 244 ms
8,872 KB
testcase_11 AC 19 ms
8,696 KB
testcase_12 AC 114 ms
8,944 KB
testcase_13 AC 106 ms
8,784 KB
testcase_14 AC 228 ms
8,932 KB
testcase_15 AC 114 ms
8,936 KB
testcase_16 AC 61 ms
8,924 KB
testcase_17 AC 92 ms
8,796 KB
testcase_18 AC 34 ms
8,744 KB
testcase_19 AC 62 ms
8,796 KB
testcase_20 AC 21 ms
8,796 KB
testcase_21 AC 103 ms
8,828 KB
testcase_22 AC 34 ms
8,936 KB
testcase_23 AC 21 ms
8,756 KB
testcase_24 AC 29 ms
8,876 KB
testcase_25 AC 83 ms
8,884 KB
testcase_26 AC 74 ms
8,764 KB
testcase_27 AC 20 ms
8,688 KB
testcase_28 AC 81 ms
8,816 KB
testcase_29 AC 79 ms
8,904 KB
testcase_30 AC 19 ms
8,860 KB
testcase_31 AC 59 ms
8,740 KB
testcase_32 AC 87 ms
8,892 KB
testcase_33 AC 244 ms
8,816 KB
testcase_34 AC 20 ms
8,856 KB
testcase_35 AC 149 ms
8,912 KB
testcase_36 AC 30 ms
8,844 KB
testcase_37 AC 1,921 ms
8,996 KB
testcase_38 AC 113 ms
8,964 KB
testcase_39 AC 313 ms
8,988 KB
testcase_40 AC 67 ms
8,840 KB
testcase_41 AC 182 ms
8,848 KB
testcase_42 AC 22 ms
8,768 KB
testcase_43 AC 33 ms
8,872 KB
testcase_44 AC 1,219 ms
8,804 KB
testcase_45 AC 49 ms
8,832 KB
testcase_46 AC 189 ms
8,964 KB
testcase_47 AC 20 ms
8,724 KB
testcase_48 AC 97 ms
8,768 KB
testcase_49 AC 508 ms
8,796 KB
testcase_50 AC 21 ms
8,764 KB
testcase_51 AC 23 ms
8,708 KB
testcase_52 AC 29 ms
8,928 KB
testcase_53 AC 181 ms
8,932 KB
testcase_54 AC 97 ms
8,920 KB
testcase_55 AC 100 ms
8,964 KB
testcase_56 AC 107 ms
8,896 KB
testcase_57 AC 19 ms
8,728 KB
testcase_58 AC 43 ms
8,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
from collections import deque
def is_ham1(a,b):
    if math.log2(a^b).is_integer():
        return True
    else:
        return False

n = int(input())
s,g = map(int,input().split())
ishi = deque(map(int,input().split()))
ishi.appendleft(g)
q=deque()

q.append([s,0])
S=set()
S.add(s)
while q:
    a = q.popleft()
    S.add(a[0]) 
    for b in ishi:
        if a[0]==b: continue
        if not is_ham1(a[0],b): continue
        if b in S: continue
        if b==g:
            print(a[1])
            exit()
        q.append([b,a[1]+1])

print(-1)
0