답안 #16567

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
16567 2015-08-28T05:18:42 Z gs14004 도시들 (IOI15_towns) C++14
0 / 100
27 ms 1348 KB
#include "towns.h"
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int,int> pi;

int dp[150][150];

int dist(int s, int e){
	if(s == e) return 0;
	if(s > e) swap(s,e);
	if(~dp[s][e]) return dp[s][e];
	return dp[s][e] = getDistance(s, e);
}

vector<pi> v;

int hubDistance(int N, int sub) {
	memset(dp,-1,sizeof(dp));
	int p = -1, val = -1, q = -1;
	for(int i=1; i<N; i++){
		if(val < dist(0, i)){
			val = dist(0, i);
			p = i;
		}
	}
	val = -1;
	for(int i=0; i<N; i++){
		if(val < dist(p, i)){
			val = dist(p, i);
			q = i;
		}
	}
	for(int i=0; i<N; i++){
		int fl = dist(p, i) - dist(q, i) + val;
		v.push_back(pi(fl / 2, i));
	}
	sort(v.begin(), v.end());
	int R = val;
	for(auto &i : v){
		R = min(R, max(val - i.first, i.first));
	}
	return R;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 27 ms 1348 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 1348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Halted 0 ms 0 KB -