제출 #837564

#제출 시각아이디문제언어결과실행 시간메모리
837564oscar1f도시들 (IOI15_towns)C++17
25 / 100
16 ms360 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...