結果

問題 No.2538 2進元ゲーム
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-11-10 22:55:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 763 bytes
コンパイル時間 2,371 ms
コンパイル使用メモリ 201,652 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-10 22:55:41
合計ジャッジ時間 4,091 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 3 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 WA -
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 1 ms
6,676 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 3 ms
6,676 KB
testcase_30 AC 11 ms
6,676 KB
testcase_31 AC 91 ms
6,676 KB
testcase_32 AC 121 ms
6,676 KB
testcase_33 AC 117 ms
6,676 KB
testcase_34 AC 99 ms
6,676 KB
testcase_35 AC 93 ms
6,676 KB
testcase_36 AC 86 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
	}
}
0