結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー harady_a_humanharady_a_human
提出日時 2020-05-29 20:23:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 533 ms / 2,000 ms
コード長 1,584 bytes
コンパイル時間 1,950 ms
コンパイル使用メモリ 173,700 KB
実行使用メモリ 144,384 KB
最終ジャッジ日時 2024-04-23 19:15:42
合計ジャッジ時間 6,219 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 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 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 2 ms
5,376 KB
testcase_11 AC 313 ms
91,648 KB
testcase_12 AC 203 ms
56,064 KB
testcase_13 AC 435 ms
127,488 KB
testcase_14 AC 236 ms
71,424 KB
testcase_15 AC 98 ms
29,312 KB
testcase_16 AC 83 ms
23,296 KB
testcase_17 AC 17 ms
7,040 KB
testcase_18 AC 259 ms
74,368 KB
testcase_19 AC 264 ms
78,720 KB
testcase_20 AC 116 ms
31,360 KB
testcase_21 AC 518 ms
144,384 KB
testcase_22 AC 517 ms
144,256 KB
testcase_23 AC 533 ms
144,256 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define int long long
#define pb push_back
#define eb emplace_back
#define FOR(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int (i)=(a);(i)>=(int)(b);(i)--)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define UNIQUE(a) sort(all(a)), a.erase(unique(all(a)), a.end())
#define Double double
 
template<typename T> using pq = priority_queue<T,vector<T>,greater<T>>; 
using ll = long long;
using ld = long double;
ll mod = 1e9 + 7;

void solve() {
    mod = 998244353;
    int n, q; cin >> n >> q;
    vector<int> A(n); rep (i, n) cin >> A[i];
    sort(all(A));
    
    vector<int> left(n+1);
    vector<vector<int>> right(n+1);

    left[0] = 1;
    right[n] = {1};

    rep (i, n) left[i+1] = left[i] * A[i] % mod;
    rrep(i, n-1) {
        right[i].resize(right[i+1].size()+1);
        rep (j, right[i+1].size()) right[i][j] += (A[i]-1) * right[i+1][j] % mod, right[i][j+1] += right[i+1][j];
        rep (j, right[i].size()) right[i][j] %= mod;
    }

    rep (_, q) {
        int l, r, p; cin >> l >> r >> p;
        int ans = 0;
        FOR (i, l, r+1) {
            int idx = lower_bound(all(A), i) - A.begin();
            ans ^= left[idx]*(p>=right[idx].size()?0:right[idx][p]) % mod;
        }
        cout << ans << endl;
    }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
0