이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "towns.h"
using namespace std;
const int MAX_SOM=115,INFINI=1000*1000*1000;
int nbSom,deb,fin,rep,distDeb,distFin;
int dist[MAX_SOM][MAX_SOM];
int calcDist(int a,int b) {
if (a==b) {
return 0;
}
if (a>b) {
swap(a,b);
}
if (dist[a][b]!=-1) {
return dist[a][b];
}
dist[a][b]=getDistance(a,b);
return dist[a][b];
}
int plusLoin(int a) {
int posMax=0,valMax=0;
for (int i=0;i<nbSom;i++) {
if (calcDist(a,i)>valMax) {
valMax=calcDist(a,i);
posMax=i;
}
}
return posMax;
}
int hubDistance(int N, int sub) {
nbSom=N;
for (int i=0;i<nbSom;i++) {
for (int j=0;j<nbSom;j++) {
dist[i][j]=-1;
}
}
deb=plusLoin(0);
fin=plusLoin(deb);
/*cout<<deb<<" "<<fin<<endl;
for (int i=0;i<nbSom;i++) {
for (int j=0;j<nbSom;j++) {
cout<<dist[i][j]<<" ";
}
cout<<endl;
}*/
rep=INFINI;
for (int i=0;i<nbSom;i++) {
if (i!=deb and i!=fin) {
distDeb=(calcDist(deb,fin)+calcDist(deb,i)-calcDist(i,fin))/2;
distFin=(calcDist(deb,fin)-calcDist(deb,i)+calcDist(i,fin))/2;
rep=min(rep,max(distDeb,distFin));
}
}
return rep;
}
컴파일 시 표준 에러 (stderr) 메시지
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:35:28: warning: unused parameter 'sub' [-Wunused-parameter]
35 | int hubDistance(int N, int sub) {
| ~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |