結果
問題 |
No.3120 Lower Nim
|
ユーザー |
|
提出日時 | 2025-04-24 14:44:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,528 bytes |
コンパイル時間 | 2,259 ms |
コンパイル使用メモリ | 196,428 KB |
実行使用メモリ | 26,356 KB |
平均クエリ数 | 1060.30 |
最終ジャッジ日時 | 2025-04-24 14:44:18 |
合計ジャッジ時間 | 10,228 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 26 WA * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; using int64 = long long; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N; // 山の個数 if(!(cin >> N)) return 0; vector<int64> A(N); for(auto &v:A) cin >> v; auto xor_all = [&]{ int64 x=0; for(auto v:A) x ^= v; return x; }; int64 nim = xor_all(); if(nim==0){ cout << "Second" << endl << flush; }else{ cout << "First" << endl << flush; int64 K = (int64)4e18; // 十分大きい値で代用 while(true){ /* ---------- 自分の手番 ---------- */ // 現在の L int64 L = 1; while(L <= K) L <<= 1; nim = xor_all(); // 必ず ≠0 int choose = -1; int64 x = 0; for(int i=0;i<N;i++){ int64 tgt = A[i] ^ nim; if(tgt < A[i]){ int64 diff = A[i] - tgt; if(diff<=K){ choose=i; x=diff; break; } } } cout << choose+1 << " " << x << endl << flush; A[choose] -= x; K = x; int ret; if(!(cin >> ret)) return 0; if(ret==1 || ret==-1) return 0; // 勝敗確定 /* ---------- ジャッジ手番 ---------- */ int idx; int64 y; cin >> idx >> y; --idx; A[idx] -= y; K = y; cin >> ret; if(ret==1 || ret==-1) return 0; } } }