結果

問題 No.1741 Arrays and XOR Procedure
ユーザー 夜
提出日時 2021-11-14 12:37:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,582 bytes
コンパイル時間 1,099 ms
コンパイル使用メモリ 97,796 KB
実行使用メモリ 10,552 KB
最終ジャッジ日時 2023-08-19 18:31:11
合計ジャッジ時間 5,885 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,424 KB
testcase_01 AC 14 ms
8,360 KB
testcase_02 AC 14 ms
8,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 44 ms
10,356 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
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 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 16 ms
8,404 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 26 ms
9,244 KB
testcase_40 AC 15 ms
8,352 KB
testcase_41 AC 21 ms
8,884 KB
testcase_42 AC 16 ms
8,604 KB
testcase_43 AC 15 ms
8,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
#include <fstream>
using namespace std;
long long fac[200020], finv[200020], inv[200020];
long long mod = 998244353;
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < 200020; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
long long COM(long long n, long long k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
long long a[200020];
int tco[200020];
vector<int> vec;
long long co = 0;
int main() {
	COMinit();
	long long n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		int co1 = 0, i1 = i;
		while (i1 % 2 == 0) {
			i1 /= 2;
			co1++;
		}
		tco[i] = co1;
	}
	int now = 0;
	vec.emplace_back(0);
	for (int i = 1; i <= n; i++) {
		now += tco[n - i + 1];
		now -= tco[i];
		if (now == 0) {
			vec.emplace_back(i);
		}
	}
	int x = 0;
	for (int i = 0; i < vec.size(); i++) {
		if (a[vec[i]] != -1) {
			x ^= a[vec[i]];
		}
		else {
			co++;
		}
	}
	long long ans = 0;
	if (x == 0) {
		for (int i = 1; i <= co; i += 2) {
			ans += COM(co, i);
			ans %= mod;
		}
	}
	else {
		for (int i = 0; i <= co; i += 2) {
			ans += COM(co, i);
			ans %= mod;
		}
	}
	cout << ans << endl;
}
0