Submission #403154

# Submission time Handle Problem Language Result Execution time Memory
403154 2021-05-12T20:28:57 Z AmineTrabelsi Stations (IOI20_stations) C++14
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
const int Mx = 1001;
vector<int> labels;
vector<int> tr[Mx];
void dfs(int node,int par){
    for(auto i:tr[node]){
        if(i != par){
            labels[i] = labels[node]+1;
            dfs(i,node);
        }
    }
}
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	labels.assign(n,0);
	for (int i = 0; i < n-1; i++) {
		tr[u[i]].push_back(v[i]);
        tr[v[i]].push_back(u[i]);
	}
    int root = 0;
    for(int i=0;i<n;i++){
        if(tr[i].size() == 1){
            root = i;
            break;
        }
    }
    dfs(root,-1);
	return labels;
}

int find_next_station(int s, int t, vector<int> c) {
    int ans = -1;
    if(t >= s){
        for(auto i:c){
            ans = max(ans,i);
        }
    }else{
        ans = 1e9+7;
        for(auto i:c){
            ans = min(ans,i);
        }
    }
	return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1388 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3056 ms 308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1525 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1015 ms 400 KB Output is correct
2 Runtime error 1115 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2690 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -