結果
| 問題 |
No.3120 Lower Nim
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-20 19:11:25 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,544 bytes |
| コンパイル時間 | 2,197 ms |
| コンパイル使用メモリ | 195,536 KB |
| 実行使用メモリ | 26,356 KB |
| 平均クエリ数 | 2400.68 |
| 最終ジャッジ日時 | 2025-04-20 19:11:37 |
| 合計ジャッジ時間 | 10,986 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 39 RE * 4 |
ソースコード
#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;
if((x & 1) == 1){
for (int i = 0; i < n; i++) {
if(a[i] >= 1){
sel = i;
take = 1;
break;
}
}
}
else{
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] -= take;
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();
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;
}
}
}
cout << (sel + 1) << " " << take << "\n" << flush;
a[sel] -= take;
k = take;
cin >> ret;
if (ret != 0) return 0;
}
}
return 0;
}