Submission #387304

#TimeUsernameProblemLanguageResultExecution timeMemory
387304KeshiTowns (IOI15_towns)C++17
0 / 100
21 ms908 KiB
//In the name of God
#include <bits/stdc++.h>
#include "towns.h"
using namespace std;

typedef int ll;
typedef pair<ll, ll> pll;

const ll maxn = 2e5 + 100;
const ll mod = 1e9 + 7;
const ll inf = 1e9;

#define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io freopen("input.txt", "r+", stdin);freopen("output.txt", "w+", stdout);
#define pb push_back
#define Mp make_pair
#define F first
#define S second
#define Sz(x) ll((x).size())
#define all(x) (x).begin(), (x).end()

int d[3][maxn], dis[maxn], sz[maxn], h[maxn];

int solve3(int n){
	return 0;
}

int solve4(int n){
	ll v = 0;
	for(ll i = 1; i < n; i++){
		d[0][i] = getDistance(0, i);
		if(d[0][i] > d[0][v]) v = i;
	}
	ll u = v;
	for(ll i = 0; i < n; i++){
		d[1][i] = getDistance(v, i);
		if(d[1][i] > d[1][u]) u = i;
	}
	for(ll i = 0; i < n; i++){
		d[2][i] = getDistance(u, i);
	}
	ll D = d[1][u];
	map<ll, ll> mp;
	ll t = 1;
	for(ll i = 0; i < n; i++){
		h[i] = (d[1][i] + d[2][i] - D) / 2;
		if(!mp[d[1][i] - h[i]]){
			mp[d[1][i] - h[i]] = t;
			dis[t] = d[1][i] - h[i];
			sz[t] = 0;
			t++;
		}
		sz[mp[d[1][i] - h[i]]]++;
	}
	ll R = inf;
	for(ll i = 1; i < t; i++){
		R = min(R, max(dis[i], D - dis[i]));
	}
	return R;
}

int hubDistance(int n, int sub) {
	//if(sub == 3) return solve3(n);
	return solve4(n);
}

/*int main(){
    fast_io;



    return 0;
}*/

Compilation message (stderr)

towns.cpp: In function 'int solve3(int)':
towns.cpp:24:16: warning: unused parameter 'n' [-Wunused-parameter]
   24 | int solve3(int n){
      |            ~~~~^
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:62:28: warning: unused parameter 'sub' [-Wunused-parameter]
   62 | int hubDistance(int n, int sub) {
      |                        ~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...