結果

問題 No.2538 2進元ゲーム
ユーザー Aeren
提出日時 2023-11-10 23:09:29
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,417 bytes
コンパイル時間 3,398 ms
コンパイル使用メモリ 261,320 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-26 02:11:20
合計ジャッジ時間 5,017 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
using namespace numbers;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int n;
	cin >> n;
	vector<long long> a(n);
	copy_n(istream_iterator<long long>(cin), n, a.begin());
	vector<int> dp(62);
	auto grundy = [&](long long x)->int{
		vector<int> found;
		if(x >= 0){
			for(auto y = 0; 1LL << y <= x; ++ y){
				if(x & 1LL << y){
					found.push_back(dp[y]);
				}
			}
		}
		else{
			found = {0, 2, 3};
			for(auto y = 0; y < 62; ++ y){
				if(x & 1LL << y){
					found.push_back(dp[y]);
				}
			}
		}
		ranges::sort(found);
		found.erase(unique(found.begin(), found.end()), found.end());
		found.push_back(1e9);
		int res = 0;
		while(res == found[res]){
			++ res;
		}
		return res;
	};
	for(auto x = 1; x < 62; ++ x){
		dp[x] = grundy(x);
	}
	int g = 0;
	for(auto x: a){
		g ^= grundy(x);
	}
	g ? cout << "1\n" : cout << "2\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////
0