Submission #408383

# Submission time Handle Problem Language Result Execution time Memory
408383 2021-05-19T07:16:32 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;
    }
    return c[0];
}
# Verdict Execution time Memory Grader output
1 Runtime error 1974 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3043 ms 380 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1937 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1515 ms 568 KB Output is correct
2 Runtime error 1578 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3159 ms 1662008 KB Time limit exceeded
2 Halted 0 ms 0 KB -