Submission #306774

# Submission time Handle Problem Language Result Execution time Memory
306774 2020-09-26T09:06:13 Z VEGAnn Stations (IOI20_stations) C++14
0 / 100
3000 ms 1040 KB
#include "stations.h"
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
using namespace std;
vector<int> g[1000];
int tin[1000], tout[1000], tt = 0;

void dfs(int v, int p){
    tin[v] = tt++;

    for (int u : g[v]){
        if (u == p) continue;
        dfs(u, v);
    }

    tout[v] = tt - 1;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
    for (int i = 0; i < n; i++)
        g[i].clear();

    tt = 0;

    for (int i = 0; i < sz(u); i++){
        g[u[i]].PB(v[i]);
        g[v[i]].PB(u[i]);
    }

    int root = 0;

    while (sz(g[root]) > 1) root++;

    dfs(0, -1);

    vector<int> labels;

    labels.resize(n);

    for (int i = 0; i < n; i++) {
        labels[i] = tin[i];
    }

	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    for (int v : c)
        if (abs(v - t) < abs(s - t))
            return v;
    while (1) {}
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3053 ms 776 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3060 ms 768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3055 ms 776 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 873 ms 1040 KB Output is correct
2 Execution timed out 3029 ms 876 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3039 ms 768 KB Time limit exceeded
2 Halted 0 ms 0 KB -