14012022-09-01 16:48:33Valaki2Szakaszokcpp14Wrong answer 0/100118ms19400 KiB
#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")

#define pb push_back

const int inf = 1e9 + 42;
const int maxn = 3e5 + 42;
int tree[1 + 4 * maxn];

struct segtree {

    int n;

    void build(const vector<int> &arr, int v, int vl, int vr) {
        if(vl == vr) {
            tree[v] = arr[vl];
        } else {
            int mid = (vl + vr) / 2;
            build(arr, 2 * v, vl, mid);
            build(arr, 2 * v + 1, mid + 1, vr);
            tree[v] = tree[2 * v] + tree[2 * v + 1];
        }
    }

    void update(int pos, int val, int v, int vl, int vr) {
        if(vl == vr) {
            tree[v] = val;
        } else {
            int mid = (vl + vr) / 2;
            if(pos <= mid) {
                update(pos, val, 2 * v, vl, mid);
            } else {
                update(pos, val, 2 * v + 1, mid + 1, vr);
            }
            tree[v] = tree[2 * v] + tree[2 * v + 1];
        }
    }

    int query(int ql, int qr, int v, int vl, int vr) {
        if(qr < vl || ql > vr) {
            return 0;
        }
        if(ql == vl && qr == vr) {
            return tree[v];
        } else {
            int mid = (vl + vr) / 2;
            return (query(ql, min(qr, mid), 2 * v, vl, mid) +
                query(max(ql, mid + 1), qr, 2 * v + 1, mid + 1, vr));
        }
    }

    segtree() : n(0) {}
    segtree(int n_) : n(n_) {}
    segtree(int n_, const vector<int> &arr) : n(n_) {
        build(arr, 1, 1, n_);
    }

};

struct event {
    int type, x, y, y1, y2, id;
    bool operator < (const event &other) const {
        if(x == other.x) {
            return type < other.type;
        }
        return x < other.x;
    }
};

vector<event> events;
vector<int> compress;

void solve() {
    int m, n;
    cin >> m >> n;
    for(int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        compress.pb(b);
        compress.pb(c);
        events.pb({1, a, c, -inf, -inf, i});
        events.pb({3, b, c, -inf, -inf, i});
    }
    for(int i = 0; i < n; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        events.pb({2, a, -inf, b, c, i});
        compress.pb(b);
        compress.pb(c);
    }
    sort(events.begin(), events.end());
    sort(compress.begin(), compress.end());
    compress.resize(unique(compress.begin(), compress.end()) - compress.begin());
    for(event &e : events) {
        if(e.y != -inf) {
            e.y = (lower_bound(compress.begin(), compress.end(), e.y) - compress.begin()) + 1;
        }
        if(e.y1 != -inf) {
            e.y1 = (lower_bound(compress.begin(), compress.end(), e.y1) - compress.begin()) + 1;
        }
        if(e.y2 != -inf) {
            e.y2 = (lower_bound(compress.begin(), compress.end(), e.y2) - compress.begin()) + 1;
        }
    }
    segtree my_tree(maxn);
    int ans = -1, best_cnt = 0;
    /*for(event e : events) {
        //cout << e.type << " " << e.x << " " << e.y << " " << e.y1 << " " << e.y2 << "\n";
        if(e.type == 1) {
            my_tree.update(e.y, 1, 1, 1, maxn);
        } else if(e.type == 2) {
            int cnt = my_tree.query(e.y1, e.y2, 1, 1, maxn);
            if(cnt > best_cnt) {
                best_cnt = cnt;
                ans = e.id;
            } else if(cnt == best_cnt && ans > e.id) {
                ans = e.id;
            }
        } else {
            my_tree.update(e.y, 0, 1, 1, maxn);
        }
    }*/
    cout << ans + 1 << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/100
1Wrong answer0/03ms1896 KiB
2Wrong answer0/021ms4404 KiB
3Wrong answer0/22ms2476 KiB
4Wrong answer0/24ms2912 KiB
5Wrong answer0/24ms3476 KiB
6Wrong answer0/310ms3996 KiB
7Wrong answer0/37ms3932 KiB
8Wrong answer0/317ms4660 KiB
9Wrong answer0/317ms4964 KiB
10Wrong answer0/417ms4920 KiB
11Wrong answer0/423ms5440 KiB
12Wrong answer0/434ms7080 KiB
13Wrong answer0/741ms7336 KiB
14Wrong answer0/752ms7884 KiB
15Wrong answer0/764ms11252 KiB
16Wrong answer0/7118ms18952 KiB
17Wrong answer0/737ms7460 KiB
18Wrong answer0/764ms11624 KiB
19Wrong answer0/782ms12080 KiB
20Wrong answer0/7118ms19248 KiB
21Wrong answer0/7118ms19232 KiB
22Wrong answer0/767ms19400 KiB