Submission #308574

# Submission time Handle Problem Language Result Execution time Memory
308574 2020-10-01T14:45:16 Z lacito Stations (IOI20_stations) C++14
0 / 100
941 ms 1008 KB
#include "stations.h"
#include <vector>

using namespace std;

const int M = 2000;

vector<vector<int>> g;
vector<int> intime, outtime;
int time;

void dfs(int v) {
    intime[v] = time++;
    for (int x : g[v])
        if (intime[x] == -1)
            dfs(x);
    outtime[v] = time++;
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	g.assign(n, {});
	intime.assign(n, -1);
	outtime.assign(n, -1);
	for (int i = 0; i < n - 1; i++) {
        g[u[i]].push_back(v[i]);
        g[v[i]].push_back(u[i]);
	}
	time = 0;
	dfs(0);
	vector<int> labels(n);
	for (int i = 0; i < n; i++) {
		labels[i] = M * intime[i] + outtime[i];
	}
	return labels;
}

inline int in(int label) {
    return label / M;
}

inline int out(int label) {
    return label % M;
}

inline bool inside(int label_a, int label_b) {
    return in(label_a) < in(label_b) && out(label_b) < out(label_a);
}

int find_next_station(int s, int t, vector<int> c) {
    int parent = -1;
    for (int x : c) {
        if (inside(x, s))
            parent = x;
    }
    for (int x : c) {
        if (inside(x, t) && x != parent)
            return x;
    }
	return parent;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=14014
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1991
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 640 KB Invalid labels (values out of range). scenario=1, k=1000000, vertex=3, label=1157149
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 941 ms 740 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 598 ms 1008 KB Wrong query response.
2 Halted 0 ms 0 KB -