Submission #408414

# Submission time Handle Problem Language Result Execution time Memory
408414 2021-05-19T07:22:39 Z muhammad_hokimiyon Stations (IOI20_stations) C++14
0 / 100
1035 ms 556 KB
#include "stations.h"
#include <vector>
#include<bits/stdc++.h>

using namespace std;

const int N = 1e3 + 7;

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	vector<int> g[n + 7];
	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;
        }
	}
	queue<int> q;
	q.push(st);
	vector<int> d(n + 7, 1e9);
	d[st] = 0;
	while(!q.empty()){
        int x = q.front();
        q.pop();
        for(auto y : g[x]){
            if(d[y] == 1e9){
                d[y] = d[x] + 1;
                q.push(y);
            }
        }
	}
	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 Incorrect 907 ms 528 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 404 KB Invalid labels (duplicates values). scenario=0, label=10
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 915 ms 544 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1035 ms 400 KB Output is correct
2 Incorrect 717 ms 472 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 691 ms 556 KB Wrong query response.
2 Halted 0 ms 0 KB -