結果

問題 No.1067 #いろいろな色 / Red and Blue and more various colors (Middle)
ユーザー sten_sansten_san
提出日時 2021-06-20 19:47:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 304 ms / 2,000 ms
コード長 1,750 bytes
コンパイル時間 2,293 ms
コンパイル使用メモリ 210,912 KB
実行使用メモリ 144,084 KB
最終ジャッジ日時 2023-09-05 01:33:29
合計ジャッジ時間 6,380 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 191 ms
91,480 KB
testcase_12 AC 122 ms
55,880 KB
testcase_13 AC 254 ms
127,060 KB
testcase_14 AC 141 ms
71,080 KB
testcase_15 AC 59 ms
29,192 KB
testcase_16 AC 53 ms
23,348 KB
testcase_17 AC 11 ms
6,932 KB
testcase_18 AC 151 ms
74,080 KB
testcase_19 AC 155 ms
78,472 KB
testcase_20 AC 74 ms
31,324 KB
testcase_21 AC 304 ms
143,996 KB
testcase_22 AC 303 ms
143,960 KB
testcase_23 AC 304 ms
144,084 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

struct iofast_t {
    iofast_t() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} iofast;

struct uns_t {} uns;
template <typename Element, typename Head, typename ...Args>
auto vec(Element init, Head arg, Args ...args) {
    if constexpr (sizeof...(Args) == 0) return std::vector(arg, init);
    else return std::vector(arg, vec(init, args...));
}
template <typename Element, typename Head, typename ...Args>
auto vec(uns_t, Head arg, Args ...args) {
    return vec(Element(), arg, args...);
}

template <typename T, typename Compare = less<T>>
T &chmin(T &l, T r, Compare &&f = less<T>()) { return l = min(l, r, f); }
template <typename T, typename Compare = less<T>>
T &chmax(T &l, T r, Compare &&f = less<T>()) { return l = max(l, r, f); }

#include <atcoder/modint>
using mint = atcoder::modint998244353;

int main() {
    int n, q; cin >> n >> q;
    auto a = vec<int>(uns, n);
    for (auto &e : a) cin >> e;
    sort(begin(a), end(a));

    auto acc = vec<mint>(uns, n + 1);

    acc[0] = 1;
    for (int i = 0; i < n; ++i) {
        acc[i + 1] = acc[i] * a[i];
    }

    auto dp = vec<mint>(uns, n + 1, n + 1);

    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            dp[i][j] = (a[n - i] - 1) * dp[i - 1][j];
            if (0 < j) {
                dp[i][j] += dp[i - 1][j - 1];
            }
        }
    }

    while (q--) {
        int l, r, p; cin >> l >> r >> p;

        int ans = 0;
        for (int i = l; i <= r; ++i) {
            int d = n - distance(begin(a), lower_bound(begin(a), end(a), i));
            ans ^= (acc[n - d] * dp[d][p]).val();
        }

        cout << mint(ans).val() << endl;
    }
}

0