結果

問題 No.74 貯金箱の退屈
ユーザー miyo2580miyo2580
提出日時 2024-02-14 20:55:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,371 bytes
コンパイル時間 2,448 ms
コンパイル使用メモリ 207,420 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-14 20:55:38
合計ジャッジ時間 4,148 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,676 KB
testcase_05 WA -
testcase_06 AC 2 ms
6,676 KB
testcase_07 WA -
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 WA -
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 WA -
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
testcase_31 AC 2 ms
6,676 KB
testcase_32 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
using Graph = vector<vector<ll>>;
const long long INF = 1LL<<60;
const long long MOD = 1000000007;

int main()
{  
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;cin>>n;
    vec d(n),w(n);
    rep(i,n)cin>>d[i];
    rep(i,n){
      cin>>w[i];
      w[i]=1-w[i];
    }
    Graph g(n,vec(n));
    rep(i,n){
      ll x=i+d[i];
      ll y=i-d[i];
      x%=n;
      y%=n;
      if(y<0)y+=n;
      g[x][i]=1;
      if(x!=y)g[y][i]=1;
    }
    ll cnt=0;
    rep(i,n){
      ll idx=-1;
      repd(j,cnt,n){
        if(g[j][i]){
          idx=j;
          break;
        }
      }
      if(idx==-1)continue;
      swap(g[cnt],g[idx]);
      swap(w[idx],w[cnt]);
      repd(j,cnt+1,n){
        if(g[j][i]){
          rep(k,n){
            g[j][k]^=g[cnt][k];
          }
        }
      }
      cnt++;
    }
    repd(i,cnt,n){
      if(w[i]==1){
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
    return 0;
}
0