library2

This documentation is automatically generated by competitive-verifier/competitive-verifier

View the Project on GitHub goodstudyqaq/library2

:heavy_check_mark: test/yosupo-line-add-get-min-2.test.cpp

Depends on

Code

// competitive-verifier: PROBLEM https://judge.yosupo.jp/problem/line_add_get_min
#include <bits/stdc++.h>
#include "../geometry/convex-hull-trick.hpp"

#include "../structure/others/binary-grouping.hpp"

using namespace std;

#ifdef LOCAL
#include "copypaste/debug.h"
#else
#define debug(...) 42
#endif

struct fast_ios {
    fast_ios() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    };
} fast_ios_;
using Data = geometry::TPoint<long long>;

struct Structure {
    vector<Data> datas;
    geometry::ConvexHullTrick<long long> cht;
    virtual void add(const Data &d) {
        datas.emplace_back(d);
    }

    void build() {
        cht = geometry::ConvexHullTrick<long long>(datas, true);
    }
    static Structure merge(const Structure &s1, const Structure &s2) {
        Structure new_s;
        for (auto &d : s1.datas) {
            new_s.add(d);
        }
        for (auto &d : s2.datas) {
            new_s.add(d);
        }
        new_s.build();
        return new_s;
    }

    long long query(long long x) {
        return cht.query(x);
    }

    size_t size() const { return datas.size(); }
};

int main() {
#ifdef LOCAL
    freopen("./data.in", "r", stdin);
#endif

    BinaryGrouping<Structure, Data> bg;
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n; i++) {
        long long a, b;
        cin >> a >> b;
        bg.insert({a, b});
    }
    while (q--) {
        int t;
        cin >> t;
        if (t == 0) {
            long long a, b;
            cin >> a >> b;
            bg.insert({a, b});
        } else {
            long long p;
            cin >> p;
            auto &structures = bg.structures;
            long long res = numeric_limits<long long>::max() / 2;
            for (auto &s : structures) {
                res = min(res, s.query(p));
            }
            cout << res << endl;
        }
    }
    return 0;
}
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj_resolve/resolver.py", line 181, in resolve
    bundled_code = language.bundle(path, basedir=basedir)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/verify/languages/cplusplus.py", line 252, in bundle
    bundler.update(path)
  File "/home/runner/.local/lib/python3.12/site-packages/competitive_verifier/oj/verify/languages/cplusplus_bundle.py", line 477, in update
    raise BundleErrorAt(
competitive_verifier.oj.verify.languages.cplusplus_bundle.BundleErrorAt: test/yosupo-line-add-get-min-2.test.cpp: line 10: unable to process #include in #if / #ifdef / #ifndef other than include guards

Test cases

Env Name Status Elapsed Memory
g++ example_00 :heavy_check_mark: AC 5 ms 4 MB
g++ half_00 :heavy_check_mark: AC 369 ms 19 MB
g++ hand_max_00 :heavy_check_mark: AC 657 ms 26 MB
g++ max_random_00 :heavy_check_mark: AC 640 ms 35 MB
g++ max_random_01 :heavy_check_mark: AC 674 ms 35 MB
g++ max_random_02 :heavy_check_mark: AC 643 ms 35 MB
g++ no_output_00 :heavy_check_mark: AC 689 ms 35 MB
g++ parabola_random_00 :heavy_check_mark: AC 713 ms 38 MB
g++ parabola_random_01 :heavy_check_mark: AC 805 ms 38 MB
g++ parabola_random_02 :heavy_check_mark: AC 700 ms 38 MB
g++ random_00 :heavy_check_mark: AC 461 ms 17 MB
g++ random_01 :heavy_check_mark: AC 453 ms 20 MB
g++ random_02 :heavy_check_mark: AC 251 ms 13 MB
g++ small_00 :heavy_check_mark: AC 5 ms 4 MB
g++ small_01 :heavy_check_mark: AC 4 ms 4 MB
Back to top page