Submission #667941

# Submission time Handle Problem Language Result Execution time Memory
667941 2022-12-02T11:57:26 Z bashkort Amusement Park (JOI17_amusement_park) C++17
Compilation error
0 ms 0 KB
#include "Ioi.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;


long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
    struct DSU {
        vector<int> p;

        DSU() = default;

        DSU(int n) : p(n) {
            iota(p.begin(), p.end(), 0);
        }

        int leader(int x) {
            while (x != p[x]) x = p[x] = p[p[x]];
            return x;
        }

        bool unite(int x, int y) {
            x = leader(x), y = leader(y);
            if (p[y] == x) {
                return false;
            } else {
                return p[y] = x, true;
            }
        }
    };

    mt19937 rnd(228);
    vector<pair<int, int>> edges(M);
    for (int i = 0; i < M; ++i) {
        edges[i] = {A[i], B[i]};
    }
    shuffle(edges.begin(), edges.end(), rnd);
    vector<int> tin(N), par(N, -1), tout(N);
    vector<vector<int>> g(N), adj(N);
    DSU d(N);
    for (int i = 0; i < M; ++i) {
        auto [a, b] = edges[i];
        if (d.unite(a, b)) {
            g[a].push_back(b);
            g[b].push_back(a);
        }
    }

    int timer = 0;
    function<void(int)> dfs = [&](int v) {
        tin[v] = timer++;
        sort(g[v].begin(), g[v].end());
        for (int to: g[v]) {
            if (to != par[v]) {
                par[to] = v;
                adj[v].push_back(to);
                dfs(to);
            }
        }
        tout[v] = timer++;
    };
    dfs(0);
    int LOG = 60;
    vector<bool> used(N);
    vector<int> ans(LOG, -1);
    ans[tin[P] % LOG] = V;
    vector<int> last(N, -1);
    int x = P;
    auto any = [&](int l, int r) {
        if (l >= r) {
            return (find(ans.begin(), ans.begin() + r, -1) != (ans.begin() + r))
                   || (find(ans.begin() + l, ans.end(), -1) != ans.end());
        }
        return find(ans.begin() + l, ans.begin() + r, -1) != (ans.begin() + r);
    };
    while (any(0, LOG)) {
        used[x] = true;
        auto it = upper_bound(adj[x].begin(), adj[x].end(), last[x]);
        if (it == adj[x].end()) {
            it = adj[x].begin();
        }
        if (adj[x].empty() || used[*it]) {
            last[par[x]] = x;
            x = par[x];
            assert(x != -1);
            ans[tin[x] % LOG] = Move(x);
        } else {
            last[x] = *it;
            int to = *it;
            if (any(tin[to] % 60, tout[to] % 60)) {
                x = *it;
                ans[tin[x] % LOG] = Move(x);
            }
        }
    }

    ll X = 0;
    for (int i = 0; i < LOG; ++i) {
        assert(ans[i] != -1);
        X += ans[i] * (1LL << i);
    }

    return X;
}
#include "Ioi.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;


long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
    struct DSU {
        vector<int> p;

        DSU() = default;

        DSU(int n) : p(n) {
            iota(p.begin(), p.end(), 0);
        }

        int leader(int x) {
            while (x != p[x]) x = p[x] = p[p[x]];
            return x;
        }

        bool unite(int x, int y) {
            x = leader(x), y = leader(y);
            if (p[y] == x) {
                return false;
            } else {
                return p[y] = x, true;
            }
        }
    };

    mt19937 rnd(228);
    vector<pair<int, int>> edges(M);
    for (int i = 0; i < M; ++i) {
        edges[i] = {A[i], B[i]};
    }
    shuffle(edges.begin(), edges.end(), rnd);
    vector<int> tin(N), par(N, -1), tout(N);
    vector<vector<int>> g(N), adj(N);
    DSU d(N);
    for (int i = 0; i < M; ++i) {
        auto [a, b] = edges[i];
        if (d.unite(a, b)) {
            g[a].push_back(b);
            g[b].push_back(a);
        }
    }

    int timer = 0;
    function<void(int)> dfs = [&](int v) {
        tin[v] = timer++;
        sort(g[v].begin(), g[v].end());
        for (int to: g[v]) {
            if (to != par[v]) {
                par[to] = v;
                adj[v].push_back(to);
                dfs(to);
            }
        }
        tout[v] = timer++;
    };
    dfs(0);
    int LOG = 60;
    vector<bool> used(N);
    vector<int> ans(LOG, -1);
    ans[tin[P] % LOG] = V;
    vector<int> last(N, -1);
    int x = P;
    auto any = [&](int l, int r) {
        if (l >= r) {
            return (find(ans.begin(), ans.begin() + r, -1) != (ans.begin() + r))
                   || (find(ans.begin() + l, ans.end(), -1) != ans.end());
        }
        return find(ans.begin() + l, ans.begin() + r, -1) != (ans.begin() + r);
    };
    while (any(0, LOG)) {
        used[x] = true;
        auto it = upper_bound(adj[x].begin(), adj[x].end(), last[x]);
        if (it == adj[x].end()) {
            it = adj[x].begin();
        }
        if (adj[x].empty() || used[*it]) {
            last[par[x]] = x;
            x = par[x];
            assert(x != -1);
            ans[tin[x] % LOG] = Move(x);
        } else {
            last[x] = *it;
            int to = *it;
            if (any(tin[to] % 60, tout[to] % 60)) {
                x = *it;
                assert(ans[tin[x] % LOG] == -1);
                ans[tin[x] % LOG] = Move(x);
            }
        }
    }

    ll X = 0;
    for (int i = 0; i < LOG; ++i) {
        assert(ans[i] != -1);
        X += ans[i] * (1LL << i);
    }

    return X;
}

Compilation message

Joi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Joi.cpp:87:33: error: 'Move' was not declared in this scope
   87 |             ans[tin[x] % LOG] = Move(x);
      |                                 ^~~~
Joi.cpp:93:37: error: 'Move' was not declared in this scope
   93 |                 ans[tin[x] % LOG] = Move(x);
      |                                     ^~~~