結果

問題 No.2171 OR Assignment
ユーザー 👑 chro_96chro_96
提出日時 2022-12-23 02:24:51
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,221 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 30,336 KB
実行使用メモリ 50,304 KB
最終ジャッジ日時 2024-04-29 05:54:05
合計ジャッジ時間 6,692 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
50,304 KB
testcase_01 AC 38 ms
50,176 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 37 ms
50,304 KB
testcase_05 AC 37 ms
50,176 KB
testcase_06 AC 36 ms
50,304 KB
testcase_07 AC 36 ms
50,176 KB
testcase_08 AC 36 ms
50,304 KB
testcase_09 WA -
testcase_10 AC 37 ms
50,304 KB
testcase_11 AC 36 ms
50,304 KB
testcase_12 AC 308 ms
50,176 KB
testcase_13 AC 310 ms
50,304 KB
testcase_14 AC 310 ms
50,304 KB
testcase_15 AC 167 ms
50,304 KB
testcase_16 WA -
testcase_17 AC 195 ms
50,304 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 281 ms
50,304 KB
testcase_25 AC 265 ms
50,304 KB
testcase_26 AC 251 ms
50,304 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 305 ms
50,176 KB
testcase_31 AC 214 ms
50,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int cmp_int (const void *ap, const void *bp) {
  int a = *(int *)ap;
  int b = *(int *)bp;
  
  if (a < b) {
    return -1;
  }
  
  if (a > b) {
    return 1;
  }
  
  return 0;
}

int main () {
  int n = 0;
  int a = 0;
  
  int res = 0;
  
  long long dp[200001][31] = {};
  long long mod_num = 998244353LL;
  
  int prev[30] = {};
  
  res = scanf("%d", &n);
  
  dp[0][30] = 1LL;
  for (int i = 0; i < n; i++) {
    int prev_sort[31][2] = {};
    res = scanf("%d", &a);
    for (int j = 0; j < 30; j++) {
      if ((a&(1<<j)) > 0) {
        dp[i+1][j] = dp[i][30];
        prev[j] = i+1;
      } else {
        dp[i+1][j] = dp[i][j];
      }
      prev_sort[j][0] = prev[j];
      prev_sort[j][1] = j;
    }
    prev_sort[30][0] = -1;
    qsort(prev_sort, 31, sizeof(int)*2, cmp_int);
    dp[i+1][30] = 0LL;
    for (int j = 0; j < 30; j++) {
      if (prev_sort[j][0] != prev_sort[j+1][0]) {
        dp[i+1][30] += dp[i+1][prev_sort[j+1][1]];
        dp[i+1][30] %= mod_num;
      }
      dp[i+1][prev_sort[j+1][1]] = dp[i+1][30];
    }
    if (a == 0) {
      dp[i+1][30] = dp[i][30];
      dp[i+1][30] %= mod_num;
    }
  }
  
  printf("%lld\n", dp[n][30]);
  return 0;
}

0