結果

問題 No.1741 Arrays and XOR Procedure
ユーザー inksamuraiinksamurai
提出日時 2021-11-12 22:24:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,123 bytes
コンパイル時間 1,837 ms
コンパイル使用メモリ 173,152 KB
実行使用メモリ 18,944 KB
最終ジャッジ日時 2024-05-04 09:29:55
合計ジャッジ時間 4,103 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,760 KB
testcase_01 WA -
testcase_02 AC 3 ms
5,888 KB
testcase_03 AC 61 ms
18,944 KB
testcase_04 AC 5 ms
5,760 KB
testcase_05 AC 61 ms
18,688 KB
testcase_06 AC 63 ms
18,688 KB
testcase_07 AC 62 ms
18,688 KB
testcase_08 AC 60 ms
18,816 KB
testcase_09 AC 56 ms
17,144 KB
testcase_10 AC 56 ms
17,536 KB
testcase_11 AC 45 ms
14,848 KB
testcase_12 AC 37 ms
12,672 KB
testcase_13 AC 55 ms
16,640 KB
testcase_14 AC 40 ms
13,440 KB
testcase_15 AC 50 ms
16,128 KB
testcase_16 AC 7 ms
6,272 KB
testcase_17 AC 22 ms
9,472 KB
testcase_18 AC 41 ms
14,080 KB
testcase_19 AC 6 ms
6,124 KB
testcase_20 AC 59 ms
18,432 KB
testcase_21 AC 47 ms
15,360 KB
testcase_22 AC 43 ms
14,592 KB
testcase_23 AC 19 ms
8,960 KB
testcase_24 AC 8 ms
6,580 KB
testcase_25 AC 60 ms
18,412 KB
testcase_26 AC 28 ms
10,880 KB
testcase_27 WA -
testcase_28 AC 45 ms
14,976 KB
testcase_29 AC 51 ms
16,256 KB
testcase_30 AC 46 ms
14,848 KB
testcase_31 WA -
testcase_32 AC 28 ms
10,880 KB
testcase_33 AC 33 ms
12,160 KB
testcase_34 AC 14 ms
7,936 KB
testcase_35 WA -
testcase_36 AC 10 ms
6,656 KB
testcase_37 AC 26 ms
10,496 KB
testcase_38 AC 58 ms
18,176 KB
testcase_39 AC 22 ms
10,056 KB
testcase_40 AC 5 ms
5,888 KB
testcase_41 AC 13 ms
7,680 KB
testcase_42 AC 5 ms
6,124 KB
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

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>;

const int mxn=3e5+10;
mint fact[mxn+10];
void prefact(){
fact[0]=fact[1]=1;
  crep(i,2,mxn){
    mint x=i;
    fact[i]=fact[i-1]*x;
  }
}

mint cnk(ll k,ll n){
  if(k>n) return 0;
  mint e=fact[k]*fact[n-k];
  return fact[n] * e.inv();
}

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