Submission #965719

# Submission time Handle Problem Language Result Execution time Memory
965719 2024-04-19T06:06:33 Z becaido Examination (JOI19_examination) C++17
Compilation error
0 ms 0 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define Waimai ios::sync_with_stdio(false), cin.tie(0)
#define FOR(x,a,b) for (int x = a, I = b; x <= I; x++)
#define pb emplace_back
#define F first
#define S second

const int SIZE = 2e5 + 5;

int n, q, sz;
int ans[SIZE];

int m;
vector<int> lis;

int bit[SIZE];
void upd(int pos, int x) {
    for (; pos <= m; pos += pos & -pos) bit[pos] += x;
}
int que(int pos) {
    int re = 0;
    for (; pos; pos -= pos & -pos) re += bit[pos];
    return re;
}

struct ds {
    int x, y, z, id;
    ds() {}
    ds(int x, int y, int z, int id) : x(x), y(y), z(z), id(id) {}
    bool operator < (const ds &o) const {
        return make_tuple(x, y, z, id) < make_tuple(o.x, o.y, o.z, o.id);
    }
} a[SIZE], tmp[SIZE];

bool cmp(ds a, ds b) {
    return make_tuple(a.y, a.z, a.id) < make_tuple(b.y, b.z, b.id);
}

void divide(int l, int r) {
    if (l == r) return;
    int mid = (l + r) / 2;
    divide(l, mid), divide(mid + 1, r);
    debug(l, r);
    for (int i = l, il = l, ir = mid + 1; i <= r; i++) {
        if (ir > r || (il <= mid && cmp(a[il], a[ir]))) {
            if (a[il].id == 0) upd(a[il].z, 1);
            tmp[i] = a[il++];
        } else {
            if (a[ir].id) ans[a[ir].id] += que(a[ir].z);
            tmp[i] = a[ir++];
        }
    }
    FOR (i, l, mid) if (a[i].id == 0) upd(a[i].z, -1);
    FOR (i, l, r) a[i] = tmp[i];
}

void solve() {
    cin >> n >> q;
    FOR (i, 1, n) {
        int x, y;
        cin >> x >> y;
        x = -x, y = -y;
        a[++sz] = ds(x, y, x + y, 0);
    }
    FOR (i, 1, q) {
        int x, y, z;
        cin >> x >> y >> z;
        x = -x, y = -y, z = -z;
        a[++sz] = ds(x, y, z, i);
    }
    FOR (i, 1, sz) lis.pb(a[i].z);
    sort(lis.begin(), lis.end());
    lis.erase(unique(lis.begin(), lis.end()), lis.end());
    m = lis.size();
    FOR (i, 1, sz) a[i].z = lower_bound(lis.begin(), lis.end(), a[i].z) - lis.begin() + 1;
    sort(a + 1, a + sz + 1);
    divide(1, sz);
    FOR (i, 1, q) cout << ans[i] << '\n';
}

int main() {
    Waimai;
    solve();
}

Compilation message

examination.cpp: In function 'void divide(int, int)':
examination.cpp:48:5: error: 'debug' was not declared in this scope
   48 |     debug(l, r);
      |     ^~~~~