Submission #1076663

# Submission time Handle Problem Language Result Execution time Memory
1076663 2024-08-26T15:24:32 Z mindiyak Stations (IOI20_stations) C++14
0 / 100
578 ms 940 KB
#include "stations.h"
#include <vector>
#include <queue>
#include <iostream>

using namespace std;

vector<vector<int>> paths(1001);
vector<int> dist(1001,-1);

void dfs(int pos,int len){
	if(dist[pos] != -1)return;
	dist[pos] = len;
	for(int i:paths[pos])dfs(i,len+1);
}


std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	paths = vector<vector<int>>(1001);
	dist = vector<int>(1001,-1);

	for(int i = 0;i<n-1;i++){
		paths[u[i]].push_back(v[i]);
		paths[v[i]].push_back(u[i]);
	}

	int head = 0;
	for (int i = 0; i < n; i++) {
		if(paths[i].size() > 2){
			head = i;
		}
	}

	dist[head] = 0;
	int cnt = 1;
	for(int i:paths[head]){
		dfs(i,cnt*1000);
		cnt ++;
	}

	// cerr << head << endl;
	for (int i = 0; i < n; i++) {
		labels[i] = dist[i];
		// cerr << labels[i] << " ";
	}
	// cerr << endl;
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if (c.size() == 1) return c[0];
	if(t>s)return c[1];
	return c[0];
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 596 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=2004
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 344 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=1007
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 341 ms 684 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 578 ms 684 KB Output is correct
2 Incorrect 424 ms 684 KB Wrong query response.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 349 ms 940 KB Wrong query response.
2 Halted 0 ms 0 KB -