Submission #115048

# Submission time Handle Problem Language Result Execution time Memory
115048 2019-06-04T21:59:49 Z luciocf Mobile (BOI12_mobile) C++14
0 / 100
1000 ms 672 KB
#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

typedef double dd;

typedef pair<dd, dd> pt;

const int maxn = 5e3+10;
const double inf = 2e18+10;
const double eps = 1e-9;

int n;
dd L;

pt p[maxn];

dd dist(pt a, pt b)
{
	dd d1 = a.x-b.x;
	dd d2 = a.y-b.y;

	return sqrt(d1*d1 + d2*d2);
}

bool ok(dd X, int ind)
{
	dd ans = inf;
	for (int i = 1; i <= n; i++)
		ans = min(ans, dist({X, 0.00}, p[i]));

	if (fabs(ans-dist({X, 0.00}, p[ind])) < eps) return true;
	return false;
}

dd busca_right(int ind)
{
	dd ini = p[ind].x, fim = L, ans = -1.00;

	for (int i = 1; i <= 64; i++)
	{
		dd mid = (ini+fim)/2.00;

		if (ok(mid, ind)) ans = mid, ini = mid;
		else fim = mid;
	}

	return ans;
}

dd busca_left(int ind)
{
	dd ini = 0.00, fim = p[ind].x, ans = -1.00;

	for (int i = 1; i <= 64; i++)
	{
		dd mid = (ini+fim)/2.00;

		if (ok(mid, ind)) ans = mid, fim = mid;
		else ini = mid;
	}

	return ans;
}

int main(void)
{
	scanf("%d %lf", &n, &L);

	for (int i = 1; i <= n; i++)
		scanf("%lf %lf", &p[i].x, &p[i].y);

	dd ans = 0.00;

	for (int i = 1; i <= n; i++)
	{
		dd posR = busca_right(i);
		dd posL = busca_left(i);

		if (posR != -1)
			ans = max(ans, dist({posR, 0.00}, p[i]));

		if (posL != -1)
			ans = max(ans, dist({posL, 0.00}, p[i]));
	}

	printf("%.6lf\n", ans);
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:71:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %lf", &n, &L);
  ~~~~~^~~~~~~~~~~~~~~~~~
mobile.cpp:74:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lf %lf", &p[i].x, &p[i].y);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Incorrect 2 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -