結果
問題 |
No.3120 Lower Nim
|
ユーザー |
|
提出日時 | 2025-04-20 03:46:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,258 bytes |
コンパイル時間 | 1,840 ms |
コンパイル使用メモリ | 195,748 KB |
実行使用メモリ | 26,356 KB |
平均クエリ数 | 2201.07 |
最終ジャッジ日時 | 2025-04-20 03:46:53 |
合計ジャッジ時間 | 9,481 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 37 RE * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int k = 1e9; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } auto calc_xor = [&]() { int x = 0; for (int v : a) x ^= v; return x; }; int x = calc_xor(); if (x != 0) { cout << "First" << "\n" << flush; while (true) { x = calc_xor(); int sel = -1, take = 0; for (int i = 0; i < n; i++) { int target = a[i] ^ x; if (target < a[i]) { int need = a[i] - target; if (need <= k) { sel = i; take = need; break; } } } assert(sel != -1); cout << (sel + 1) << " " << take << "\n" << flush; a[sel] ^= x; k = take; int ret; if (!(cin >> ret)) return 0; if (ret != 0) return 0; int j, y; cin >> j >> y; if (j < 1 || j > n) return 0; a[j - 1] -= y; k = y; cin >> ret; if (ret != 0) return 0; } } else { cout << "Second" << "\n" << flush; while (true) { int j, y; cin >> j >> y; if (j < 1 || j > n) return 0; a[j - 1] -= y; k = y; int ret; cin >> ret; if (ret != 0) return 0; x = calc_xor(); assert(x != 0); int sel = -1, take = 0; for (int i = 0; i < n; i++) { int target = a[i] ^ x; if (target < a[i]) { int need = a[i] - target; if (need <= k) { sel = i; take = need; break; } } } assert(sel != -1); cout << (sel + 1) << " " << take << "\n" << flush; a[sel] ^= x; k = take; cin >> ret; if (ret != 0) return 0; } } return 0; }