제출 #615603

#제출 시각아이디문제언어결과실행 시간메모리
615603Apiram도시들 (IOI15_towns)C++14
컴파일 에러
0 ms0 KiB
#include "towns.h"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>arr(200,vector<int>(200));
int getDistance(int i,int j){
	//cout<<i<<" "<<j<<" "<<arr[i][j]<<'\n';
	return arr[i][j];
};
int hubDistance(int N, int sub) {
	int root = 0;
	vector<int>dist(N);
	for (int i = 0;i<N;++i){
		if (i == root)dist[i] = 0;
		else dist[i] = getDistance(i,root);
	}
	for (int i = 0;i<N;++i){
		if (dist[i] > dist[root]){
			root = i;
		}
	}
	for (int i = 0;i<N;++i){
		if (i == root)dist[i] = 0;
		else dist[i] = getDistance(i,root);
	}
	int root2 = root;
	for (int i = 0;i<N;++i){
		if (dist[i] > dist[root2])root2 = i;
	}
	int answer = dist[root2];
	vector<int>dist2(N);
	for (int i = 0;i<N;++i){
		if (i == root2){
			dist2[i] = 0;
		}
		else{
			dist2[i] = getDistance(root2,i);
		}
	}
	for (int i = 0;i<N;++i){
		int x = (dist[i] + dist2[i] - dist[root2])/2;
		answer = min(answer,max(dist[i] - x,dist2[i] - x)); 
	}
	bool ok = 0;
	for (int i = 0;i<N;++i){
		int x = (dist[i] + dist2[i] + - dist[root2])/2;
		if (answer == max(dist[i] - x,dist2[i] - x)){
			int sub1 = 0,sub2 = 0;
			for (int j = 0;j<N;++j){
				if (dist[j] <= dist[i] - x){
					sub1++;
				}
				if (dist2[j]<=dist2[i] - x){
					sub2++;
				}
			}	
			int remain = N - sub1 - sub2;
			remain = (remain + 1)/2;
			if (max({remain,sub1,sub2}) <=N/2){
				ok = true;
			}
		}
	}
	return answer * ((ok)?1:-1);
}

컴파일 시 표준 에러 (stderr) 메시지

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:9:28: warning: unused parameter 'sub' [-Wunused-parameter]
    9 | int hubDistance(int N, int sub) {
      |                        ~~~~^~~
/usr/bin/ld: /tmp/ccwI02KN.o: in function `getDistance(int, int)':
grader.c:(.text+0x110): multiple definition of `getDistance(int, int)'; /tmp/ccMclj0N.o:towns.cpp:(.text+0x0): first defined here
collect2: error: ld returned 1 exit status