# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
31013 |
2017-08-04T02:57:20 Z |
kajebiii |
Towns (IOI15_towns) |
C++14 |
|
33 ms |
2072 KB |
#include "towns.h"
#include <bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<double, double> pd;
typedef pair<int, int> pi;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll; typedef pair<ll, pi> plp;
typedef tuple<int, int, int> ti; typedef tuple<ll, int, int> tli;
const int INF = 0x3f2f1f0f;
const ll LINF = 1ll * INF * INF * 2;
map<pi, int> Mp;
int getD(int i, int j) {
if(Mp.count(pi(i, j)) == 0) Mp[pi(i, j)] = Mp[pi(j, i)] = getDistance(i, j);
return Mp[pi(i, j)];
}
int N, Sub;
int hubDistance(int n, int sub) {
Mp.clear();
N = n; Sub = sub;
int max0D = -1, f = -1;
for(int i=0; i<N; i++) {
if(i == 0) continue;
int d = getD(0, i);
if(max0D < d) max0D = d, f = i;
}
int maxfD = -1, s = -1;
for(int i=0; i<N; i++) {
if(i == f) continue;
int d = getD(f, i);
if(maxfD < d) maxfD = d, s = i;
}
int R = INF;
for(int i=0; i<N; i++) {
int all = (getD(f, i) + getD(i, s) + getD(s, f) ) / 2;
int fd = all - getD(i, s);
int sd = all - getD(i, f);
int id = all - getD(s, f);
// printf("%d %d %d -> %d %d %d\n", f, s, i, fd, sd, id);
R = min(R, max(fd, sd));
}
return R;
}
Compilation message
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:49:13: warning: unused variable 'id' [-Wunused-variable]
int id = all - getD(s, f);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
2072 KB |
Output is correct |
2 |
Correct |
19 ms |
2072 KB |
Output is correct |
3 |
Correct |
0 ms |
2072 KB |
Output is correct |
4 |
Correct |
26 ms |
2072 KB |
Output is correct |
5 |
Correct |
33 ms |
2072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
2072 KB |
Output is correct |
2 |
Correct |
16 ms |
2072 KB |
Output is correct |
3 |
Correct |
33 ms |
2072 KB |
Output is correct |
4 |
Correct |
29 ms |
2072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
2072 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
33 ms |
2072 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
2072 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
2072 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |