This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "towns.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll i,j,d[1010][1010],jum[1010],p[1010],has;
vector<ll> isi[1010];
int hubDistance(int N, int sub)
{
memset(d,0,sizeof(d));
for(i=0;i<N;i++)
isi[i].clear();
has=0;
for(i=0;i<N;i++)
for(j=i+1;j<N;j++)
{
d[i][j]=getDistance(i,j);
d[j][i]=d[i][j];
}
memset(p,-1,sizeof(p));
for(i=0;i<N;i++)
for(j=0;j<N;j++)
jum[i]+=d[i][j];
for(i=0;i<N;i++)
for(j=i+1;j<N;j++)
{
ll tem=abs(jum[j]-jum[i]),X,Y;
tem/=(N-2);
X=(d[i][j]-tem)/2;
Y=d[i][j]-X;
if(jum[i]>jum[j])
swap(X,Y);
//cout<<i<<" "<<j<<" "<<d[i][j]<<" "<<tem<<" "<<X<<" "<<Y<<"\n";
isi[i].pb(X);
isi[j].pb(Y);
}
for(i=0;i<N;i++)
{
sort(isi[i].begin(),isi[i].end());
has=max(has,isi[i][N-2]);
//for(j=0;j<isi[i].size();j++)
// cout<<i<<" "<<j<<" "<<isi[i][j]<<"\n";
}
return has;
}
Compilation message (stderr)
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:20:27: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
d[i][j]=getDistance(i,j);
^
towns.cpp:20:27: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
towns.cpp:47:9: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
return has;
^~~
towns.cpp:11:28: warning: unused parameter 'sub' [-Wunused-parameter]
int hubDistance(int N, int sub)
^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |