Submission #396125

# Submission time Handle Problem Language Result Execution time Memory
396125 2021-04-29T13:34:14 Z snasibov05 Stations (IOI20_stations) C++14
0 / 100
3000 ms 280 KB
#include "stations.h"
#include <vector>

#define pb push_back

using namespace std;

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	vector<int> labels(n);

	vector<int> ed[n];
    for (int i = 0; i < n - 1; ++i) {
        ed[u[i]].pb(v[i]);
        ed[v[i]].pb(u[i]);
    }

    int prev = -1, cur = -1;
    for (int i = 0; i < n; ++i) {
        if (ed[i].size() == 1) cur = i;
    }

    int x = 1;

    while (true){
        labels[cur] = x++;
        prev = cur;
        for (auto to : ed[cur]){
            if (to != prev) {
                cur = to;
                break;
            }
        }
        if (prev == cur) break;
    }

	return labels;
}

int find_next_station(int s, int t, vector<int> c) {

    if (s > t){
        for (auto x : c){
            if (s > x) return x;
        }
    }
    else{
        for (auto x : c){
            if (s < x) return x;
        }
    }
    
    return c[0];
    
}
# Verdict Execution time Memory Grader output
1 Execution timed out 3052 ms 200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3064 ms 280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3071 ms 200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3002 ms 200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3051 ms 200 KB Time limit exceeded
2 Halted 0 ms 0 KB -