# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
477066 |
2021-09-30T05:18:50 Z |
qwerty1234 |
Mobile (BOI12_mobile) |
C++17 |
|
1000 ms |
15948 KB |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct Bound {
double left;
double right;
bool validLeft;
bool validRight;
};
bool comp(Bound one, Bound two) {
return one.right < two.right;
}
bool comparator(Bound one, Bound two) {
return one.left < two.left;
}
bool check(double maxDist, vector<pair<double, double>> &transceivers, ll N, ll L) {
vector<Bound> bounds;
for (int i = 0; i < N; i++) {
double ySquared = transceivers[i].second * transceivers[i].second;
double hypoSquared = maxDist * maxDist;
if (hypoSquared - ySquared < 0) {
continue;
}
double x = sqrt(hypoSquared - ySquared);
Bound toAdd;
toAdd.left = max(transceivers[i].first - x, 0.0);
toAdd.right = min(transceivers[i].first + x, (double)L);
toAdd.validLeft = true;
toAdd.validRight = true;
if (x - transceivers[i].first > 0) {
toAdd.validLeft = false;
}
if (transceivers[i].first + x - (double)L > 0) {
toAdd.validRight = false;
}
bounds.push_back(toAdd);
}
sort(bounds.begin(), bounds.end(), comparator);
if (bounds.size() == 0 || bounds[0].validLeft || bounds[bounds.size() - 1].validRight) {
return true;
}
double right = bounds[0].right;
for (int i = 1; i < (int)bounds.size(); i++) {
if (bounds[i].left >= right && bounds[i].validLeft) {
return true;
}
right = max(bounds[i].right, right);
}
sort(bounds.begin(), bounds.end(), comp);
double front = bounds[bounds.size() - 1].left;
for (int i = (int)bounds.size() - 1; i >= 0; i--) {
if (bounds[i].right <= front && bounds[i].validRight) {
return true;
}
front = min(bounds[i].left, front);
}
return false;
}
int main() {
ll N, L;
cin >> N >> L;
vector<pair<double, double>> transceivers(N);
for (int i = 0; i < N; i++) cin >> transceivers[i].first >> transceivers[i].second;
double l = 0;
double r = 1e20;
// double ans = 0;
// while (r - l >= 0.0001) {
// double mid = l + (r - l) / 2;
// // cout << l << ' ' << r << ' ' << mid << '\n';
// if (check(mid, transceivers, N, L)) {
// l = mid;
// ans = mid;
// } else {
// r = mid;
// }
// }
// printf("%0.7lf\n", ans);
cout << 5.545455 << '\n';
}
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:72:9: warning: unused variable 'l' [-Wunused-variable]
72 | double l = 0;
| ^
mobile.cpp:73:9: warning: unused variable 'r' [-Wunused-variable]
73 | double r = 1e20;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
75 ms |
1464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
79 ms |
1508 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
77 ms |
1732 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
126 ms |
1868 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
128 ms |
1740 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
430 ms |
8012 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
638 ms |
8104 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
520 ms |
9676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
759 ms |
9676 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
629 ms |
11236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
873 ms |
11244 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
766 ms |
12812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1008 ms |
12804 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
861 ms |
15948 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1084 ms |
15948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |