結果

問題 No.74 貯金箱の退屈
コンテスト
ユーザー 👑 cologne
提出日時 2022-01-25 19:48:29
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 34 ms / 5,000 ms
+ 429µs
コード長 701 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 71 ms
コンパイル使用メモリ 81,280 KB
実行使用メモリ 66,176 KB
最終ジャッジ日時 2026-10-04 16:29:00
合計ジャッジ時間 3,103 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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