Submission #1364900

#TimeUsernameProblemLanguageResultExecution timeMemory
1364900backer8002Stations (IOI20_stations)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;

vector<int> edges[1000];
static void DFS(int curr,int prev,vector<int>& res,bool maximum) {
    static int time = 0;
    if (!maximum)
        res[curr] = ++time;

    for (int edge : edges[curr]) if (edge != prev) DFS(edge,curr,res,!maximum);

    if (maximum)
        res[curr] = ++time;
}

vector<int> label(int n, int, const vector<int>& u, const vector<int>& v) {
    for (int i = 0; i < n-1; i++) {
        edges[u[i]].emplace_back(v[i]);
        edges[v[i]].emplace_back(u[i]);
    }
    vector<int> res(n);
    DFS(0,0,res,false);
    return res;
}

int find_next_station(int s, int t, const vector<int>& c) {
    if (s < c[0]) {
        if (t >= c.back())
            return c.back();
        return *ranges::upper_bound(c,t-1);
    }
    if (t > s)
        return c[0];
    return *--ranges::upper_bound(c,t);
}

#if 0

int main() {
    int n;
    cin >> n;
    vector<int> edge1(n-1),edge2(n-1);

    for (int i = 0; i < n-1; i++) {
        cin >> edge1[i];
        cin >> edge2[i];
    }
    auto labels = label(n,0,edge1,edge2);

    for (auto [i,lab]: views::enumerate(labels))
        cout << format("{} {}\n",i,lab);
}

#endif

Compilation message (stderr)

/usr/bin/ld: /tmp/cc8Usl1D.o: in function `main':
stub.cpp:(.text.startup+0x2b4): 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+0x4ce): undefined reference to `find_next_station(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status