結果

問題 No.74 貯金箱の退屈
ユーザー 👑 rin204
提出日時 2022-09-29 19:30:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 54 ms / 5,000 ms
コード長 482 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 60,672 KB
最終ジャッジ日時 2024-12-22 18:18:43
合計ジャッジ時間 3,358 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
D = list(map(int, input().split()))
W = list(map(int, input().split()))

base = []
for i, d in enumerate(D):
    r = (i + d) % n
    l = (i - d) % n
    if r == l:
        x = 1 << l
    else:
        x = (1 << l) | (1 << r)

    for b in base:
        x = min(x, b ^ x)
    if x != 0:
        base.append(x)

x = 0
for i, w in enumerate(W):
    if w == 0:
        x |= 1 << i

for b in base:
    x = min(x, b ^ x)
if x == 0:
    print("Yes")
else:
    print("No")
0