# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
71652 |
2018-08-25T09:49:03 Z |
mr_banana |
Towns (IOI15_towns) |
C++17 |
|
37 ms |
824 KB |
#include <bits/stdc++.h>
#include "towns.h"
using namespace std;
const int MN=200,inf=1e9;
int dist[MN][MN];
bool mark[MN][MN];
map<int,int> cnt;
int n;
int getdists(int x){
int mi=0;
for(int i=0;i<n;i++){
if(x!=i && !mark[x][i]){
dist[x][i]=dist[i][x]=getDistance(x,i);
mark[x][i]=mark[i][x]=1;
}
if(dist[x][i]>dist[x][mi]){
mi=i;
}
}
return mi;
}
int hubDistance(int N, int sub) {
cnt.clear();
memset(mark,0,sizeof mark);
memset(dist,0,sizeof dist);
n=N;
int u=getdists(0);
int v=getdists(u);
getdists(v);
int ans=inf;
for(int i=0;i<n;i++){
int d=(dist[i][v]+dist[i][u]-dist[u][v])/2;
cnt[dist[i][v]-d]++;
ans=min(ans,max(dist[i][v],dist[i][u])-d);
}
int n1=0,n2=n;
bool f=0;
for(auto i:cnt){
if(max(i.first,dist[u][v]-i.first)!=ans){
continue;
}
n2-=i.second;
if(n1<=n/2 && n2<=n/2 && i.second<=n/2){
f=1;
}
n1+=i.second;
}
if(f){
return ans;
}
else{
return -ans;
}
}
Compilation message
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:22:28: warning: unused parameter 'sub' [-Wunused-parameter]
int hubDistance(int N, int sub) {
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
504 KB |
Output is correct |
2 |
Correct |
37 ms |
740 KB |
Output is correct |
3 |
Correct |
3 ms |
740 KB |
Output is correct |
4 |
Correct |
27 ms |
824 KB |
Output is correct |
5 |
Correct |
24 ms |
824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
824 KB |
Output is correct |
2 |
Correct |
26 ms |
824 KB |
Output is correct |
3 |
Correct |
36 ms |
824 KB |
Output is correct |
4 |
Correct |
25 ms |
824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
824 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
824 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |