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

test/aoj/dsl/range_search.test.cpp

AC · 最終更新 2026-07-24 · GitHub

問題: https://onlinejudge.u-aizu.ac.jp/problems/DSL_2_C

依存するヘッダ(1)
実装
// competitive-verifier: PROBLEM https://onlinejudge.u-aizu.ac.jp/problems/DSL_2_C
#include <algorithm>
#include <iostream>
#include "geometry/kdtree.hpp"

int main(void) {
    int n;
    std::cin >> n;
    kdtree kd;
    while (n--) {
        int x, y;
        std::cin >> x >> y;
        kd.add(x, y);
    }
    kd.build();

    int q;
    std::cin >> q;
    while (q--) {
        int sx, tx, sy, ty;
        std::cin >> sx >> tx >> sy >> ty;
        auto v = kd.find(sx, tx + 1, sy, ty + 1);
        std::sort(v.begin(), v.end());
        for (auto e : v) std::cout << e << '\n';
        std::cout << '\n';
    }

    return 0;
}