結果

問題 No.1183 コイン遊び
ユーザー ThetaTheta
提出日時 2022-10-18 11:50:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 629 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 17,824 KB
最終ジャッジ日時 2023-09-11 06:25:36
合計ジャッジ時間 8,143 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,932 KB
testcase_01 AC 16 ms
7,880 KB
testcase_02 AC 16 ms
7,760 KB
testcase_03 AC 16 ms
7,808 KB
testcase_04 AC 16 ms
7,744 KB
testcase_05 AC 16 ms
7,864 KB
testcase_06 AC 16 ms
7,768 KB
testcase_07 AC 16 ms
7,764 KB
testcase_08 AC 18 ms
8,256 KB
testcase_09 AC 18 ms
8,248 KB
testcase_10 AC 403 ms
9,716 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    A_num = int("0b" + "".join(map(str, A)), 0)
    B_num = int("0b" + "".join(map(str, B)), 0)

    left_idx = 0
    right_idx = N - 1

    ctr = 0
    while A_num ^ B_num:
        left_idx = N - len(format(A_num ^ B_num, "b"))
        right_idx = left_idx + format(A_num ^ B_num, "b").rfind("1")
        mask = int(
            "0b"
            + "1"*(right_idx-left_idx+1)
            + "0"*(N-right_idx-1), 0)
        A_num = A_num ^ mask
        ctr += 1

    print(ctr)


if __name__ == "__main__":
    main()
0