結果

問題 No.2165 Let's Play Nim!
ユーザー t98slidert98slider
提出日時 2022-12-16 04:58:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 3,294 ms
コンパイル使用メモリ 170,412 KB
実行使用メモリ 24,276 KB
平均クエリ数 863.56
最終ジャッジ日時 2023-08-09 13:48:21
合計ジャッジ時間 10,702 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,460 KB
testcase_01 AC 126 ms
23,676 KB
testcase_02 AC 137 ms
23,892 KB
testcase_03 AC 88 ms
23,376 KB
testcase_04 AC 26 ms
23,688 KB
testcase_05 AC 32 ms
24,276 KB
testcase_06 AC 32 ms
24,144 KB
testcase_07 AC 30 ms
23,268 KB
testcase_08 AC 94 ms
23,088 KB
testcase_09 AC 27 ms
23,472 KB
testcase_10 AC 34 ms
23,268 KB
testcase_11 AC 135 ms
24,156 KB
testcase_12 AC 118 ms
24,096 KB
testcase_13 AC 26 ms
23,472 KB
testcase_14 AC 31 ms
23,388 KB
testcase_15 AC 27 ms
23,688 KB
testcase_16 AC 111 ms
23,232 KB
testcase_17 AC 63 ms
23,484 KB
testcase_18 AC 195 ms
23,376 KB
testcase_19 AC 26 ms
23,664 KB
testcase_20 AC 30 ms
23,484 KB
testcase_21 AC 53 ms
23,868 KB
testcase_22 AC 46 ms
23,676 KB
testcase_23 AC 43 ms
23,268 KB
testcase_24 AC 39 ms
23,424 KB
testcase_25 AC 79 ms
23,268 KB
testcase_26 AC 137 ms
23,436 KB
testcase_27 AC 46 ms
23,688 KB
testcase_28 AC 68 ms
24,180 KB
testcase_29 AC 25 ms
23,580 KB
testcase_30 AC 25 ms
23,412 KB
testcase_31 AC 25 ms
24,072 KB
testcase_32 AC 94 ms
23,256 KB
evil_2_big_1.txt RE -
evil_2_big_2.txt RE -
evil_2_big_3.txt RE -
evil_big_1.txt RE -
evil_big_2.txt RE -
evil_big_3.txt RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, v = 0, p, x, s, M = 18;
    cin >> n;
    vector<int> a(n);
    vector<bitset<10000>> S(M);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        v ^= a[i];
        for(int j = 0; j < M; j++){
            if(a[i] >> j & 1)S[j][i] = 1;
        }
    }
    auto update = [&](int p, int x){
        v ^= a[p];
        for(int j = 0; j < M; j++)S[j][p] = 0;
        a[p] -= x;
        v ^= a[p];
        for(int j = 0; j < M; j++){
            if(a[p] >> j & 1)S[j][p] = 1;
        }
    };
    auto my_turn = [&](){
        int p = S[__lg(v)]._Find_first();
        cout << p + 1 << " " << a[p] - (v ^ a[p]) << endl;
        update(p, a[p] - (v ^ a[p]));
    };
    if(v == 0){
        cout << 0 << endl;
        cin >> p >> x;
        update(--p, x);
    }else{
        cout << 1 << endl;
        my_turn();
        cin >> s;
        if(s == -1)return 0;
        cin >> p >> x;
        update(--p, x);
    }
    while(true){
        cin >> s;
        if(s == -1)return 0;
        my_turn();
        cin >> s;
        if(s == -1)return 0;
        cin >> p >> x;
        update(--p, x);
    }
}
0