This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "towns.h"
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for(int i = x; i < y; ++i)
#define pb push_back
vector<vector<int>> D;
//int getDistance(int a, int b){
// return D[a][b];
//}
int hubDistance(int N, int sub) {
//int R = getDistance(0,1);
vector<vector<int>> d(N, vector<int> (N));
FOR(i, 0, N){
FOR(j, i + 1, N){
d[i][j] = getDistance(i, j);
d[j][i] = d[i][j];
}
}
int ans = INT_MAX;
FOR(i, 0, N){
FOR(j, i + 1, N){
FOR(k, j + 1, N){
int big = 0;
int tmp = d[i][j] + d[j][k] + d[k][i];
int a = tmp - 2*d[j][k];
int b = tmp - 2*d[i][k];
int c = tmp - 2*d[i][j];
a /= 2;
b /= 2;
c /= 2;
FOR(h, 0, N){
int as = d[h][i] - a;
int bs = d[h][j] - b;
int cs = d[h][k] - c;
if (as == bs){
big = max(big, as);
}
else if (as == cs){
big = max(big, as);
}
else{
big = max(big, bs);
}
}
ans = min(ans, big);
}
}
}
//cout << ans << "\n";
return ans;
}
/*int main(){
int n, s;
ifstream fin("towns.in");
fin >> n >> s;
fin >> n;
D.resize(n, vector<int>(n));
FOR(i, 0, n){
FOR(j, 0, n){
fin >> D[i][j];
}
}
hubDistance(n, s);
}*/
Compilation message (stderr)
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:12:28: warning: unused parameter 'sub' [-Wunused-parameter]
12 | int hubDistance(int N, int sub) {
| ~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |