제출 #1366577

#제출 시각아이디문제언어결과실행 시간메모리
1366577Ekber_Ekber다리 (APIO19_bridges)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
    #include <debug.h>
#else
    #define debug(...)
#endif
#define GOOD_LUCK ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
// #define int long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;

constexpr int MAX = 2e+5 + 1, INF = 2e+9, MOD = 1e+9 + 7, K = 31;

struct DSU_roll{
    int n, c;
    vector <int> p, sz;
    vector <pair<int, int>> h;
    void init(int n1) {
        n = n1;
        c = n;
        p.assign(n+1, -1);
        for (int i = 1; i <= n; i++) p[i] = i;
        sz.assign(n+1, 1);
        h.clear();
    }
    int get(int u) {
        if (p[u] == u) return u;
        return get(p[u]);
    }
    bool un(int a, int b) {
        a = get(a);
        b = get(b);
        if (a == b) return 0;
        if (sz[a] < sz[b]) swap(a, b);
        h.pb({a, b});
        sz[a] += sz[b];
        p[b] = a;
        --c;
        return 1;
    }
    void roll(int x) {
        while (h.size() > x) {
            int a = h.back().ff, b = h.back().ss;
            h.pop_back();
            ++c;
            sz[a] -= sz[b];
            p[b] = b;
        }
    }
};

vector <vector <int>> is;

void _() {
    int n, m;
    cin >> n >> m;
    vector <array <int, 3>> v;
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        c = INF - c;
        v.pb({a, b, c});
    }
    int B = 200;
    int q;
    cin >> q;
    vector <array <int, 3>> que(q);
    for (auto &i : que) {
        cin >> i[0] >> i[1] >> i[2];
        if (i[0] == 1) {
            --i[1];
        }
        i[2] = INF - i[2];
    }
    vector <int> pr(m);
    for (int i = 0; i < m; i++) pr[i] = i;
    sort(all(pr), [&](int a, int b){
        return v[a][2] < v[b][2];
    });
    int sz = ceil(1. * q / B);
    vector <int> res(q, -1);
    vector <bool> is(m, 0);
    DSU_roll dsu;
    for (int z = 0; z < sz; z++) {
        dsu.init(n);
        int st = z * B, end = min(q, (z + 1) * B);
        vector <int> del;
        for (int i = st; i < end; i++) {
            if (que[i][0] == 1) {
                if (!is[que[i][1]]) {
                    del.pb(que[i][1]);
                    is[que[i][1]] = 1;
                }
            }
        }
        vector <array <int, 3>> prev;
        vector <int> ch, nt;
        for (int &i : pr) {
            if (is[i]) {
                ch.pb(i);
                continue;
            }
            prev.pb({v[i][2], v[i][0], v[i][1]});
            nt.pb(i);
        }
        vector <pair<int, int>> qu;
        for (int i = st; i < end; i++) {
            if (que[i][0] == 2) {
                qu.pb({que[i][2], i});
            }
        }
        sort(all(qu));
        int idw = 0;
        for (auto &[w, i] : qu) {
            while (idw < prev.size() && prev[idw][0] <= w) {
                dsu.un(prev[idw][1], prev[idw][2]);
                idw++;
            }
            int h = dsu.h.size();
            for (int id : del) {
                int cur = v[id][2];
                for (int z = st; z < i; z++) {
                    if (que[z][0] == 1 && que[z][1] == id) {
                        cur = que[z][2];
                    }
                }
                if (cur <= w) dsu.un(v[id][0], v[id][1]);
            }
            res[i] = dsu.sz[dsu.get(que[i][1])];
            dsu.roll(h);
        }
        for (int i = st; i < end; i++) {
            if (que[i][0] == 1) {
                is[que[i][1]] = 0;
                v[que[i][1]][2] = que[i][2];
            }
        }
        sort(all(ch), [&](int a, int b){
            return v[a][2] <v[b][2];
        });
        merge(all(nt), all(ch), pr.begin(), [&](int a, int b){
            return v[a][2] < v[b][2];
        });
    }
    for (int &i : res) {
        if (i != -1) cout << i << endl;
    }
}

signed main() {

    GOOD_LUCK

    int tests=1;
    // cin >> tests;
    for (int i=1; i <= tests; i++) {
        _();
        cout << endl;
    }

    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

bridges.cpp:3:14: fatal error: debug.h: No such file or directory
    3 |     #include <debug.h>
      |              ^~~~~~~~~
compilation terminated.