結果
問題 |
No.2165 Let's Play Nim!
|
ユーザー |
|
提出日時 | 2022-12-16 03:12:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,281 bytes |
コンパイル時間 | 1,848 ms |
コンパイル使用メモリ | 172,852 KB |
実行使用メモリ | 40,772 KB |
平均クエリ数 | 234.28 |
最終ジャッジ日時 | 2024-11-15 07:30:17 |
合計ジャッジ時間 | 92,773 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 TLE * 29 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ //ios::sync_with_stdio(false); //cin.tie(0); int n, v = 0, p, x, s; cin >> n; vector<int> a(n); queue<int> q; for(int i = 0; i < n; i++){ cin >> a[i]; q.push(i); v ^= a[i]; } auto update = [&](int p, int x){ //S.erase(make_pair(a[p], p)); //BT.add(a[p], -1); v ^= a[p]; a[p] -= x; v ^= a[p]; /*if(a[p] >= 1){ S.insert(make_pair(a[p], p)); BT.add(a[p], 1); }*/ }; auto my_turn = [&](){ while(!q.empty()){ int i = q.front(); q.pop(); if((a[i] ^ v) < a[i]){ cout << i + 1 << " " << a[i] - (v ^ a[i]) << endl; update(i, a[i] - (v ^ a[i])); if(a[i] != 0)q.push(i); return; } if(a[i] != 0)q.push(i); } }; if(v == 0){ cout << 0 << endl; cin >> p >> x; update(--p, x); }else{ cout << 1 << endl; my_turn(); } while(true){ cin >> s; if(s == -1)break; my_turn(); cin >> s; if(s == -1)break; cin >> p >> x; update(--p, x); } }