제출 #257038

#제출 시각아이디문제언어결과실행 시간메모리
257038eohomegrownapps도시들 (IOI15_towns)C++14
25 / 100
22 ms1152 KiB
#include "towns.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> distv; int n; int dist(int a, int b){ if (a==b){return 0;} if (a>b){ swap(a,b); } if (distv[a][b]!=-1){ return distv[a][b]; } else { return distv[a][b]=getDistance(a,b); } } int hubDistance(int N, int sub) { n=N; distv.assign(n,vector<int>(n,-1)); int adist = -1; int aind = -1; for (int i = 0; i<n; i++){ int ds = dist(0,i); if (adist<ds){ adist=ds; aind=i; } } int bdist = -1; int bind = -1; for (int i = 0; i<n; i++){ int ds = dist(aind,i); if (bdist<ds){ bdist=ds; bind=i; } } //from adist to aind //vector<int> diameter; int hubdist = 1e9; int hubind = -1; for (int i = 0; i<n; i++){ if (i==aind||i==bind){continue;} int distfroma = dist(aind,i)-(dist(aind,i)+dist(bind,i)-dist(aind,bind))/2; int rv = max(distfroma,dist(aind,bind)-distfroma); if (rv<hubdist){ hubdist=rv; hubind=i; } } return hubdist; }

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

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:48:9: warning: variable 'hubind' set but not used [-Wunused-but-set-variable]
     int hubind = -1;
         ^~~~~~
towns.cpp:20:28: warning: unused parameter 'sub' [-Wunused-parameter]
 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...