답안 #1076651

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1076651 2024-08-26T15:18:39 Z mindiyak 기지국 (IOI20_stations) C++14
5 / 100
645 ms 936 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() == 1){
			head = i;
		}
	}
	dfs(head,0);

	// 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];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 369 ms 684 KB Output is correct
2 Correct 323 ms 684 KB Output is correct
3 Correct 571 ms 684 KB Output is correct
4 Correct 479 ms 684 KB Output is correct
5 Correct 430 ms 684 KB Output is correct
6 Correct 280 ms 684 KB Output is correct
7 Correct 302 ms 684 KB Output is correct
8 Correct 2 ms 764 KB Output is correct
9 Correct 3 ms 776 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 344 KB Invalid labels (duplicates values). scenario=0, label=11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 368 ms 684 KB Output is correct
2 Correct 317 ms 684 KB Output is correct
3 Correct 645 ms 684 KB Output is correct
4 Correct 462 ms 684 KB Output is correct
5 Correct 405 ms 684 KB Output is correct
6 Correct 323 ms 684 KB Output is correct
7 Correct 330 ms 684 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Incorrect 1 ms 344 KB Invalid labels (duplicates values). scenario=1, label=2
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 616 ms 684 KB Output is correct
2 Correct 450 ms 684 KB Output is correct
3 Correct 386 ms 684 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 2 ms 768 KB Output is correct
7 Incorrect 1 ms 464 KB Invalid labels (duplicates values). scenario=0, label=2
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 303 ms 684 KB Output is correct
2 Correct 263 ms 936 KB Output is correct
3 Correct 564 ms 684 KB Output is correct
4 Correct 473 ms 688 KB Output is correct
5 Correct 449 ms 684 KB Output is correct
6 Correct 309 ms 684 KB Output is correct
7 Correct 296 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 0 ms 764 KB Output is correct
11 Incorrect 4 ms 344 KB Invalid labels (duplicates values). scenario=0, label=11
12 Halted 0 ms 0 KB -