Submission #361937

# Submission time Handle Problem Language Result Execution time Memory
361937 2021-02-01T09:53:26 Z valerikk Stations (IOI20_stations) C++17
0 / 100
877 ms 1120 KB
#include <vector>
using namespace std;

const int N = 1007;
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 fun(int v) {
    tin[v] = v / 1000;
    tout[v] = v % 1000;
}

int find_next_station(int s, int t, vector<int> c) {
    fun(s); fun(t);
    for (int v : c) fun(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 2 ms 492 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 5 ms 364 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 Runtime error 4 ms 992 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 877 ms 864 KB Output is correct
2 Correct 630 ms 956 KB Output is correct
3 Runtime error 601 ms 1084 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 1120 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -