답안 #350688

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
350688 2021-01-19T07:26:55 Z Kerim 기지국 (IOI20_stations) C++17
0 / 100
1009 ms 1152 KB
#include "stations.h"
#include "bits/stdc++.h"
#define MAXN 1009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int T,n;
vector<int>adj[MAXN],labels;
void dfs(int nd,int pr,int lvl){
	if(!lvl)labels[nd]=T++;
	tr(it,adj[nd])
		if(*it!=pr)
			dfs(*it,nd,lvl^1);
	if(lvl)labels[nd]=T++;
}
vector<int> label(int N, int k,vector<int> u, std::vector<int> v) {
	n=N;T=0;labels.clear();
	labels.resize(n);
	for(int i=0;i<n;i++)adj[i].clear();
	for(int i=0;i<n-1;i++){
		adj[u[i]].pb(v[i]);
		adj[v[i]].pb(u[i]);
	}
	dfs(0,-1,0);
	return labels;
}
int find_next_station(int s, int t, vector<int> c) {
	sort(all(c));int m=int(c.size());
	if(!s){
		tr(it,c)
			if(t<=*it)
				return *it;	
	}
	if(s<c[0]){
		int in=s,out=c[m-1]-1;
		if(in<t and t<out){
			tr(it,c)
				if(t<=*it)
					return *it;	
		}
		return c.back();
	}
	else{
		int in=c[0]+1,out=s;
		if(in<t and t<out){
			for(int i=m-1;i>=0;i--)
				if(c[i]<=t)
					return c[i];
		}
		return c[0];
	}
	return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 698 ms 1096 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 547 ms 864 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 620 ms 1152 KB Wrong query response.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1009 ms 1108 KB Output is correct
2 Incorrect 636 ms 952 KB Wrong query response.
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 629 ms 864 KB Wrong query response.
2 Halted 0 ms 0 KB -