結果
問題 |
No.2538 2進元ゲーム
|
ユーザー |
![]() |
提出日時 | 2023-11-24 12:24:03 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 110 ms / 2,000 ms |
コード長 | 1,039 bytes |
コンパイル時間 | 2,075 ms |
コンパイル使用メモリ | 201,524 KB |
最終ジャッジ日時 | 2025-02-17 23:37:25 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 37 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); int n; cin >> n; vector<long long> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<int> grundy(65); for (int i = 1; i < 65; i++) { set<int> st; for (int j = 0; j < 65; j++) { if (i & (1LL << j)) { st.insert(grundy[j]); } } while (st.count(grundy[i])) { grundy[i]++; } } int ans = 0; int neg_cnt = 0; for (int i = 0; i < n; i++) { if (a[i] < 0) { neg_cnt++; continue; } set<int> st; for (int j = 0; j <= 64; j++) { if (a[i] & (1LL << j)) { st.insert(grundy[j]); } } int tmp = 0; while (st.count(tmp)) { tmp++; } ans ^= tmp; } cout << (ans || neg_cnt % 2 ? 1 : 2) << endl; }