結果

問題 No.74 貯金箱の退屈
ユーザー cologne
提出日時 2022-01-25 19:48:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 701 bytes
コンパイル時間 186 ms
コンパイル使用メモリ 82,436 KB
実行使用メモリ 64,768 KB
最終ジャッジ日時 2024-12-17 14:19:54
合計ジャッジ時間 2,787 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys


def input(): return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    *D, = map(int, input().split())
    *W, = map(int, input().split())

    target = 0
    arr = []
    for i in range(N):
        target |= (1-W[i]) << i
        L = (i-D[i]) % N
        R = (i+D[i]) % N
        arr.append((1 << L) | (1 << R))

    for i in range(N):
        ans = None
        for v in arr:
            if v & (1 << i):
                ans = v
        if ans is not None:
            if target & (1 << i):
                target ^= ans
            arr = [x ^ ans if x & (1 << i) else x for x in arr]

    print('Yes' if target == 0 else 'No')


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