結果

問題 No.1576 織姫と彦星
ユーザー y05h1k1ngy05h1k1ng
提出日時 2021-07-01 12:23:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 551 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 77,764 KB
最終ジャッジ日時 2023-09-10 10:05:45
合計ジャッジ時間 13,421 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
71,472 KB
testcase_01 AC 96 ms
71,480 KB
testcase_02 AC 95 ms
71,500 KB
testcase_03 AC 93 ms
71,640 KB
testcase_04 AC 92 ms
71,988 KB
testcase_05 AC 92 ms
71,336 KB
testcase_06 AC 91 ms
71,484 KB
testcase_07 AC 136 ms
76,980 KB
testcase_08 AC 111 ms
77,132 KB
testcase_09 AC 101 ms
77,224 KB
testcase_10 AC 269 ms
77,532 KB
testcase_11 AC 102 ms
76,884 KB
testcase_12 AC 197 ms
77,540 KB
testcase_13 AC 204 ms
77,024 KB
testcase_14 AC 249 ms
77,348 KB
testcase_15 AC 237 ms
77,392 KB
testcase_16 AC 175 ms
77,308 KB
testcase_17 AC 221 ms
77,396 KB
testcase_18 AC 121 ms
77,100 KB
testcase_19 AC 148 ms
77,604 KB
testcase_20 AC 104 ms
77,244 KB
testcase_21 AC 223 ms
77,504 KB
testcase_22 AC 127 ms
77,064 KB
testcase_23 AC 107 ms
76,740 KB
testcase_24 AC 116 ms
77,296 KB
testcase_25 AC 217 ms
77,484 KB
testcase_26 AC 164 ms
77,524 KB
testcase_27 AC 103 ms
77,172 KB
testcase_28 AC 211 ms
77,516 KB
testcase_29 AC 162 ms
77,504 KB
testcase_30 AC 93 ms
71,744 KB
testcase_31 AC 161 ms
77,356 KB
testcase_32 AC 211 ms
77,328 KB
testcase_33 AC 375 ms
77,764 KB
testcase_34 AC 108 ms
77,488 KB
testcase_35 AC 183 ms
77,416 KB
testcase_36 AC 115 ms
77,148 KB
testcase_37 AC 399 ms
77,360 KB
testcase_38 AC 248 ms
77,360 KB
testcase_39 AC 207 ms
77,372 KB
testcase_40 AC 173 ms
77,524 KB
testcase_41 AC 185 ms
77,564 KB
testcase_42 AC 105 ms
76,924 KB
testcase_43 AC 123 ms
77,248 KB
testcase_44 AC 381 ms
77,432 KB
testcase_45 AC 149 ms
77,224 KB
testcase_46 AC 273 ms
77,500 KB
testcase_47 AC 106 ms
77,288 KB
testcase_48 AC 201 ms
77,456 KB
testcase_49 AC 193 ms
77,400 KB
testcase_50 AC 105 ms
76,724 KB
testcase_51 AC 114 ms
76,980 KB
testcase_52 AC 128 ms
77,164 KB
testcase_53 AC 259 ms
77,608 KB
testcase_54 AC 231 ms
77,544 KB
testcase_55 AC 239 ms
77,512 KB
testcase_56 AC 252 ms
77,152 KB
testcase_57 AC 100 ms
76,992 KB
testcase_58 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

def hamming_distance(a: int, b: int) -> int:
    x = a ^ b
    return bin(x)[2:].count("1")

n = int(input())
start, end = map(int, input().split(" "))
stones = list(map(int, input().split(" ")))

que = deque([])
que.append((0, start))

while len(que):
    cnt, now = que.popleft()

    if hamming_distance(now, end) == 1:
        print(cnt)
        break

    for stone in stones:
        if hamming_distance(now, stone) == 1:
            que.append((cnt+1, stone))
            stones.remove(stone)
else:
    print(-1)
0