답안 #306226

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
306226 2020-09-24T23:10:08 Z sofapuden 기지국 (IOI20_stations) C++14
0 / 100
3000 ms 253388 KB
#include "stations.h"
#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> gri;
vector<int> ret;
int cn;

void dfs(int x, int p, int d){
	if(d&1)ret[x] = cn++;
	for(auto i : gri[x]){
		if(i == p)continue;
		dfs(i,x,d+1);
	}
	if(!(d&1))ret[x] = cn++;	
}

vector<int> label(int n, int k, vector<int> u, vector<int> v) {
	gri.clear();
	ret.clear();
	cn = 0;
	gri.resize(n);
	for(int i = 0; i < n; ++i){
		gri[u[i]].push_back(v[i]);
		gri[v[i]].push_back(u[i]);
	}
	ret.resize(n);
	dfs(0,0,0);
	return ret;
}

int find_next_station(int s, int t, vector<int> c) {
	int m = c.size();
	if(m == 1)return c[0];
	for(int i : c)if(i == t)return t;
	if(s > c[0]){
		sort(c.rbegin(),c.rend());
		if(s < t)return c.back();
		for(int i = 0; i < m; ++i){
			if(c[i] < t)return c[i];
		}
		return c.back();		
	}
	sort(c.begin(),c.end());
	if(s > t)return c.back();
	for(int i = 0; i < m; ++i){
		if(c[i] > t)return c[i];
	}
	return c.back();
	
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3065 ms 253388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 894 ms 640 KB Output is correct
2 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -