제출 #985238

#제출 시각아이디문제언어결과실행 시간메모리
985238SmuggingSpun기지국 (IOI20_stations)C++14
0 / 100
566 ms1128 KiB
#include "stations.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>label(int n, int k, vector<int>u, vector<int>v) {
	vector<int>label(n), h(n);
	vector<vector<int>>e(n);
	for(int i = 0; i + 1 < n; i++){
		e[u[i]].emplace_back(v[i]);
		e[v[i]].emplace_back(u[i]);
	}
	function<void(int, int)>dfs;
	int time_dfs = 0;
	dfs = [&] (int s, int p){
		if(~h[s] & 1){
			label[s] = time_dfs++;
		}
		for(int& d : e[s]){
			if(d != p){
				dfs(d, s);
			}
		}
		if(h[s] & 1){
			label[s] = time_dfs++;	
		}
	};
	dfs(h[0] = 0, -1);
	return label;
}
int find_next_station(int s, int t, vector<int>c) {
	if(c.size() == 1){
		return c[0];
	}
	if(find(c.begin(), c.end(), t) != c.end()){
		return t;
	}
	if(s < c[0]){
		return s < t && c[int(c.size()) - 2] > t ? *lower_bound(c.begin(), c.end(), t) : c.back();
	}
	return t < s && t > c[0] ? *prev(lower_bound(c.begin(), c.end(), t)) : c[0];
}
#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...