結果

問題 No.1576 織姫と彦星
ユーザー d1k0b3od1k0b3o
提出日時 2021-07-18 18:46:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,827 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 9,036 KB
最終ジャッジ日時 2023-09-22 21:44:07
合計ジャッジ時間 10,127 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,648 KB
testcase_01 AC 22 ms
8,824 KB
testcase_02 AC 20 ms
8,632 KB
testcase_03 AC 20 ms
8,844 KB
testcase_04 AC 19 ms
8,800 KB
testcase_05 AC 19 ms
8,900 KB
testcase_06 AC 19 ms
8,864 KB
testcase_07 AC 40 ms
8,912 KB
testcase_08 AC 27 ms
8,928 KB
testcase_09 AC 20 ms
8,736 KB
testcase_10 AC 248 ms
8,848 KB
testcase_11 AC 19 ms
8,936 KB
testcase_12 AC 109 ms
8,912 KB
testcase_13 AC 107 ms
8,968 KB
testcase_14 AC 220 ms
8,856 KB
testcase_15 AC 115 ms
8,952 KB
testcase_16 AC 60 ms
8,912 KB
testcase_17 AC 99 ms
8,988 KB
testcase_18 AC 33 ms
8,856 KB
testcase_19 AC 60 ms
8,800 KB
testcase_20 AC 20 ms
8,964 KB
testcase_21 AC 100 ms
8,836 KB
testcase_22 AC 34 ms
8,852 KB
testcase_23 AC 22 ms
8,760 KB
testcase_24 AC 29 ms
8,888 KB
testcase_25 AC 84 ms
8,948 KB
testcase_26 AC 73 ms
8,976 KB
testcase_27 AC 21 ms
8,772 KB
testcase_28 AC 82 ms
8,928 KB
testcase_29 AC 77 ms
8,812 KB
testcase_30 AC 19 ms
8,744 KB
testcase_31 AC 59 ms
8,772 KB
testcase_32 AC 87 ms
8,808 KB
testcase_33 AC 243 ms
8,960 KB
testcase_34 AC 20 ms
8,736 KB
testcase_35 AC 145 ms
8,812 KB
testcase_36 AC 31 ms
8,756 KB
testcase_37 AC 1,827 ms
8,896 KB
testcase_38 AC 112 ms
8,996 KB
testcase_39 AC 308 ms
8,940 KB
testcase_40 AC 66 ms
8,820 KB
testcase_41 AC 180 ms
8,816 KB
testcase_42 AC 22 ms
8,896 KB
testcase_43 AC 33 ms
8,792 KB
testcase_44 AC 1,195 ms
8,840 KB
testcase_45 AC 51 ms
8,892 KB
testcase_46 AC 179 ms
8,836 KB
testcase_47 AC 21 ms
8,760 KB
testcase_48 AC 99 ms
8,912 KB
testcase_49 AC 511 ms
8,932 KB
testcase_50 AC 21 ms
8,892 KB
testcase_51 AC 23 ms
8,852 KB
testcase_52 AC 29 ms
8,920 KB
testcase_53 AC 182 ms
9,036 KB
testcase_54 AC 99 ms
8,972 KB
testcase_55 AC 99 ms
8,840 KB
testcase_56 AC 107 ms
8,924 KB
testcase_57 AC 21 ms
8,896 KB
testcase_58 AC 43 ms
8,928 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 = [g]+ list(map(int,input().split()))
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