結果

問題 No.1576 織姫と彦星
ユーザー 👑 KazunKazun
提出日時 2021-06-29 17:38:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 575 ms / 2,000 ms
コード長 479 bytes
コンパイル時間 680 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 77,884 KB
最終ジャッジ日時 2023-09-08 02:40:29
合計ジャッジ時間 13,438 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
71,820 KB
testcase_01 AC 82 ms
71,784 KB
testcase_02 AC 90 ms
71,488 KB
testcase_03 AC 86 ms
71,692 KB
testcase_04 AC 87 ms
71,480 KB
testcase_05 AC 87 ms
71,356 KB
testcase_06 AC 89 ms
71,452 KB
testcase_07 AC 135 ms
77,528 KB
testcase_08 AC 103 ms
77,424 KB
testcase_09 AC 96 ms
76,860 KB
testcase_10 AC 307 ms
77,620 KB
testcase_11 AC 101 ms
77,224 KB
testcase_12 AC 222 ms
77,664 KB
testcase_13 AC 207 ms
76,984 KB
testcase_14 AC 306 ms
77,768 KB
testcase_15 AC 269 ms
77,688 KB
testcase_16 AC 168 ms
77,364 KB
testcase_17 AC 226 ms
77,720 KB
testcase_18 AC 120 ms
77,452 KB
testcase_19 AC 173 ms
77,500 KB
testcase_20 AC 99 ms
77,312 KB
testcase_21 AC 252 ms
77,508 KB
testcase_22 AC 120 ms
77,248 KB
testcase_23 AC 97 ms
77,352 KB
testcase_24 AC 110 ms
77,304 KB
testcase_25 AC 207 ms
77,764 KB
testcase_26 AC 194 ms
77,752 KB
testcase_27 AC 97 ms
77,284 KB
testcase_28 AC 214 ms
77,720 KB
testcase_29 AC 200 ms
77,572 KB
testcase_30 AC 89 ms
72,232 KB
testcase_31 AC 168 ms
77,500 KB
testcase_32 AC 226 ms
77,468 KB
testcase_33 AC 516 ms
77,684 KB
testcase_34 AC 95 ms
77,396 KB
testcase_35 AC 218 ms
77,820 KB
testcase_36 AC 113 ms
77,308 KB
testcase_37 AC 513 ms
77,864 KB
testcase_38 AC 259 ms
77,768 KB
testcase_39 AC 233 ms
77,472 KB
testcase_40 AC 181 ms
77,576 KB
testcase_41 AC 214 ms
77,872 KB
testcase_42 AC 100 ms
77,284 KB
testcase_43 AC 124 ms
77,288 KB
testcase_44 AC 575 ms
77,884 KB
testcase_45 AC 147 ms
77,380 KB
testcase_46 AC 394 ms
77,312 KB
testcase_47 AC 100 ms
77,480 KB
testcase_48 AC 244 ms
77,632 KB
testcase_49 AC 223 ms
77,632 KB
testcase_50 AC 97 ms
77,104 KB
testcase_51 AC 98 ms
77,200 KB
testcase_52 AC 116 ms
77,312 KB
testcase_53 AC 347 ms
77,668 KB
testcase_54 AC 235 ms
77,632 KB
testcase_55 AC 243 ms
77,652 KB
testcase_56 AC 262 ms
77,652 KB
testcase_57 AC 97 ms
77,292 KB
testcase_58 AC 140 ms
77,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def popcount(x):
    return bin(x).count("1")

def Hamming(x,y):
    return popcount(x^y)
#==================================================
from collections import deque

N=int(input())
S,G=map(int,input().split())
A=list(map(int,input().split()))

V=[S,G]+A
Q=deque([0])
X=[-1]*(N+2); X[0]=0

while Q:
    x=Q.popleft()
    for y in range(N+2):
        if Hamming(V[x],V[y])==1 and X[y]==-1:
            X[y]=X[x]+1
            Q.append(y)

print(X[1]-1 if X[1]!=-1 else -1)
0