結果
問題 | No.1741 Arrays and XOR Procedure |
ユーザー |
![]() |
提出日時 | 2021-11-12 22:05:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,755 bytes |
コンパイル時間 | 1,449 ms |
コンパイル使用メモリ | 172,688 KB |
実行使用メモリ | 14,976 KB |
最終ジャッジ日時 | 2024-11-25 18:41:54 |
合計ジャッジ時間 | 3,378 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 WA * 10 |
ソースコード
#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>; int main(){ _3pPbCt8; 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(ox,2){ int now; rep(x,2){ if(a[i]!=-1) x=a[i]; if(i==0 or i==n-1) now=x; else now=(((n-1)%2)*x)%2; dp[i+1][(ox+now)%2]+=dp[i][ox]; if(a[i]!=-1) break; } } } mint ans=dp[n][1]; cout<<ans.x<<"\n"; // return 0; }