結果
問題 |
No.1741 Arrays and XOR Procedure
|
ユーザー |
![]() |
提出日時 | 2021-11-12 22:42:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 2,060 bytes |
コンパイル時間 | 1,541 ms |
コンパイル使用メモリ | 174,044 KB |
実行使用メモリ | 14,976 KB |
最終ジャッジ日時 | 2024-11-25 20:21:34 |
合計ジャッジ時間 | 3,720 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#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; }