結果
問題 |
No.1444 !Andd
|
ユーザー |
![]() |
提出日時 | 2023-09-05 05:21:50 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 95 ms / 2,000 ms |
コード長 | 1,023 bytes |
コンパイル時間 | 5,887 ms |
コンパイル使用メモリ | 308,172 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 01:52:07 |
合計ジャッジ時間 | 7,421 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include<bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using mint=modint998244353; //1000000007; using ll=long long; using pp=pair<ll,ll>; #define sr string #define vc vector #define fi first #define se second #define rep(i,n) for(ll i=0;i<(ll)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) int main(){ ll n;cin>>n; ll b=1<<10; vc<ll>dp(b,0),dx(b,0); dp[1]=1; ll over=0; rep(i,n){ ll a;cin>>a; vc<ll>pre(b,0),prex(b,0); swap(pre,dp); swap(prex,dx); if(a==0){ dp[0]=1; over=0; cout<<1<<"\n"; continue; } rep(j,b){ ll nj=j&a; if(pre[j]||prex[j])dp[nj]=1; nj=j*a; if(nj>=b){ if(pre[j])over++; if(pre[j]||prex[j])dx[nj&(b-1)]=1; } else{ if(pre[j])dp[nj]=1; if(prex[j])dx[nj]=1; } } ll ans=over; rep(j,b)ans+=dp[j]; cout<<ans<<"\n"; } }