답안 #417658

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
417658 2021-06-04T06:04:20 Z lakshith_ 기지국 (IOI20_stations) C++14
0 / 100
3000 ms 2097156 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

#define what_is(a) cout << #a << " is " << a << "\n"
#define checker(a) cout << "checker reached " << a << "\n"

vector<vector<int>> adj(1000,vector<int>());

vector<int> path;

void dfs(int u,int p){
	path.push_back(u);
	for(int v:adj[u])
		if(v!=p)dfs(v,u);
	//what_is(u);
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	vector<int> labels;
	int counts[n];
	memset(counts,0,sizeof(counts));
	for(int i=0;i<n-1;i++){
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
		counts[u[i]]++,counts[v[i]]++;
	}
	int start = 0;
	for(int i=0;i<n;i++){
		if(counts[i]==1){
			start = i;
			break;
		}
	}
	path.clear();
	dfs(start,-1);
	labels.assign(n,0);
	for(int i=0;i<n;i++)
		labels[path[i]] = i;
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if(s<=t)
		return max(c[0],c[1]);
	else
		return min(c[0],c[1]);
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1538 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3048 ms 1051184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1676 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 867 ms 400 KB Output is correct
2 Runtime error 1449 ms 2097156 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2939 ms 2097156 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -