제출 #1082415

#제출 시각아이디문제언어결과실행 시간메모리
1082415PanosPask도시들 (IOI15_towns)C++14
25 / 100
16 ms1112 KiB
#include "towns.h" #include <vector> using namespace std; int N; int diameter = 0; int v, s, t; vector<int> d1; vector<int> d2; void findAll(int u, vector<int>& d) { d.resize(N); d[u] = 0; for (int i = 0; i < N; i++) { if (i != u) { d[i] = getDistance(u, i); } } } int getPos(vector<int>& d) { int m_i = -1; int m_v = -1; for (int i = 0; i < N; i++) { if (d[i] > m_v) { m_i = i; m_v = d[i]; } } return m_i; } int distance(int i, int j) { if (i == v) { return d1[j]; } else if (j == v) { return d1[i]; } else if (i == s) { return d2[j]; } else if (j == s) { return d2[i]; } return getDistance(i, j); } int distFromS(int node) { int commonpath = 0; if (node != v) { commonpath = (distance(node, v) + distance(node, s) - distance(v, s)) / 2; } else { commonpath = (distance(node, t) + distance(node, s) - distance(t, s)) / 2; } return distance(s, node) - commonpath; } int hubDistance(int n, int sub) { N = n; v = 0; findAll(v, d1); s = getPos(d1); findAll(s, d2); t = getPos(d2); diameter = d2[t]; int ans1 = 0; int ans2 = diameter; for (int i = 0; i < N; i++) { int res = distFromS(i); if (2 * res < diameter) { ans1 = max(ans1, res); } else { ans2 = min(ans2, res); } } return min(ans2, diameter - ans1); }

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

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