Submission #964109

# Submission time Handle Problem Language Result Execution time Memory
964109 2024-04-16T10:35:09 Z dubabuba Mobile (BOI12_mobile) C++14
0 / 100
562 ms 6972 KB
#include <bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define MP make_pair

const int mxn = 1e5 + 10;
int x[mxn], y[mxn], n, m;

bool can(double R) {
	vector<pair<double, double>> buba;

	for(int i = 0; i < n; i++) {
		const double &X = x[i];
		const double &Y = y[i];
		if(R < Y) continue;
		if(R == Y) {
			if(0.0 <= X && X <= (double) m)
				buba.push_back(MP(X, X));
			continue;
		}

		double d = sqrt(R * R - Y * Y);
		double l = X - d, r = X + d;
		if(r < 0.0 || (double) m < l) continue;
		l = max(l, 0.0);
		r = min(r, (double) m);

		buba.push_back(MP(l, r));
	}

	sort(buba.begin(), buba.end());

	// cout << R << endl;
	// for(auto p : buba)
	// 	cout << p.ff << ' ' << p.ss << endl;

	if(buba[0].ff > 0.0) return 0;
	if(buba.back().ss < (double) m) return 0;
	for(int i = 1; i < buba.size(); i++)
		if(buba[i - 1].ss < buba[i].ff)
			return 0;
	return 1;
}

int main() {
	cin >> n >> m;
	for(int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		y[i] = abs(y[i]);
	}

	double L = 0.0;
	double R = 1e18;

	cout << setprecision(5) << fixed;
	while(R - L > 1e-5) {
		double M = L + (R - L) / 2;
		if(can(M)) R = M;
		else L = M;
	}

	cout << R << endl;
	return 0;
}

Compilation message

mobile.cpp: In function 'bool can(double)':
mobile.cpp:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int i = 1; i < buba.size(); i++)
      |                 ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 1 ms 348 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 852 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 203 ms 6144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 228 ms 5144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 356 ms 5408 KB Output is correct
2 Correct 384 ms 5620 KB Output is correct
3 Correct 455 ms 5484 KB Output is correct
4 Incorrect 226 ms 6808 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 420 ms 6492 KB Output is correct
2 Correct 485 ms 6300 KB Output is correct
3 Correct 531 ms 6440 KB Output is correct
4 Incorrect 236 ms 6824 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 272 ms 6392 KB Output is correct
2 Correct 487 ms 6444 KB Output is correct
3 Correct 562 ms 5884 KB Output is correct
4 Incorrect 220 ms 6972 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 2984 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 49 ms 3708 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 32 ms 2896 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 78 ms 3936 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 35 ms 2996 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 58 ms 4020 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 2896 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 61 ms 3868 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 33 ms 2996 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 56 ms 3892 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -