結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,860 KB
testcase_01 AC 15 ms
7,824 KB
testcase_02 AC 14 ms
7,872 KB
testcase_03 AC 14 ms
7,864 KB
testcase_04 AC 14 ms
7,912 KB
testcase_05 AC 13 ms
7,864 KB
testcase_06 AC 13 ms
7,820 KB
testcase_07 AC 14 ms
7,804 KB
testcase_08 AC 13 ms
7,876 KB
testcase_09 AC 12 ms
7,868 KB
testcase_10 AC 14 ms
8,008 KB
testcase_11 AC 14 ms
7,892 KB
testcase_12 AC 14 ms
8,008 KB
testcase_13 AC 13 ms
7,924 KB
testcase_14 AC 13 ms
7,784 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 13 ms
7,836 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 14 ms
7,920 KB
testcase_21 AC 13 ms
7,852 KB
testcase_22 AC 12 ms
7,880 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 13 ms
7,808 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):
    a,b=(i+di)%n,(i-di)%n
    u(a,b)
    if a==b: rv[a]=True

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

for i in set([f(j) for j in 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