結果
問題 | No.1741 Arrays and XOR Procedure |
ユーザー |
![]() |
提出日時 | 2021-11-12 22:24:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,123 bytes |
コンパイル時間 | 1,574 ms |
コンパイル使用メモリ | 173,760 KB |
実行使用メモリ | 18,844 KB |
最終ジャッジ日時 | 2024-11-25 19:30:11 |
合計ジャッジ時間 | 4,381 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 37 WA * 4 |
ソースコード
#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; }