結果
| 問題 | 
                            No.3120 Lower Nim
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2025-04-20 04:00:51 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,174 bytes | 
| コンパイル時間 | 2,408 ms | 
| コンパイル使用メモリ | 195,880 KB | 
| 実行使用メモリ | 25,972 KB | 
| 平均クエリ数 | 2201.20 | 
| 最終ジャッジ日時 | 2025-04-20 04:01:03 | 
| 合計ジャッジ時間 | 9,122 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 37 WA * 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;
                    }
                }
            }
            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;
}