結果

問題 No.1741 Arrays and XOR Procedure
ユーザー otoshigootoshigo
提出日時 2024-03-30 01:29:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 903 bytes
コンパイル時間 2,419 ms
コンパイル使用メモリ 205,240 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-03-30 01:29:10
合計ジャッジ時間 5,947 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
9,216 KB
testcase_01 AC 10 ms
9,216 KB
testcase_02 AC 10 ms
9,216 KB
testcase_03 AC 25 ms
10,752 KB
testcase_04 AC 10 ms
9,216 KB
testcase_05 AC 23 ms
10,752 KB
testcase_06 AC 27 ms
10,752 KB
testcase_07 AC 27 ms
10,752 KB
testcase_08 AC 23 ms
10,752 KB
testcase_09 AC 24 ms
10,624 KB
testcase_10 AC 25 ms
10,624 KB
testcase_11 AC 22 ms
10,368 KB
testcase_12 AC 19 ms
10,112 KB
testcase_13 AC 24 ms
10,496 KB
testcase_14 AC 20 ms
10,112 KB
testcase_15 AC 23 ms
10,496 KB
testcase_16 AC 10 ms
9,344 KB
testcase_17 AC 14 ms
9,728 KB
testcase_18 AC 21 ms
10,240 KB
testcase_19 AC 10 ms
9,344 KB
testcase_20 AC 26 ms
10,752 KB
testcase_21 AC 23 ms
10,368 KB
testcase_22 AC 21 ms
10,240 KB
testcase_23 AC 14 ms
9,600 KB
testcase_24 AC 10 ms
9,344 KB
testcase_25 AC 26 ms
10,752 KB
testcase_26 AC 17 ms
9,856 KB
testcase_27 AC 11 ms
9,344 KB
testcase_28 AC 21 ms
10,368 KB
testcase_29 AC 23 ms
10,496 KB
testcase_30 AC 22 ms
10,368 KB
testcase_31 AC 12 ms
9,344 KB
testcase_32 AC 17 ms
9,856 KB
testcase_33 AC 18 ms
9,984 KB
testcase_34 AC 13 ms
9,472 KB
testcase_35 AC 10 ms
9,216 KB
testcase_36 AC 11 ms
9,344 KB
testcase_37 AC 16 ms
9,856 KB
testcase_38 AC 25 ms
10,752 KB
testcase_39 AC 16 ms
9,728 KB
testcase_40 AC 10 ms
9,216 KB
testcase_41 AC 13 ms
9,472 KB
testcase_42 AC 11 ms
9,344 KB
testcase_43 AC 10 ms
9,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;

const int MOD=998244353;
const int MAX=250'000;
vector<ll>fac(MAX),finv(MAX),inv(MAX);

void set_fac(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2;i<MAX;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;
    }
}

ll cmb(int n,int r){
    if (r<0||n<r)return 0;
    return fac[n]*(finv[r]*finv[n-r]%MOD)%MOD;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	set_fac();
	int N;
	cin>>N;
	vector<int>B(N),C(N);
	for(int i=0;i<N;i++){
		cin>>B[i];
		if(((N-1)&i)==i)C[i]=1;
	}
	int X=1,c0=0,c1=0;
	for(int i=0;i<N;i++){
		if(B[i]==-1){
			if(C[i]==0)c0++;
			else c1++;
		}else{
			X=(X+B[i]*C[i])%2;
		}
	}
	ll ans=0;
	for(int i=X;i<=c1;i+=2)ans=(ans+cmb(c1,i))%MOD;
	for(int i=0;i<c0;i++)ans=(2*ans)%MOD;
	cout<<ans<<"\n";
}
0