結果

問題 No.1444 !Andd
ユーザー chocoruskchocorusk
提出日時 2021-03-26 22:13:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 1,748 bytes
コンパイル時間 3,483 ms
コンパイル使用メモリ 187,224 KB
実行使用メモリ 43,688 KB
最終ジャッジ日時 2023-08-19 08:38:27
合計ジャッジ時間 6,169 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 36 ms
14,556 KB
testcase_04 AC 24 ms
10,908 KB
testcase_05 AC 46 ms
23,040 KB
testcase_06 AC 27 ms
11,312 KB
testcase_07 AC 23 ms
10,644 KB
testcase_08 AC 60 ms
20,064 KB
testcase_09 AC 37 ms
14,716 KB
testcase_10 AC 31 ms
15,900 KB
testcase_11 AC 37 ms
19,260 KB
testcase_12 AC 74 ms
23,944 KB
testcase_13 AC 103 ms
32,216 KB
testcase_14 AC 55 ms
27,020 KB
testcase_15 AC 99 ms
31,492 KB
testcase_16 AC 147 ms
43,560 KB
testcase_17 AC 104 ms
43,548 KB
testcase_18 AC 150 ms
43,476 KB
testcase_19 AC 149 ms
43,472 KB
testcase_20 AC 149 ms
43,488 KB
testcase_21 AC 149 ms
43,688 KB
testcase_22 AC 149 ms
43,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
bool dp[2][20020][1024];
int main()
{
   int n; cin>>n;
    int a[20020];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    const int mask=1023;
    dp[0][0][1]=1;
    for(int i=0; i<n; i++){
        for(int j=0; j<1024; j++){
            dp[1][i+1][(j*a[i])&mask]|=(dp[0][i][j]|dp[1][i][j]);
            dp[0][i+1][j&a[i]]|=(dp[0][i][j]|dp[1][i][j]);
        }
    }
    bool ok[1024]={};
    ok[1]=1;
    int cnt=0;
    for(int i=0; i<n; i++){
        if(a[i]==0){
            for(int j=i; j<n; j++){
                cout<<1<<endl;
            }
            return 0;
        }
        bool ok1[1024]={};
        for(int j=0; j<1024; j++){
            if(ok[j]){
                if(j*a[i]>=1024){
                    cnt++;
                }else{
                    ok1[a[i]*j]=1;
                }
            }
        }
        for(int j=0; j<1024; j++){
            ok[j]=ok1[j];
        }
        int ans=cnt;
        for(int j=0; j<1024; j++){
            if(dp[0][i+1][j]) ok[j]=1;
            if(ok[j]){
                ans++;
                //cout<<j<<" ";
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}
0