結果
問題 |
No.2165 Let's Play Nim!
|
ユーザー |
|
提出日時 | 2022-12-16 03:38:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,102 bytes |
コンパイル時間 | 1,826 ms |
コンパイル使用メモリ | 177,564 KB |
実行使用メモリ | 40,760 KB |
平均クエリ数 | 22.49 |
最終ジャッジ日時 | 2024-11-15 07:59:58 |
合計ジャッジ時間 | 59,350 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 1 RE * 20 TLE * 17 |
ソースコード
#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<set<int>> tb(75001); vector<int> a(n); for(int i = 0; i < n; i++){ cin >> a[i]; tb[a[i]].insert(i); v ^= a[i]; } auto update = [&](int p, int x){ tb[a[p]].erase(p); v ^= a[p]; a[p] -= x; v ^= a[p]; tb[a[p]].insert(p); }; auto my_turn = [&](){ for(int j = v; j < 750000; j++){ if((j ^ v) >= j)continue; if(tb[j].empty())continue; cout << (*tb[j].begin()) + 1 << " " << j - (j ^ v) << '\n'; update(*tb[j].begin(), j - (j ^ v)); return; } }; 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); } }