답안 #1036593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1036593 2024-07-27T14:35:57 Z vjudge1 도시들 (IOI15_towns) C++17
25 / 100
10 ms 1228 KB
#include "towns.h"

#include<bits/stdc++.h>
using namespace std;

int n;

int dist[200][200];

int query(int i,int j){
	if(j<i)swap(i,j);
	if(!dist[i][j])dist[i][j]=getDistance(i,j);
	return dist[i][j];
}

int hubDistance(int N, int sub) {
	memset(dist,0,sizeof(dist));
	n=N;
	int past=-1,point1=-1;
	for(int i=1;i<n;i++){
		if(past<query(0,i)){
			point1=i;
			past=query(0,i);
		}
	}
	past=-1;
	int point2=-1;
	for(int i=0;i<n;i++){
		if(i==point1)continue;
		if(past<query(point1,i)){
			point2=i;
			past=query(point1,i);
		}
	}
	int ds=query(point1,point2);
	int ans=1e9;
	for(int i=0;i<n;i++){
		if(i==point1||i==point2)continue;
		int tem=(query(point1,i)+query(point2,i)-ds)/2;
		int val1=query(point1,i)-tem;
		int val2=query(point2,i)-tem;
		ans=min(ans,max({tem,val1,val2}));
	}
	return ans;
}

Compilation message

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:16:28: warning: unused parameter 'sub' [-Wunused-parameter]
   16 | int hubDistance(int N, int sub) {
      |                        ~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1116 KB Output is correct
2 Correct 7 ms 1008 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 10 ms 1116 KB Output is correct
5 Correct 10 ms 1100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1112 KB Output is correct
2 Correct 8 ms 860 KB Output is correct
3 Correct 10 ms 1180 KB Output is correct
4 Correct 10 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 9 ms 1228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 856 KB Output isn't correct
2 Halted 0 ms 0 KB -