제출 #417691

#제출 시각아이디문제언어결과실행 시간메모리
417691lakshith_기지국 (IOI20_stations)C++14
0 / 100
825 ms628 KiB
#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<int> labels;
int col = 0;

void dfs(int u,int p,vector<vector<int>>& adj){
	int c = 0;
	for(int v:adj[u]){
		if(v==p)continue;
		c++;
		if(c==2)labels[u] = col++;
		dfs(v,u,adj);
	}
	
	if(labels[u]==-1)labels[u] = col++;
}

std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	labels.assign(n,-1);
	vector<vector<int>> adj(1000,vector<int>());
	for(int i=0;i<n-1;i++){
		adj[u[i]].push_back(v[i]);
		adj[v[i]].push_back(u[i]);
	}
	col = 0;
	dfs(0,-1,adj);
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
	if(c.size()==0){
		if(s<t)return c[1];
		else return c[0];
	}
	if(c.size()==1)return c[0];
	if(s<=t)
		return c[3];
	else if(t<=c[0])
		return c[0];
	else 
		return c[1];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...