# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
60184 |
2018-07-23T20:24:52 Z |
istlemin |
Towns (IOI15_towns) |
C++14 |
|
26 ms |
1080 KB |
#include "towns.h"
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)
typedef int ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;
ll n;
vector<vi> distMem;
ll distance(ll a,ll b){
if(distMem[a][b]!=-1) return distMem[a][b];
return distMem[a][b] = distMem[b][a] = getDistance(a,b);
}
pii getFurthest(ll v){
ll furthest = 0;
ll mx = 0;
rep(i,0,n){
ll dist = distance(v,i);
if(dist>mx){
mx = dist;
furthest = i;
}
}
return {furthest,mx};
}
int hubDistance(int N, int sub) {
n = N;
distMem.resize(n+1,vi(n+1,-1));
ll diaA = getFurthest(0).first;
pii tmp = getFurthest(diaA);
ll diaB = tmp.first;
ll diameter = tmp.second;
map<ll,ll> pointsOnDiameter;
rep(i,0,n){
if(i==diaA||i==diaB) continue;
ll distA = distance(i,diaA);
ll distB = distance(i,diaB);
ll distFromDiameter = (distA+distB-diameter)/2;
pointsOnDiameter[distA-distFromDiameter]++;
}
ll minR = 1e9;
ll center = 0;
trav(x,pointsOnDiameter){
ll currR = max(x.first,diameter-x.first);
if(currR<minR){
center = x.first;
minR = currR;
}
}
return minR;
//if(pointsOnDiameter[center]<=n/2) return
}
Compilation message
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:59:8: warning: variable 'center' set but not used [-Wunused-but-set-variable]
ll center = 0;
^~~~~~
towns.cpp:37:28: warning: unused parameter 'sub' [-Wunused-parameter]
int hubDistance(int N, int sub) {
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
26 ms |
760 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
12 ms |
900 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
920 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
936 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
1072 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
1080 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |