結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー ShibuyapShibuyap
提出日時 2020-05-29 22:46:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 368 ms / 2,000 ms
コード長 1,474 bytes
コンパイル時間 2,096 ms
コンパイル使用メモリ 198,860 KB
実行使用メモリ 285,440 KB
最終ジャッジ日時 2024-04-24 00:16:26
合計ジャッジ時間 5,629 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 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 1 ms
5,376 KB
testcase_11 AC 226 ms
180,224 KB
testcase_12 AC 146 ms
109,184 KB
testcase_13 AC 300 ms
251,520 KB
testcase_14 AC 167 ms
139,648 KB
testcase_15 AC 69 ms
55,680 KB
testcase_16 AC 59 ms
43,520 KB
testcase_17 AC 11 ms
11,264 KB
testcase_18 AC 181 ms
145,664 KB
testcase_19 AC 185 ms
154,496 KB
testcase_20 AC 88 ms
59,904 KB
testcase_21 AC 363 ms
285,312 KB
testcase_22 AC 368 ms
285,440 KB
testcase_23 AC 367 ms
285,312 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005

int main() {
    ll MOD = 998244353;
    ll n, q;
    cin >> n >> q;
    ll a[n], b[q];
    rep(i,n)cin >> a[i];
    sort(a,a+n,greater<ll>());
    ll aa[n];
    rep(i,n)aa[i] = a[n-1-i];

    ll dp[n][n+10];
    rep(i,n)rep(j,n+10)dp[i][j] = 0;

    rep(i,n){
        if(i == 0){
            dp[i][0] = a[i] - 1;
            dp[i][1] = 1;
        }else{
            rep(j,n+1){
                dp[i][j+1] = dp[i-1][j];
                if(j == 0){
                    dp[i][j] = (dp[i-1][j]*(a[i]-1)%MOD) % MOD;
                }else{
                    dp[i][j] = (dp[i-1][j]*(a[i]-1)%MOD + dp[i-1][j-1]) % MOD;
                }   
                
            }
        }
    }

    ll mul[n+1];
    mul[n] = 1;
    drep(i,n){
        mul[i] = mul[i+1] * a[i] % MOD;
    }

    rep(i,q){
        ll l,r,p;
        cin >> l >> r >> p;
        ll ans = 0;
        srep(j,l,r+1){
            ll cnt = n - (int)(lower_bound(aa,aa+n,j) - aa);
            // cout << j << ' ' << cnt << endl;
            ll tmp = dp[cnt-1][p] * mul[cnt] % MOD;
            // cout << tmp << endl;
            ans ^= tmp;
        }
        cout << ans << endl;
    }

    return 0;
}
 
 
0