結果

問題 No.74 貯金箱の退屈
ユーザー codershifthcodershifth
提出日時 2015-07-31 07:48:34
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,774 bytes
コンパイル時間 2,564 ms
コンパイル使用メモリ 146,844 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-24 22:25:14
合計ジャッジ時間 2,986 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()

using namespace std;


class BoredomOfSavingsBox {
public:
    void solve(void) {
            int N;
            cin>>N;
            vector<int> D(N);
            REP(i,N)
                cin>>D[i];
            vector<int> W(N);
            REP(i,N)
                cin>>W[i];

            // O(N^3)
            REP(i, N)
            {
                bool all_ok = false;
                vector<int> w(W);
                int d = D[i];
                int l = (d+i)%N;
                int r = (N*1000-d+i)%N;
                w[i] ^= 1;
                // d による周期は最大 N
                REP(j, N)
                {
                    bool ok = true;
                    REP(i, N)
                        ok &= (w[i]==1);
                    if (ok)
                    {
                        all_ok = true;
                        break;
                    }
                    if (l == r)
                        w[l] ^= 1;
                    else
                    {
                        w[l] ^= 1;
                        w[r] -= 1;
                    }
                    l = (l+d)%N;
                    r = (N*1000-d+r)%N;
                }
                if (all_ok)
                {
                    cout<<"Yes"<<endl;
                    return;
                }
            }
            cout<<"No"<<endl;
            return;
    }
};

#if 1
int main(int argc, char *argv[])
{
        ios::sync_with_stdio(false);
        auto obj = new BoredomOfSavingsBox();
        obj->solve();
        delete obj;
        return 0;
}
#endif
0