結果
問題 |
No.74 貯金箱の退屈
|
ユーザー |
|
提出日時 | 2014-11-25 18:39:14 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 616 bytes |
コンパイル時間 | 197 ms |
コンパイル使用メモリ | 12,160 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2025-01-03 02:24:43 |
合計ジャッジ時間 | 2,247 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 13 |
ソースコード
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")