# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
330664 |
2020-11-26T05:51:38 Z |
IloveN |
Towns (IOI15_towns) |
C++14 |
|
27 ms |
1132 KB |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(vr) vr.begin(),vr.end()
#define vi vector<int>
#define vll vector<ll>
#include "towns.h"
const int N=1e3+10;
namespace myrand
{
mt19937 mt(chrono::system_clock::now().time_since_epoch() / chrono::microseconds(1));
ll Int(ll l,ll r) { return uniform_int_distribution<ll> (l,r)(mt);}
}
using namespace myrand;
/*int getDistance(int x,int y)
{
return 0;
}*/
int dis_t[N];
int hubDistance(int n, int sub) {
int lim;
if (sub==1 || sub==3) lim=n*(n-1)/2;
else if (sub==5) lim=5*n;
else lim=(7*n+1)/2;
int s=Int(1,n),t=0,mx=0;
for (int i=1;i<=n;i++)
if (s!=i)
{
int d=getDistance(s,i);
if (d>mx) mx=d,t=i;
}
for (int i=1;i<=n;i++)
if (i!=t)
{
int d=getDistance(t,i);
dis_t[i]=d;
if (d>mx) mx=d,s=i;
}
int res=mx;
for (int i=1;i<=n;i++)
if (i!=s && i!=t)
{
int d=getDistance(s,i);
int tmp=(d+dis_t[i]-dis_t[s])/2;
res=min(res,max(d-tmp,dis_t[i]-tmp));
}
return res;
}
/*int main()
{
//freopen("ss.inp","r",stdin);
ios::sync_with_stdio(false);
cin.tie(0);
return 0;
}*/
Compilation message
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:39:11: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
39 | int s=Int(1,n),t=0,mx=0;
| ~~~^~~~~
towns.cpp:35:9: warning: variable 'lim' set but not used [-Wunused-but-set-variable]
35 | int lim;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
1004 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
1004 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
17 ms |
876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
1132 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |