結果

問題 No.74 貯金箱の退屈
ユーザー 👑 rin204rin204
提出日時 2022-09-29 19:30:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 482 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 76,376 KB
最終ジャッジ日時 2023-08-24 05:01:32
合計ジャッジ時間 4,433 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,628 KB
testcase_01 AC 72 ms
71,528 KB
testcase_02 AC 73 ms
71,256 KB
testcase_03 AC 76 ms
75,860 KB
testcase_04 AC 75 ms
75,908 KB
testcase_05 AC 76 ms
75,652 KB
testcase_06 AC 76 ms
76,272 KB
testcase_07 AC 74 ms
75,892 KB
testcase_08 AC 74 ms
75,856 KB
testcase_09 AC 75 ms
75,656 KB
testcase_10 AC 75 ms
75,852 KB
testcase_11 AC 76 ms
75,924 KB
testcase_12 AC 77 ms
75,828 KB
testcase_13 AC 79 ms
76,192 KB
testcase_14 AC 79 ms
76,116 KB
testcase_15 AC 78 ms
76,276 KB
testcase_16 AC 78 ms
76,004 KB
testcase_17 AC 71 ms
71,420 KB
testcase_18 AC 70 ms
71,456 KB
testcase_19 AC 77 ms
75,916 KB
testcase_20 AC 80 ms
76,204 KB
testcase_21 AC 82 ms
76,316 KB
testcase_22 AC 75 ms
71,388 KB
testcase_23 AC 75 ms
71,524 KB
testcase_24 AC 80 ms
76,016 KB
testcase_25 AC 77 ms
76,128 KB
testcase_26 AC 79 ms
76,220 KB
testcase_27 AC 80 ms
75,836 KB
testcase_28 AC 79 ms
76,172 KB
testcase_29 AC 78 ms
76,332 KB
testcase_30 AC 83 ms
76,148 KB
testcase_31 AC 81 ms
76,376 KB
testcase_32 AC 74 ms
75,924 KB
権限があれば一括ダウンロードができます

ソースコード

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