# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
732382 |
2023-04-29T03:15:22 Z |
uy842003 |
Mobile (BOI12_mobile) |
C++17 |
|
1000 ms |
48080 KB |
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
const double eps = 1e-7;
bool cmp_less(double a, double b) {
return a + eps < b;
}
bool cmp_less_equal(double a, double b) {
return a < b + eps;
}
bool cmp_range(const pair<double, double> &p1, const pair<double, double> &p2) {
return cmp_less(p1.first, p2.first);
}
bool inside(double l, double r, double m) {
return cmp_less_equal(l, m) && cmp_less_equal(m, r);
}
int main() {
int n;
double len;
cin >> n >> len;
vector<pair<double, double>> cor(n);
for (int i = 0; i < n; i++)
cin >> cor[i].first >> cor[i].second;
double l = 0, r = 2e9 + 7, m;
while (cmp_less(l, r)) {
m = (l + r) / 2;
// cout << "@m " << m << endl;
vector<pair<double, double>> range, real_range;
for (int i = 0; i < n; i++) {
if (cmp_less_equal(m, abs(cor[i].second))) continue;
double dx = sqrt(m * m - cor[i].second * cor[i].second);
range.push_back({cor[i].first - dx, cor[i].first + dx});
}
// cout << "dx ok" << endl;
sort(range.begin(), range.end(), cmp_range);
pair<double, double> cur_range = {-1, -1};
if (range.size() > 0) cur_range = *range.begin();
for (int i = 0; i < range.size(); i++) {
if (inside(cur_range.first, cur_range.second, range[i].first) && cmp_less(cur_range.second, range[i].second))
cur_range.second = range[i].second;
if (!inside(cur_range.first, cur_range.second, range[i].first) || i + 1 == range.size()) {
real_range.push_back(cur_range);
cur_range = range[i];
}
}
// cout << "real range ok" << endl;
bool iok = false;
for (int i = 0; i < real_range.size(); i++) {
if (inside(real_range[i].first, real_range[i].second, 0) && inside(real_range[i].first, real_range[i].second, len)) {
iok = true;
break;
}
}
if (iok)
r = m;
else
l = m + eps;
// cout << "check inside ok" << endl;
}
cout << setprecision(6) << fixed;
cout << r << endl;
return 0;
}
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:47:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for (int i = 0; i < range.size(); i++) {
| ~~^~~~~~~~~~~~~~
mobile.cpp:50:85: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | if (!inside(cur_range.first, cur_range.second, range[i].first) || i + 1 == range.size()) {
| ~~~~~~^~~~~~~~~~~~~~~
mobile.cpp:57:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for (int i = 0; i < real_range.size(); i++) {
| ~~^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
444 KB |
Output is correct |
2 |
Correct |
8 ms |
340 KB |
Output is correct |
3 |
Correct |
5 ms |
340 KB |
Output is correct |
4 |
Correct |
8 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
580 KB |
Output is correct |
2 |
Correct |
20 ms |
640 KB |
Output is correct |
3 |
Correct |
27 ms |
636 KB |
Output is correct |
4 |
Correct |
13 ms |
652 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
596 KB |
Output is correct |
2 |
Correct |
19 ms |
592 KB |
Output is correct |
3 |
Correct |
25 ms |
580 KB |
Output is correct |
4 |
Correct |
11 ms |
580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
580 KB |
Output is correct |
2 |
Correct |
19 ms |
576 KB |
Output is correct |
3 |
Correct |
26 ms |
580 KB |
Output is correct |
4 |
Correct |
12 ms |
596 KB |
Output is correct |
5 |
Correct |
12 ms |
628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
273 ms |
4844 KB |
Output is correct |
2 |
Correct |
435 ms |
4960 KB |
Output is correct |
3 |
Correct |
295 ms |
3684 KB |
Output is correct |
4 |
Correct |
178 ms |
5912 KB |
Output is correct |
5 |
Correct |
134 ms |
3300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
211 ms |
4816 KB |
Output is correct |
2 |
Correct |
201 ms |
5404 KB |
Output is correct |
3 |
Correct |
200 ms |
5936 KB |
Output is correct |
4 |
Correct |
184 ms |
6036 KB |
Output is correct |
5 |
Correct |
181 ms |
6540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
406 ms |
5188 KB |
Output is correct |
2 |
Correct |
486 ms |
5020 KB |
Output is correct |
3 |
Correct |
671 ms |
5988 KB |
Output is correct |
4 |
Correct |
187 ms |
7424 KB |
Output is correct |
5 |
Correct |
237 ms |
6076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
557 ms |
5616 KB |
Output is correct |
2 |
Correct |
616 ms |
5572 KB |
Output is correct |
3 |
Correct |
817 ms |
6564 KB |
Output is correct |
4 |
Correct |
181 ms |
7436 KB |
Output is correct |
5 |
Correct |
251 ms |
6752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
476 ms |
5608 KB |
Output is correct |
2 |
Correct |
602 ms |
6900 KB |
Output is correct |
3 |
Correct |
849 ms |
6676 KB |
Output is correct |
4 |
Correct |
179 ms |
7424 KB |
Output is correct |
5 |
Correct |
256 ms |
6768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1078 ms |
24196 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
24180 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1067 ms |
35860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1070 ms |
35520 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1079 ms |
38684 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1081 ms |
38648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1054 ms |
41936 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1073 ms |
29300 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1069 ms |
48080 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1071 ms |
15956 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |