結果
問題 |
No.2538 2進元ゲーム
|
ユーザー |
|
提出日時 | 2023-11-10 23:40:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 134 ms / 2,000 ms |
コード長 | 1,177 bytes |
コンパイル時間 | 2,204 ms |
コンパイル使用メモリ | 201,188 KB |
最終ジャッジ日時 | 2025-02-17 21:30:11 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 37 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<long long> A(N); for(auto &a : A) cin >> a; vector<long long> grundy(61); for(int i=1; i<=60; i++){ vector<int> appear; for(int k=0; k<6; k++){ if(i&(1<<k)) appear.push_back(grundy.at(k)); } sort(appear.begin(),appear.end()); int now = 0; for(auto ap : appear){ if(ap > now) break; if(ap == now) now++; } grundy.at(i) = now; } int minus = 0,xora = 0; for(int i=0; i<N; i++){ long long a = A.at(i); if(a < 0){minus++; continue;} if(a == 0) continue; vector<int> appear; for(int k=0; k<60; k++){ if(a&(1LL<<k)) appear.push_back(grundy.at(k)); } sort(appear.begin(),appear.end()); int now = 0; for(auto ap : appear){ if(ap > now) break; if(ap == now) now++; } xora ^= now; } if(xora == 0 && minus%2 == 0) cout << 2 << endl; else cout << 1 << endl; }