結果

問題 No.74 貯金箱の退屈
ユーザー titiatitia
提出日時 2022-05-25 01:08:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 779 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 81,704 KB
実行使用メモリ 59,332 KB
最終ジャッジ日時 2023-10-20 19:03:46
合計ジャッジ時間 2,941 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,436 KB
testcase_01 AC 36 ms
53,436 KB
testcase_02 AC 36 ms
53,436 KB
testcase_03 AC 39 ms
57,156 KB
testcase_04 AC 39 ms
57,168 KB
testcase_05 AC 40 ms
57,168 KB
testcase_06 AC 39 ms
56,772 KB
testcase_07 AC 39 ms
57,168 KB
testcase_08 AC 39 ms
57,168 KB
testcase_09 AC 40 ms
57,168 KB
testcase_10 AC 38 ms
57,168 KB
testcase_11 AC 38 ms
57,168 KB
testcase_12 AC 39 ms
59,220 KB
testcase_13 AC 41 ms
59,332 KB
testcase_14 AC 42 ms
59,328 KB
testcase_15 AC 43 ms
59,328 KB
testcase_16 AC 41 ms
59,332 KB
testcase_17 AC 36 ms
53,448 KB
testcase_18 AC 36 ms
53,448 KB
testcase_19 AC 39 ms
57,168 KB
testcase_20 AC 40 ms
59,328 KB
testcase_21 AC 41 ms
59,328 KB
testcase_22 AC 37 ms
53,448 KB
testcase_23 AC 38 ms
53,448 KB
testcase_24 AC 40 ms
59,324 KB
testcase_25 AC 40 ms
59,328 KB
testcase_26 AC 42 ms
59,328 KB
testcase_27 AC 41 ms
59,328 KB
testcase_28 AC 42 ms
59,328 KB
testcase_29 AC 41 ms
59,328 KB
testcase_30 AC 41 ms
59,332 KB
testcase_31 AC 42 ms
59,328 KB
testcase_32 AC 40 ms
57,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# xor基底の問題かと思ったが、そう解説している人はいなそう。(結局、掃き出し法と同じになるかもしれないが)
# iとjをひっくり返せるとき、(1<<i)|(1<<j)を基底に追加する。
# 1<<i s.t. W[i]==0となるもの がその基底で0になるか調べればOK。


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


# xorの掃き出し法・基底

BASE=[]

def sweep(x):
    for b in BASE:
        if b^x<x:
            x=b^x
    return x

for i in range(N):
    x=(i+D[i])%N
    y=(i-D[i])%N

    z=(1<<x)|(1<<y)

    k=sweep(z)
    if k!=0:
        BASE.append(k)

x=0

for i in range(N):
    if W[i]==0:
        x|=(1<<i)

k=sweep(x)

if k==0:
    print("Yes")
else:
    print("No")
0