結果
問題 |
No.2538 2進元ゲーム
|
ユーザー |
|
提出日時 | 2023-11-10 22:55:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 763 bytes |
コンパイル時間 | 1,852 ms |
コンパイル使用メモリ | 194,160 KB |
最終ジャッジ日時 | 2025-02-17 21:20:14 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; ll gr[66]; ll grundy(ll a) { if (a == 0) { return gr[0] = 0; } if (a < 0) { a *= -1; return (a & 1 ? (ll)1e18 : 0ll); } if (a < 60 && gr[a] != -1) { return gr[a]; } int A[66]; fill(A, A + 66, 0); for (int i = 0; i < 60; i ++) { if ((a >> i) & 1) { A[grundy(i)] = 1; } } int ret = 0; while (A[ret]) ret ++; if (a < 60) { gr[a] = ret; } return ret; } int main () { fill(gr, gr + 60, -1); int N; cin >> N; ll xx = 0; int cnt = 0; for (int i = 0; i < N; i ++) { ll a; cin >> a; if (a < 0 && (abs(a) & 1)) { cnt ++; } xx ^= grundy(a); // ex = ex || (xx > 100); } if (cnt > 1) { cout << 0 << endl; } else { cout << (xx ? 1 : 2) << endl; } }