제출 #1027396

#제출 시각아이디문제언어결과실행 시간메모리
1027396Dan4Life도시들 (IOI15_towns)C++17
25 / 100
10 ms904 KiB
#include "towns.h" #include <bits/stdc++.h> using namespace std; using ar2 = array<int,2>; int n; int mem[120][120]; map<int,int> M; int dis(int a, int b){ if(a==b) return 0; if(mem[a][b]!=-1) return mem[a][b]; if(mem[b][a]!=-1) return mem[b][a]; return mem[a][b]=mem[b][a]=getDistance(a,b); } int hubDistance(int N, int sub) { n = N; ar2 mx = {0,0}; int a = 0, b = 0; M.clear(); memset(mem,-1,sizeof(mem)); for(int i = 0; i < n; i++) mx=max(mx,{dis(a,i),i}); a = mx[1]; mx = {0,0}; for(int i = 0; i < n; i++) mx=max(mx,{dis(a,i),i}); b = mx[1]; int diameter = dis(a,b); int ans = diameter; for(int i = 0; i < n; i++){ if(i==a or i==b) continue; int branch = (dis(a,i)+dis(b,i)-diameter)/2; int lpos = dis(a,i)-branch; int rpos = diameter-lpos; M[lpos]=max({M[lpos],branch,lpos,rpos}); } for(auto u : M) ans=min(ans,u.second); return ans; }

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

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