Submission #1262623

#TimeUsernameProblemLanguageResultExecution timeMemory
1262623anteknneStations (IOI20_stations)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define st first
#define nd second
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define debug false

const int MAXN = 1000 + 17;
vector<int> graf[MAXN];
int lev[MAXN];
int cnt = 0;
int nr[MAXN];

void DFS1 (int v, int o) {
    for (auto x : graf[v]) {
        if (x != o) {
            lev[x] = lev[v] + 1;
            DFS1(x, v);
        }
    }
}

void DFS2 (int v, int o) {
    if (lev[v] % 2 == 0) {
        nr[v] = cnt;
        cnt ++;
    }
    for (auto x : graf[v]) {
        if (x != o) {
            DFS2(x, v);
        }
    }
    if (lev[v] % 2 == 1) {
        nr[v] = cnt;
        cnt ++;
    }
}

vector<int> label(int n, int k, vector<pii> neighbours) {
    vector<int> labels(n);

    for (int i = 0; i < n; i ++) {
        graf[i].clear();
    }
    for (auto x : neighbours) {
        graf[x.st].pb(x.nd);
        graf[x.nd].pb(x.st);
    }
    cnt = 0;
    DFS1(0, 0);
    DFS2(0, 0);

    for (int i = 0; i < n; i ++) {
        labels[i] = nr[i];
    }

    return labels;
}

int step(int v, int u, vector<int> c) {
    sort(c.begin(), c.end());
    int r = int(c.size());
    if (v > c.back()) {
        for (int i = 1; i < r - 1; i ++) {
            if (c[i] <= u && u < c[i + 1]) {
                return c[i];
            }
        }
        if (c[r - 1] <= u && u < v)  {
            return c[r - 1];
        }
        return c[0];
    }
    for (int i = 1; i < r - 1; i ++) {
        if (c[i - 1] < u && u <= c[i]) {
            return c[i];
        }
    }
    if (v < u && u <= c[0]) {
        return c[0];
    }
    return c[r - 1];
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccKBMSjO.o: in function `main':
stub.cpp:(.text.startup+0x2d7): undefined reference to `label(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: stub.cpp:(.text.startup+0x4fc): undefined reference to `find_next_station(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status