結果
問題 |
No.3120 Lower Nim
|
ユーザー |
|
提出日時 | 2025-03-24 22:20:17 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,703 bytes |
コンパイル時間 | 4,397 ms |
コンパイル使用メモリ | 281,056 KB |
実行使用メモリ | 26,228 KB |
平均クエリ数 | 58.89 |
最終ジャッジ日時 | 2025-03-24 22:20:36 |
合計ジャッジ時間 | 17,956 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 1 |
other | RE * 37 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int n,x,a[200000],ret; set<pair<int,int>> stone; int lsb(int b) { return (b & (-b)); } int main(){ cin >> n; for(int i = 0; i < n; i++){ cin >> a[i]; x ^= a[i]; stone.insert(make_pair(a[i], i)); } if(x == 0){ cout << "Second" << endl; } else { cout << "First" << endl; bool moveMade = false; for(int i = 0; i < n && !moveMade; i++){ int oldVal = a[i]; for(int j = 1; j <= oldVal; j++){ int newVal = oldVal - j; if((x ^ oldVal ^ newVal) == 0){ stone.erase(make_pair(oldVal, i)); a[i] = newVal; if(newVal > 0) stone.insert(make_pair(newVal, i)); cout << i + 1 << " " << j << endl; moveMade = true; break; } } } cin >> ret; assert(ret != -1); } while(!stone.empty()){ int idx, num; cin >> idx >> num >> ret; assert(ret != -1); idx--; stone.erase(make_pair(a[idx], idx)); a[idx] -= num; if(a[idx] > 0) stone.insert(make_pair(a[idx], idx)); int er = lsb(num); auto it = stone.end(); it--; auto chosen = *it; stone.erase(it); a[chosen.second] -= er; int newVal = chosen.first - er; if(newVal > 0) stone.insert(make_pair(newVal, chosen.second)); cout << chosen.second + 1 << " " << er << endl; } cin >> ret; assert(ret == 0); }