Submission #408378

# Submission time Handle Problem Language Result Execution time Memory
408378 2021-05-19T07:15:37 Z muhammad_hokimiyon Stations (IOI20_stations) C++14
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <vector>
#include<bits/stdc++.h>

using namespace std;

const int N = 1e3 + 7;

int d[N];
vector<int> g[N];

void dfs(int x, int p)
{
    for(auto y : g[x]){
        if(y == p)continue;
        d[y] = d[x] + 1;
        dfs(y, x);
    }
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	for(int i = 0; i < n - 1; i++){
        int x = u[i], y = v[i];
        g[x].push_back(y);
        g[y].push_back(x);
	}
	int st = 0;
	for(int i = 1; i < n; i++){
        if((int)g[i].size() < (int)g[st].size()){
            st = i;
        }
	}
	dfs(st, st);
	for(int i = 0; i < n; i++){
        labels[i] = d[i];
	}
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    for(auto x : c){
        if(s < t && x < s)return x;
        if(s > t && x > s)return x;
    }
    assert(0);
}
# Verdict Execution time Memory Grader output
1 Runtime error 1956 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3059 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1997 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 784 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3156 ms 1603168 KB Time limit exceeded
2 Halted 0 ms 0 KB -