結果
問題 |
No.74 貯金箱の退屈
|
ユーザー |
|
提出日時 | 2016-10-05 21:27:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,276 bytes |
コンパイル時間 | 1,873 ms |
コンパイル使用メモリ | 173,796 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-21 17:25:26 |
合計ジャッジ時間 | 6,477 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | RE * 30 |
ソースコード
#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<<endl #define smax(x,y) (x)=max((x),(y)) #define smin(x,y) (x)=min((x),(y)) #define MEM(x,y) memset((x),(y),sizeof (x)) #define sz(x) (int)(x).size() typedef long long ll; typedef pair<int, int> pii; typedef vector<int> vi; typedef vector<ll> vll; int con[101][101]; int main(){ int N; cin >> N; vi D(N), W(N); rep(i, N)cin >> D[i]; rep(i, N)cin >> W[i]; vi self; rep(i, N){ int a = (i + D[i]) % N, b = (N + i - D[i]) % N; if(a == b)self.push_back(a); else{ con[a][b] = con[b][a] = 1; } } sort(all(self)); self.erase(unique(all(self)), self.end()); rep(k, N)rep(u, N)rep(v, N)con[u][v] |= con[u][k] & con[k][v]; rep(i, N)if(!W[i]){ each(se, self){ if(con[i][se]){ W[i] = 1; break; } } } rep(i, N)rep(j, i)if(!W[i] && !W[j]){ if(con[i][j])W[i] = W[j] = 1; } bool ans = count(all(W), 1)==N; puts(ans ? "Yes" : "No"); }