#include "towns.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int nax = 120;
int n,dis[nax][nax],ans;
int query(int a,int b){
if(dis[a][b] != 0)
return dis[a][b];
dis[a][b] = dis[b][a] = getDistance(a,b);
return dis[a][b];
}
int far(int u){
int mx = 0,v = -1;
for(int i=0;i<n;i++){
if(i == u)
continue;
int cur = query(u,i);
if(cur > mx){
mx = cur;
v = i;
}
}
return v;
}
int hubDistance(int N, int sub){
n = N;
int a = far(0);
int b = far(a);
far(b);
ans = 2e9;
for(int i=0;i<n;i++){
if(a == i || b == i)
continue;
// int disa = query(i,a);
// int disb = query(i,b);
int cur = (dis[a][i] + dis[b][i] - dis[a][b]) / 2;
ans = min(ans,max(dis[a][i],dis[b][i]) - cur);
}
if(sub == 1 || sub == 2)
return ans;
else
assert(0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
18 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
18 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |