Submission #361936

# Submission time Handle Problem Language Result Execution time Memory
361936 2021-02-01T09:52:30 Z valerikk Stations (IOI20_stations) C++17
0 / 100
1007 ms 888 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();
    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:34:9: warning: 'p' may be used uninitialized in this function [-Wmaybe-uninitialized]
   34 |     int p;
      |         ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 364 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 364 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Invalid labels (duplicates values). scenario=1, label=0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1007 ms 888 KB Output is correct
2 Incorrect 1 ms 364 KB Invalid labels (duplicates values). scenario=0, label=0
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 492 KB Invalid labels (duplicates values). scenario=0, label=0
2 Halted 0 ms 0 KB -