Submission #119742

# Submission time Handle Problem Language Result Execution time Memory
119742 2019-06-22T07:09:01 Z WhipppedCream Towns (IOI15_towns) C++17
25 / 100
19 ms 896 KB
#include "towns.h"
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 120;

int m, n;

int dist[maxn];

map<int, int> faker;
map<int, int> cnt;

int hubDistance(int N, int sub)
{
	faker.clear();
	if(sub > 2 && sub != 4) return 0;
	n = N;
	int best = 0, dat = -1;
	for(int i = 1; i< N; i++)
	{
		int here = getDistance(0, i);
		if(here> best)
		{
			best = here;
			dat = i;
		}
	}
	int U = dat;
	best = 0; dat = -1;
	for(int i = 0; i< N; i++)
	{
		if(i == U) continue;
		dist[i] = getDistance(U, i);
		if(dist[i]> best)
		{
			best = dist[i];
			dat = i;
		}
	}
	int V = dat;
	// printf("(%d->%d) %d\n", U, V, dist[V]);
	for(int i = 0; i< N; i++)
	{
		if(i == U || i == V) continue;
		int br = dist[i]+getDistance(V, i)-dist[V];
		br /= 2;
		int run = dist[i]-br;
		faker[run] = max(faker[run], br);
		cnt[run]++;
	}
	int rad = 1e9;
	int cm = 1;
	bool good = false;
	for(auto kk : faker)
	{
		int x = kk.X, y = kk.Y;
		// printf("%d: %d\n", x, cnt[x]);
		rad = min(rad, max(y, max(x, dist[V]-x)));
		if(max(cm, max(cnt[x], n-cnt[x]-cm))<= n/2) good = true;
		cm += cnt[x];
	}
	return good?rad:-rad;
}
# Verdict Execution time Memory Grader output
1 Correct 18 ms 384 KB Output is correct
2 Correct 14 ms 768 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 18 ms 896 KB Output is correct
5 Correct 19 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 384 KB Output is correct
2 Correct 14 ms 740 KB Output is correct
3 Correct 17 ms 896 KB Output is correct
4 Correct 18 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 452 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -