結果
問題 | No.1741 Arrays and XOR Procedure |
ユーザー | auaua |
提出日時 | 2021-11-12 22:30:49 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 81 ms / 2,000 ms |
コード長 | 2,539 bytes |
コンパイル時間 | 1,620 ms |
コンパイル使用メモリ | 168,180 KB |
実行使用メモリ | 10,956 KB |
最終ジャッジ日時 | 2023-08-17 02:32:57 |
合計ジャッジ時間 | 6,154 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
8,040 KB |
testcase_01 | AC | 45 ms
8,240 KB |
testcase_02 | AC | 45 ms
8,264 KB |
testcase_03 | AC | 81 ms
10,892 KB |
testcase_04 | AC | 45 ms
8,372 KB |
testcase_05 | AC | 75 ms
10,904 KB |
testcase_06 | AC | 80 ms
10,896 KB |
testcase_07 | AC | 80 ms
10,956 KB |
testcase_08 | AC | 75 ms
10,864 KB |
testcase_09 | AC | 75 ms
10,648 KB |
testcase_10 | AC | 77 ms
10,940 KB |
testcase_11 | AC | 69 ms
9,832 KB |
testcase_12 | AC | 64 ms
9,316 KB |
testcase_13 | AC | 74 ms
10,368 KB |
testcase_14 | AC | 66 ms
9,728 KB |
testcase_15 | AC | 73 ms
10,044 KB |
testcase_16 | AC | 47 ms
8,240 KB |
testcase_17 | AC | 55 ms
8,524 KB |
testcase_18 | AC | 68 ms
9,792 KB |
testcase_19 | AC | 46 ms
8,216 KB |
testcase_20 | AC | 80 ms
10,912 KB |
testcase_21 | AC | 71 ms
10,160 KB |
testcase_22 | AC | 69 ms
9,896 KB |
testcase_23 | AC | 55 ms
8,512 KB |
testcase_24 | AC | 47 ms
8,440 KB |
testcase_25 | AC | 80 ms
10,636 KB |
testcase_26 | AC | 60 ms
9,104 KB |
testcase_27 | AC | 46 ms
8,224 KB |
testcase_28 | AC | 70 ms
9,908 KB |
testcase_29 | AC | 74 ms
10,320 KB |
testcase_30 | AC | 70 ms
9,920 KB |
testcase_31 | AC | 47 ms
8,392 KB |
testcase_32 | AC | 59 ms
9,072 KB |
testcase_33 | AC | 63 ms
9,444 KB |
testcase_34 | AC | 52 ms
8,412 KB |
testcase_35 | AC | 45 ms
8,120 KB |
testcase_36 | AC | 47 ms
8,068 KB |
testcase_37 | AC | 58 ms
9,200 KB |
testcase_38 | AC | 78 ms
10,788 KB |
testcase_39 | AC | 57 ms
8,728 KB |
testcase_40 | AC | 46 ms
8,136 KB |
testcase_41 | AC | 51 ms
8,312 KB |
testcase_42 | AC | 46 ms
8,252 KB |
testcase_43 | AC | 45 ms
8,076 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; #define int long long #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair #define endl '\n' //#define vec vector<ll> //#define mat vector<vector<ll> > #define fi first #define se second #define double long double typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll> pll; //typedef long double ld; typedef complex<double> Complex; const ll INF=1e9+7; const ll MOD=998244353; const ll inf=INF*INF; const ll mod=MOD; const ll MAX=200010; const double PI=acos(-1.0); typedef vector<vector<ll> > mat; typedef vector<ll> vec; //Combination long long extGCD(long long a,long long mod,long long &x,long long &y){ if(mod==0){ x=1; y=0; return a; } long long d=extGCD(mod,a%mod,y,x); y-=(a/mod)*x; return d; } long long invmod(long long a,long long mod){ long long x,y; extGCD(a,mod,x,y); x%=mod; if(x<0)x+=mod; return x; } ll fac[MAX],finv[MAX],inv[MAX]; void combinit(){ fac[0]=fac[1]=1; finv[0]=finv[1]=1; inv[1]=1; REP(i,2,MAX){ fac[i]=fac[i-1]*i%mod; inv[i]=invmod(i,mod); finv[i]=finv[i-1]*inv[i]%mod; } } ll comb(ll n,ll k){ if(n<k)return 0; if(n<0||k<0)return 0; return fac[n]*(finv[k]*finv[n-k]%mod)%mod; } //二分累乗 ll rui(ll a,ll b){ ll res=1; ll x=a; while(b){ if(b&1)res=res*x%mod; x=x*x%mod; b/=2; } return res; } void solve(){ combinit(); ll n;cin>>n; vector<ll>a(n); vector<ll>b(n); rep(i,n)cin>>b[i]; a[0]=1; ll cnta=0,cntb=0; REP(i,1,n){ ll x=n-i,y=i; while(x%2==0){ cnta++; x/=2; } while(y%2==0){ cntb++; y/=2; } if(cnta>cntb)a[i]=0; else a[i]=1; } ll cnt0=0,cnt1=0; ll xo=0; rep(i,n){ if(b[i]==0){ }else if(b[i]==1){ if(a[i])xo^=1; }else{ if(a[i]==0)cnt0++; else cnt1++; } } ll ans=rui(2,cnt0); ll sum=0; if(cnt1==0){ if(xo==0)ans=0; }else{ rep(i,cnt1+1){ if(i%2==xo)continue; sum=(sum+comb(cnt1,i))%mod; } ans=ans*sum%mod; } if(ans<0)ans+=mod; cout<<ans<<endl; } signed main(){ //cin.tie(0); //ios::sync_with_stdio(false); solve(); }