結果

問題 No.74 貯金箱の退屈
ユーザー gigurururugigurururu
提出日時 2014-11-25 18:34:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 608 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 8,020 KB
最終ジャッジ日時 2023-08-31 01:10:52
合計ジャッジ時間 2,092 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,964 KB
testcase_01 AC 15 ms
7,920 KB
testcase_02 AC 16 ms
7,784 KB
testcase_03 AC 16 ms
7,972 KB
testcase_04 AC 17 ms
7,940 KB
testcase_05 AC 16 ms
7,784 KB
testcase_06 AC 16 ms
7,868 KB
testcase_07 AC 15 ms
7,852 KB
testcase_08 AC 15 ms
7,832 KB
testcase_09 AC 16 ms
7,920 KB
testcase_10 AC 16 ms
7,940 KB
testcase_11 AC 16 ms
7,860 KB
testcase_12 AC 16 ms
8,020 KB
testcase_13 AC 15 ms
7,992 KB
testcase_14 AC 16 ms
7,960 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 16 ms
7,924 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 16 ms
7,900 KB
testcase_21 AC 16 ms
7,876 KB
testcase_22 AC 16 ms
7,856 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 16 ms
7,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
d=map(int,input().split())
w=map(int,input().split())

uf=list(range(n))
rv=[False]*n

def f(n):
    if n==uf[n]:
        return n 
    else:
        uf[n]=f(uf[n])
        return uf[n]

def u(a,b):
    uf[f(a)]=f(b)

for i,di in enumerate(d):
    u((i+di)%n,(i-di)%n)
    if (i+di)%n==(i-di)%n: rv[(i+di)%n]=True

for i,b in enumerate(rv):
    n=f(i)
    if b: rv[n]=True

for i in set(uf):
    cnt=0
    for n,wi in enumerate(w):
        if  uf[n]==i and wi==0: cnt+=1
    if not rv[i] and cnt%2!=0:
        print("No")
        break
else:
    print("Yes")
0