結果

問題 No.2165 Let's Play Nim!
ユーザー 👑 NachiaNachia
提出日時 2022-12-16 00:13:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,601 bytes
コンパイル時間 1,038 ms
コンパイル使用メモリ 98,296 KB
実行使用メモリ 40,112 KB
平均クエリ数 1.54
最終ジャッジ日時 2024-04-27 04:24:37
合計ジャッジ時間 9,347 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 TLE -
testcase_31 -- -
testcase_32 -- -
evil_2_big_1.txt -- -
evil_2_big_2.txt -- -
evil_2_big_3.txt -- -
evil_big_1.txt -- -
evil_big_2.txt -- -
evil_big_3.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <atcoder/modint>
#include <atcoder/segtree>

using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;

using Modint = atcoder::static_modint<998244353>;

namespace Segtree {
    using S = pair<int,int>;
    S e(){ return {-1,-1}; }
    S op(S l, S r){ return max(l, r); }
    using RQ = atcoder::segtree<S, op, e>;
}

int main(){
    int N; cin >> N;
    vector<int> A(N); rep(i,N) cin >> A[i];
    Segtree::RQ rq(N);
    rep(i,N) rq.set(i, {A[i],i});

    int allxor = 0;
    for(int a : A) allxor ^= a;

    auto readMove = [&](){
        int i,k; cin >> i >> k; i--;
        allxor ^= A[i];
        A[i] -= k;
        rq.set(i, {A[i],i});
        allxor ^= A[i];
    };

    auto doMove = [&](){
        int i = rq.all_prod().second;
        allxor ^= A[i];
        int k = A[i] - allxor;
        cout << (i+1) << ' ' << k << endl;
        A[i] -= k;
        rq.set(i, {A[i],i});
        allxor ^= A[i];
    };

    if(allxor != 0){
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
        readMove();
        int r; cin >> r;
        if(r == -1) return 0;
    }

    while(true){
        doMove();
        readMove();
        int r; cin >> r;
        if(r == -1) break;
    }
    return 0;
}


struct ios_do_not_sync{
    ios_do_not_sync(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;


0