結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,816 KB
testcase_01 AC 16 ms
7,776 KB
testcase_02 AC 15 ms
7,780 KB
testcase_03 AC 15 ms
7,904 KB
testcase_04 AC 16 ms
7,792 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 15 ms
7,836 KB
testcase_08 AC 15 ms
7,764 KB
testcase_09 AC 16 ms
7,836 KB
testcase_10 AC 16 ms
7,904 KB
testcase_11 AC 15 ms
7,724 KB
testcase_12 AC 16 ms
7,728 KB
testcase_13 AC 15 ms
7,776 KB
testcase_14 AC 15 ms
7,832 KB
testcase_15 AC 16 ms
7,828 KB
testcase_16 AC 16 ms
7,768 KB
testcase_17 AC 15 ms
7,760 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 16 ms
7,840 KB
testcase_22 AC 15 ms
7,840 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 16 ms
7,824 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 15 ms
7,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

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

def union(a,b):
    uf[find(a)]=find(b)

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

for i,b in enumerate(rv):
    if b: rv[find(i)]=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