Submission #361938

# Submission time Handle Problem Language Result Execution time Memory
361938 2021-02-01T09:55:57 Z valerikk Stations (IOI20_stations) C++17
0 / 100
978 ms 55776 KB
#include <vector>
using namespace std;

const int N = 1e6 + 7;
vector<int> g[N];
int tin[N], tout[N], t;

void dfs(int v, int p = -1) {
    tin[v] = t++;
    for (int u : g[v]) {
        if (u != p) dfs(u, v);
    }
    tout[v] = t;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
    for (int i = 0; i < n; i++) g[i].clear();
    for (int i = 0; i < n - 1; i++) {
        g[u[i]].push_back(v[i]);
        g[v[i]].push_back(u[i]);
    }
    t = 0;
    dfs(0);
    tout[0] = n - 1;
    vector<int> l(n);
    for (int i = 0; i < n; i++) l[i] = tin[i]*1000 + tout[i];
    return l;
}

void f(int v) {
    tin[v] = v / 1000;
    tout[v] = v % 1000;
}

int find_next_station(int s, int t, vector<int> c) {
    f(s); f(t);
    for (int v : c) f(v);
    int p;
    for (int v : c) {
        if (tin[v] <= tin[s] && tout[v] >= tout[s]) {
            p = v;
            continue;
        }
        if (tin[v] <= tin[t] && tout[v] >= tout[t]) return v;
    }
    return p;
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:38:9: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |     int p;
      |         ^
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 23916 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6010
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 23916 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1512
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 684 ms 55716 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 978 ms 47712 KB Output is correct
2 Correct 720 ms 47932 KB Output is correct
3 Correct 610 ms 47968 KB Output is correct
4 Correct 31 ms 47768 KB Output is correct
5 Correct 34 ms 47712 KB Output is correct
6 Correct 32 ms 47760 KB Output is correct
7 Incorrect 680 ms 47712 KB Wrong query response.
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 743 ms 55776 KB Wrong query response.
2 Halted 0 ms 0 KB -