結果

問題 No.1741 Arrays and XOR Procedure
ユーザー inksamuraiinksamurai
提出日時 2021-11-12 22:42:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 2,060 bytes
コンパイル時間 2,245 ms
コンパイル使用メモリ 172,244 KB
実行使用メモリ 15,080 KB
最終ジャッジ日時 2023-08-17 02:59:21
合計ジャッジ時間 4,363 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 50 ms
14,808 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 39 ms
15,080 KB
testcase_06 AC 48 ms
14,796 KB
testcase_07 AC 48 ms
14,840 KB
testcase_08 AC 39 ms
14,844 KB
testcase_09 AC 45 ms
13,320 KB
testcase_10 AC 46 ms
13,572 KB
testcase_11 AC 34 ms
11,224 KB
testcase_12 AC 28 ms
9,424 KB
testcase_13 AC 42 ms
13,060 KB
testcase_14 AC 29 ms
10,120 KB
testcase_15 AC 43 ms
12,440 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 16 ms
6,472 KB
testcase_18 AC 31 ms
10,620 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 49 ms
14,540 KB
testcase_21 AC 38 ms
11,748 KB
testcase_22 AC 35 ms
10,948 KB
testcase_23 AC 15 ms
6,160 KB
testcase_24 AC 4 ms
4,380 KB
testcase_25 AC 49 ms
14,316 KB
testcase_26 AC 22 ms
7,740 KB
testcase_27 AC 4 ms
4,380 KB
testcase_28 AC 38 ms
11,420 KB
testcase_29 AC 40 ms
12,436 KB
testcase_30 AC 36 ms
11,288 KB
testcase_31 AC 4 ms
4,380 KB
testcase_32 AC 21 ms
7,836 KB
testcase_33 AC 27 ms
8,840 KB
testcase_34 AC 10 ms
5,152 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 6 ms
4,380 KB
testcase_37 AC 20 ms
7,476 KB
testcase_38 AC 46 ms
13,932 KB
testcase_39 AC 16 ms
7,252 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 9 ms
4,844 KB
testcase_42 AC 3 ms
4,380 KB
testcase_43 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3pPbCt8 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<int,int>;
using vi=vector<int>;

//snuke's modular int
template <ll mod>
struct modularint{
	ll x;
	modularint(ll x=0):x(x%mod){}
	modularint& operator+=(const modularint a){
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	modularint& operator-=(const modularint a){
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	modularint& operator*=(const modularint a){
		(x *= a.x) %= mod;
		return *this;
	}
	modularint operator+(const modularint a)const{
		modularint res(*this);
		return res+=a;
	}
	modularint operator-(const modularint a)const{
		modularint res(*this);
		return res-=a;
	}
	modularint operator*(const modularint a)const{
		modularint res(*this);
		return res*=a;
	}
	modularint pow(ll n)const{
		modularint res=1,x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}
	modularint inv()const{
		return pow(mod-2);
	}
};
using mint=modularint<998244353>;

//https://cp-algorithms.com/combinatorics/binomial-coefficients.html
//https://en.wikipedia.org/wiki/Lucas's_theorem

ll cenk(ll x,ll y) {
	if(x==y or x==0) return 1;
	if(x>y) return 0;
	return cenk(x-1,y)+cenk(x-1,y-1);
}

ll cnk(ll k , ll n){
	if(k>n) return 0;
	ll c=1;
	while(n>0) {
		c *= cenk(k%2,n%2);
		c%=2;
		n/=2; k/=2;
	}
	return c;
}

int main(){
_3pPbCt8;
// prefact();
	int n;
	cin>>n;
	vi a(n);
	rep(i,n){
		cin>>a[i];
	}
	vec(vec(mint)) dp(n+1,vec(mint)(2,0));
	dp[0][0]=1;
	rep(i,n){
		rep(x,2){
			if(a[i]!=-1) x=a[i];
			int e=x*cnk(i,n-1)%2;
			e%=2;
			rep(ox,2){
				dp[i+1][(e+ox)%2]+=dp[i][ox];
			}
			if(a[i]!=-1) break;
		}
	}
	cout<<dp[n][1].x<<"\n";
//	
	return 0;
}
0