제출 #795393

#제출 시각아이디문제언어결과실행 시간메모리
795393jasmin도시들 (IOI15_towns)C++17
25 / 100
16 ms884 KiB
#include "towns.h" #include<bits/stdc++.h> using namespace std; int hubDistance(int n, int sub) { //find diameter vector<int> dist0(n); int a=1; for(int i=1; i<n; i++){ dist0[i] = getDistance(0, i); if(dist0[i]>dist0[a]){ a=i; } } int b=0; vector<int> dista(n); dista[0] = dist0[a]; for(int i=1; i<n; i++){ if(i==a) continue; dista[i] = getDistance(a, i); if(dista[i] > dista[b]){ b=i; } } vector<int> distb(n); distb[0] = dist0[b]; distb[a] = dista[b]; for(int i=1; i<n; i++){ if(i==a || i==b) continue; distb[i] = getDistance(b, i); } int diameter = dista[b]; //group the leafes vector<int> dleft(n); dleft[a]=0; dleft[b]=diameter; vector<int> ddiam(n); ddiam[a]=ddiam[b]=0; map<int, vector<int> > group; for(int i=0; i<n; i++){ if(i==a || i==b) continue; ddiam[i] = (dista[i]+distb[i] - diameter)/2; dleft[i] = dista[i]-ddiam[i]; group[dleft[i]].push_back(i); } //compute r int r=diameter; for(auto [x, g]: group){ r = min(r, max(x, diameter-x)); } return r; }

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

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:5:28: warning: unused parameter 'sub' [-Wunused-parameter]
    5 | 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...