結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー m-44m-44
提出日時 2020-05-29 22:29:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 999 bytes
コンパイル時間 1,381 ms
コンパイル使用メモリ 163,844 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-04-23 23:27:35
合計ジャッジ時間 4,945 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int a[6000];
int n;
long long mod = 998244353;
void solve(int l, int r, int p) {
  long long dp[r-l+1][n+1];
  for (int i=0; i<=r-l; i++) {
    for (int j=0; j<=n; j++) {
      dp[i][j] = 0;
    }
  }
  for (int i=0; i<=r-l; i++) {
    dp[i][0] = 1;
  }
  for (int i=0; i<n; i++) {
    for (int k=l; k<=r; k++) {
      if (k > a[i]) {
        dp[k-l][0] = dp[k-l][0] * a[i];
        dp[k-l][0] %= mod;
        continue;
      }
      for (int j=n; j>=1; j--) {
        dp[k-l][j] = dp[k-l][j] * (a[i] - 1);
        dp[k-l][j] %= mod;
        dp[k-l][j] += dp[k-l][j-1];
        dp[k-l][j] %= mod;
      }
      dp[k-l][0] = dp[k-l][0] * (a[i] - 1);
      dp[k-l][0] %= mod;
    }
  }
  long long ans = 0;
  for (int i=0; i<=r-l; i++) {
    ans ^= dp[i][p];
  }
  cout<<ans<<endl;
}
int main() {
  int q;
  cin>>n>>q;
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  for (int i=0; i<q; i++) {
    int l, r, p;
    cin>>l>>r>>p;
    solve(l, r, p);
  }
}
0