結果

問題 No.2171 OR Assignment
ユーザー 👑 tute7627tute7627
提出日時 2022-11-20 20:20:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 988 bytes
コンパイル時間 4,164 ms
コンパイル使用メモリ 227,616 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-04-29 05:10:42
合計ジャッジ時間 9,716 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 143 ms
5,376 KB
testcase_13 AC 143 ms
5,376 KB
testcase_14 AC 139 ms
5,376 KB
testcase_15 AC 31 ms
5,376 KB
testcase_16 AC 38 ms
5,376 KB
testcase_17 AC 47 ms
5,376 KB
testcase_18 TLE -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace std;


int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<atcoder::modint998244353> dp(N);
  dp[0] = 1;
  atcoder::modint998244353 all = 1;
  vector<int> prev(30, -1);
  for(int i = 0; i < N; i++){
    for(int j = 0; j < 30; j++){
      if(A[i] >> j & 1){
        prev[j] = i;
      }
    }
    auto idx = prev;
    sort(idx.begin(), idx.end());
    idx.erase(unique(idx.begin(), idx.end()), idx.end());
    atcoder::modint998244353 rem = all;
    int r = i;
    for(int j = (int)idx.size() - 1; j >= 0; j--){
      if(idx[j] != i && idx[j] != -1){
        while(idx[j] < r){
          rem -= dp[r--];
        }
        dp[idx[j] + 1] += rem;
        all += rem;
      }
    }
  }
  cout << all.val() << endl; 
}
0