QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#348708#8338. Quad Kingdoms Chessucup-team1600#Compile Error//C++206.0kb2024-03-09 20:37:402024-03-09 20:37:41

Judging History

你现在查看的是最新测评结果

  • [2024-03-09 20:37:41]
  • 评测
  • [2024-03-09 20:37:40]
  • 提交

answer

//#pragma GCC optimize("Ofast", "unroll-loops")
//#pragma GCC target("sse", "sse2", "sse3", "ssse3", "sse4")

#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#include <cassert>

#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define fi first
#define se second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

template<typename T>
bool umin(T &a, T b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool umax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#ifdef KIVI
#define DEBUG for (bool _FLAG = true; _FLAG; _FLAG = false)
#define LOG(...) print(#__VA_ARGS__" ::", __VA_ARGS__) << endl

template<class ...Ts>
auto &print(Ts ...ts) { return ((cerr << ts << " "), ...); }

#else
#define DEBUG while (false)
#define LOG(...)
#endif

mt19937 rng(4242);

const int max_n = 1e5 + 42, inf = 1000111222;

template<typename TKey, typename TSum>
class min_records_segment_tree {
private:
    struct node {
        TKey min;
        TSum ans, ans_right_after_left;

        node() {
            min = 0;
            ans = 0;
            ans_right_after_left = numeric_limits<TSum>::min();
        }

        template<typename TValue>
        node(TKey key, TValue value) {
            min = key;
            ans = value;
            ans_right_after_left = numeric_limits<TSum>::min();
        }
    };

    node t[4 * max_n];

    node merge(const node& l, int r) {
        node res;
        res.min = min(l.min, t[r].min);
        res.ans_right_after_left = 0;
        while(true) {
            if(t[r].min >= l.min) {
                break;
            } else if(t[r].ans_right_after_left == numeric_limits<TSum>::min()) {
                res.ans_right_after_left += t[r].ans;
                break;
            } else if(t[r * 2].min >= l.min) {
                r = r * 2 + 1;
            } else {
                res.ans_right_after_left += t[r].ans_right_after_left;
                r = r * 2;
            }
        }
        res.ans = l.ans + res.ans_right_after_left;

        return res;
    }

    void get_min_records_internal(int v, int tl, int tr, int l, int r, node& res) {
        if(tl == l && tr == r) {
            res = merge(res, v);
            return;
        }
        int mid = (tl + tr) / 2;
        if(r <= mid) {
            get_min_records_internal(2 * v, tl, mid, l, r, res);
            return;
        } else if(l > mid) {
            get_min_records_internal(2 * v + 1, mid + 1, tr, l, r, res);
            return;
        }
        get_min_records_internal(2 * v, tl, mid, l, mid, res);
        get_min_records_internal(2 * v + 1, mid + 1, tr, mid + 1, r, res);
    }

public:
    template<typename TValue>
    void build(int v, int l, int r, const pair<TKey, TValue> a[]) {
        if(l == r) {
            t[v] = node(a[l].fi, a[l].se);
            return;
        }
        int mid = (l + r) / 2;
        build((v << 1), l, mid, a);
        build((v << 1) + 1, mid + 1, r, a);
        t[v] = merge(t[(v << 1)], (v << 1) + 1);
    }

    template<typename TValue>
    void update(int v, int l, int r, int pos, pair<TKey, TValue> elem) {
        if(l == r) {
            t[v] = node(elem.fi, elem.se);
            return;
        }
        int mid = (l + r) / 2;
        if(pos <= mid) {
            update(2 * v, l, mid, pos, elem);
        } else {
            update(2 * v + 1, mid + 1, r, pos, elem);
        }
        t[v] = merge(t[2 * v], 2 * v + 1);
    }

    TSum get_min_records(int v, int tl, int tr, int l, int r, TKey start_value = numeric_limits<TKey>::max()) {
        node res(start_value, 0);
        get_min_records_internal(v, tl, tr, l, r, res);
        return res.ans;
    }

};

int h[max_n];
min_records_segment_tree<int, ll> t1, t2;

void solve() {
    int n, m, q;
    cin >> n;
    vector <int> a(n);
    for (auto &i : a) cin >> i;
    cin >> m;
    vector <int> b(m);
    for (auto &i : b) cin >> i;
    reverse(all(a));
    reverse(all(b));
    cin >> q;
    vector <pair<int, ll> > A(n), B(m);
    for (int i = 0; i < n; i++) {
        A[i].first = -a[i];
        A[i].second = h[a[i]];
    }
    for (int i = 0; i < m; i++) {
        B[i].first = -b[i];
        B[i].second = h[b[i]];
    }
    t1.build(1, 0, n - 1, A.data());
    t2.build(1, 0, m - 1, B.data());
    while (q--) {
        int t, l, r;
        cin >> t >> l >> r;
        --l;
        if (t == 1) {
            l = n - 1 - l;
            A[l].first = -r;
            A[l].second = h[r];
            t1.update(1, 0, n - 1, l, A[l]);
        }
        else {
            l = m - 1 - l;
            B[l].first = -r;
            B[l].second = h[r];
            t2.update(1, 0, n - 1, l, B[l]);
        }
        ll val1 = t1.get_min_records(1, 0, n - 1, 0, n - 1);
        ll val2 = t2.get_min_records(1, 0, m - 1, 0, m - 1);
        if (val1 == val2) {
            cout << "YES\n";
        }
        else {
            cout << "NO\n";
        }
    }
}

template<typename T = int>
inline T randll(T l = INT_MIN, T r = INT_MAX) {
    return uniform_int_distribution<T>(l, r)(rng);
}

inline ld randld(ld l = INT_MIN, ld r = INT_MAX) {
    return uniform_real_distribution<ld>(l, r)(rng);
}

int main() {
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    for (int i = 0; i < max_n; i++) {
        h[i] = randll(1, (1 << 30) - 1);
    }

    int t = 1;

//    cin >> t;

    while (t--) solve();

}

/*
KIVI
*/

Details

answer.code:223:23: error: ‘INT_MIN’ was not declared in this scope
  223 | inline T randll(T l = INT_MIN, T r = INT_MAX) {
      |                       ^~~~~~~
answer.code:22:1: note: ‘INT_MIN’ is defined in header ‘<climits>’; did you forget to ‘#include <climits>’?
   21 | #include <cassert>
  +++ |+#include <climits>
   22 | 
answer.code:223:38: error: ‘INT_MAX’ was not declared in this scope
  223 | inline T randll(T l = INT_MIN, T r = INT_MAX) {
      |                                      ^~~~~~~
answer.code:223:38: note: ‘INT_MAX’ is defined in header ‘<climits>’; did you forget to ‘#include <climits>’?
answer.code:227:25: error: ‘INT_MIN’ was not declared in this scope
  227 | inline ld randld(ld l = INT_MIN, ld r = INT_MAX) {
      |                         ^~~~~~~
answer.code:227:25: note: ‘INT_MIN’ is defined in header ‘<climits>’; did you forget to ‘#include <climits>’?
answer.code:227:41: error: ‘INT_MAX’ was not declared in this scope
  227 | inline ld randld(ld l = INT_MIN, ld r = INT_MAX) {
      |                                         ^~~~~~~
answer.code:227:41: note: ‘INT_MAX’ is defined in header ‘<climits>’; did you forget to ‘#include <climits>’?