結果

問題 No.2171 OR Assignment
ユーザー lddlinanlddlinan
提出日時 2023-03-28 15:38:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 358 ms / 3,500 ms
コード長 1,339 bytes
コンパイル時間 883 ms
コンパイル使用メモリ 92,752 KB
実行使用メモリ 54,860 KB
最終ジャッジ日時 2023-10-20 09:54:54
合計ジャッジ時間 7,105 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,396 KB
testcase_01 AC 2 ms
7,396 KB
testcase_02 AC 2 ms
7,396 KB
testcase_03 AC 2 ms
7,396 KB
testcase_04 AC 3 ms
7,396 KB
testcase_05 AC 3 ms
7,396 KB
testcase_06 AC 2 ms
7,396 KB
testcase_07 AC 2 ms
7,396 KB
testcase_08 AC 2 ms
7,396 KB
testcase_09 AC 3 ms
7,396 KB
testcase_10 AC 2 ms
7,396 KB
testcase_11 AC 2 ms
7,400 KB
testcase_12 AC 96 ms
54,860 KB
testcase_13 AC 95 ms
54,860 KB
testcase_14 AC 96 ms
54,860 KB
testcase_15 AC 42 ms
54,856 KB
testcase_16 AC 51 ms
54,856 KB
testcase_17 AC 52 ms
54,856 KB
testcase_18 AC 211 ms
54,860 KB
testcase_19 AC 201 ms
54,860 KB
testcase_20 AC 312 ms
54,860 KB
testcase_21 AC 326 ms
54,860 KB
testcase_22 AC 352 ms
54,860 KB
testcase_23 AC 277 ms
54,860 KB
testcase_24 AC 356 ms
54,860 KB
testcase_25 AC 358 ms
54,860 KB
testcase_26 AC 353 ms
54,860 KB
testcase_27 AC 328 ms
54,860 KB
testcase_28 AC 331 ms
54,860 KB
testcase_29 AC 307 ms
54,860 KB
testcase_30 AC 285 ms
54,860 KB
testcase_31 AC 350 ms
54,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;
class mypcmp {
public:
    bool operator()(const int& a, const int& b) {
        return a<b;
    }
};



int as[200004];
int dp[200004][32];
int can[200004][32];
int cc[200004];
#define MOD 998244353
int xx[32];
int main() {
    int n, i, j, c, s, k, v;
    set<int> ss;
    scanf("%d", &n);
    for (i=0; i<n; i++) scanf("%d", &as[i]);
    c=0;  xx[c++]=0;
    for (i=0; i<n; i++) {
        cc[i]=c; for (j=0; j<c; j++) can[i][j]=xx[j];
        ss.clear();
        for (j=0; j<c; j++) ss.insert(xx[j]|as[i]); ss.insert(as[i]);
        c=0; for (auto x: ss) xx[c++]=x;
    }
    cc[i]=c; for (j=0; j<c; j++) can[i][j]=xx[j];
    for (j=0; j<c; j++) dp[n][j]=1;
    for (i=n-1; i>=0; i--) {
        s=0;
        for (j=0, k=0; j<cc[i]; j++) {
            v=can[i][j]|as[i];
            while(k<cc[i+1]&&(can[i+1][k]&v)==can[i+1][k]) {
                s+=dp[i+1][k]; k++;
                s%=MOD;
            }
            dp[i][j]=s;
        }
    }
    printf("%d\n", dp[0][0]);
    return 0;
}
0