test/yosupo/data_structure/segment_add_get_min.test.cpp
✅
AC
· 最終更新 2026-07-24
· GitHub
問題: https://judge.yosupo.jp/problem/segment_add_get_min
依存するヘッダ(1)
実装
// competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/segment_add_get_min
#include <cstdint>
#include <iostream>
#include "dp/li_chao_tree.hpp"
int main(void) {
int n, q;
std::cin >> n >> q;
li_chao_tree lct(-1000000000, 1000000001);
while (n--) {
std::int64_t l, r, a, b;
std::cin >> l >> r >> a >> b;
lct.add_segment(a, b, l, r);
}
while (q--) {
int c;
std::cin >> c;
if (c == 0) {
std::int64_t l, r, a, b;
std::cin >> l >> r >> a >> b;
lct.add_segment(a, b, l, r);
} else {
std::int64_t x;
std::cin >> x;
auto ans = lct.query(x);
if (ans == lct.inf) std::cout << "INFINITY\n";
else std::cout << ans << '\n';
}
}
return 0;
}