# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1011703 |
2024-07-01T07:03:22 Z |
hotboy2703 |
Towns (IOI15_towns) |
C++17 |
|
14 ms |
1116 KB |
#include "towns.h"
#include<bits/stdc++.h>
using namespace std;
using ll = int;
#define pll pair <ll,ll>
#define fi first
#define se second
#define MP make_pair
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1)
#define MASK(i) (1LL << (i))
const ll MAXN = 120;
ll dist[3][MAXN];
ll n;
ll get_dist(ll u,ll d[]){
ll res = 0;
for (ll i = 0;i < n;i ++){
if (i == u){
d[u] = 0;
}
else{
d[i] = getDistance(i,u);
if (d[res] < d[i])res = i;
}
}
return res;
}
int hubDistance(int N, int sub) {
n=N;
ll a = get_dist(0,dist[0]);
ll b = get_dist(a,dist[1]);
get_dist(b,dist[2]);
ll res = 1e9;
for (ll i = 0;i < n;i ++){
ll ab,ac,bc,abc;
ab = dist[1][b];
ac = dist[1][i];
bc = dist[2][i];
abc = (ab+ac+bc)/2;
res = min(res,max(abc-bc,abc-ac));
}
// cout<<a<<' '<<b<<'\n';
return res;
}
Compilation message
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:29:28: warning: unused parameter 'sub' [-Wunused-parameter]
29 | int hubDistance(int N, int sub) {
| ~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
860 KB |
Output is correct |
2 |
Correct |
7 ms |
856 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
10 ms |
860 KB |
Output is correct |
5 |
Correct |
10 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
860 KB |
Output is correct |
2 |
Correct |
7 ms |
856 KB |
Output is correct |
3 |
Correct |
10 ms |
856 KB |
Output is correct |
4 |
Correct |
10 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
856 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |