# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
331024 |
2020-11-27T04:35:08 Z |
IloveN |
Towns (IOI15_towns) |
C++14 |
|
0 ms |
0 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[N][N];
int lim;
int get(int x,int y)
{
if (x==y) return 0;
if (dis[x][y]) return dis[x][y];
lim--;
return (dis[x][y]=dis[y][x]=getDistance(x-1,y-1));
}
int hubDistance(int n, int sub)
{
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++)
for (int j=1;j<=n;j++) dis[i][j]=0;
for (int i=1;i<=n;i++)
if (s!=i)
{
int d=get(s,i);
if (d>mx) mx=d,t=i;
}
for (int i=1;i<=n;i++)
if (i!=t)
{
int d=get(t,i);
dis[t][i]=d;
if (d>mx) mx=d,s=i;
}
int res=mx,flag=0;
vi lc(n+1);
for (int i=1;i<=n;i++)
if (i!=s && i!=t)
{
int d=get(s,i);
int tmp=(d+dis[t][i]-dis[t][s])/2;
res=min(res,max(d-tmp,dis[t][i]-tmp));
}
map<int,int> cnt;
for (int i=1;i<=n;i++)
{
int d=(dis[s][i]+dis[t][i]-dis[s][t])/2;
if (dis[t][i]-d==res) flag |= 1;
if (dis[s][i]-d==res) flag |= 2;
lc[i]=dis[s][i]-d;
}
int check=0;
if (flag&1)
{
int siz1=0,siz2=0,siz3=0;
for (int i=1;i<=n;i++)
if (lc[i]<mx-res) siz1++;
else if (lc[i]==mx-res) siz2++;
else siz3++;
if (max({siz1,siz2,siz3})<=n/2) check=1;
}
else
{
int siz1=0,siz2=0,siz3=0;
for (int i=1;i<=n;i++)
if (lc[i]<res) siz1++;
else if (lc[i]==res) siz2++;
else siz3++;
if (max({siz1,siz2,siz3})<=n/2) check=1;
}
if (check) return res;
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 getDistance(int, int)':
towns.cpp:26:21: warning: unused parameter 'x' [-Wunused-parameter]
26 | int getDistance(int x,int y)
| ~~~~^
towns.cpp:26:27: warning: unused parameter 'y' [-Wunused-parameter]
26 | int getDistance(int x,int y)
| ~~~~^
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:47:11: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
47 | int s=Int(1,n),t=0,mx=0;
| ~~~^~~~~
/tmp/cchAalHr.o: In function `getDistance(int, int)':
grader.c:(.text+0x110): multiple definition of `getDistance(int, int)'
/tmp/ccOR0aji.o:towns.cpp:(.text+0x0): first defined here
/tmp/cchAalHr.o: In function `main':
grader.c:(.text.startup+0x0): multiple definition of `main'
/tmp/ccOR0aji.o:towns.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status