algo — C++23 日本語リファレンス GitHub

test/yosupo/data_structure/point_set_range_frequency.test.cpp

AC · 最終更新 2026-10-23 · GitHub

問題: https://judge.yosupo.jp/problem/point_set_range_frequency

依存するヘッダ(7)
実装
// competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/point_set_range_frequency
#include <iostream>
#include <vector>
#include "data_structure/dynamic_wavelet_matrix.hpp"
#include "segtree/monoid.hpp"

int main(void) {
    int n, q;
    std::cin >> n >> q;
    std::vector<int> a(n);
    for (int &e : a) std::cin >> e;
    DynamicWaveletMatrix<int, 30> wm(a);
    while (q--) {
        int t;
        std::cin >> t;
        if (t == 0) {
            int k, v;
            std::cin >> k >> v;
            wm.erase(k);
            wm.insert(k, v);
        } else {
            int l, r, x;
            std::cin >> l >> r >> x;
            std::cout << wm.rank(l, r, x) << '\n';
        }
    }

    return 0;
}