結果
| 問題 |
No.74 貯金箱の退屈
|
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-06-04 01:16:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,126 bytes |
| コンパイル時間 | 769 ms |
| コンパイル使用メモリ | 66,264 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-08 07:42:41 |
| 合計ジャッジ時間 | 5,929 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | RE * 30 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
#define REP(i,s,e) for (i = s; i <= e; i++)
#define rep(i,n) REP (i,0,(int)(n)-1)
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP (i,(int)(n)-1,0)
#define INF (int)1e8
#define MOD (int)(1e9+7)
typedef long long ll;
int par[100];
int find(int x) {
if (par[x] == x)
return x;
else
return par[x] = find(par[x]);
}
void unite(int x, int y) {
par[find(x)] = find(y);
}
void init(int n) {
int i;
rep (i,n) par[i] = i;
}
int main(void) {
int i, n;
int d[100], w[100];
int cnt[100] {};
cin >> n;
rep (i,n) cin >> d[i];
rep (i,n) cin >> w[i];
init(n);
rep (i,n) {
unite((i+d[i])%n,(i-d[i]+n)%n);
}
rep (i,n) if ((i+d[i])%n == (i-d[i]+n)%n) cnt[find(i)] = -2;
rep (i,n) {
int x = find(i);
if (cnt[x] < 0) continue;
cnt[x] += w[i] == 0;
}
bool ans = true;
rep (i,n) ans &= cnt[i] % 2 == 0;
if (ans)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}
h_noson