# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
481864 |
2021-10-22T04:11:07 Z |
sberens |
Mobile (BOI12_mobile) |
C++17 |
|
1000 ms |
47408 KB |
#pragma GCC optimize ("O3,fast-math,inline")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename K> using hset = gp_hash_table<K, null_type>;
template <typename K, typename V> using hmap = gp_hash_table<K, V>;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define smax(x, y) (x = max(x, y))
#define smin(x, y) (x = min(x, y))
using ld = long double;
using ll = long long;
template <typename T>
using vv = vector<vector<T>>;
using vi = vector<int>;
using ii = array<int, 2>;
using vii = vector<ii>;
using vvi = vv<int>;
using vll = vector<ll>;
using l2 = array<int, 2>;
using vl2 = vector<l2>;
using vvll = vv<ll>;
template <typename T>
using minq = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxq = priority_queue<T>;
const ll M = 1000000007;
#ifndef REFERENCE_DISCRETE_BINARY_SEARCH_H
#define REFERENCE_DISCRETE_BINARY_SEARCH_H
#include <iostream>
#include <functional>
template<typename IN>
IN discrete_binary_search(function<bool(IN)> predicate, IN low = 0, IN high = numeric_limits<IN>::max()) {
while (fabs(high - low) > 1e-4) {
IN middle = low + (high - low) / 2; // todo std::midpoint in cpp 2020
if (predicate(middle))
high = middle;
else low = middle;
}
return low;
}
#endif //REFERENCE_DISCRETE_BINARY_SEARCH_H
inline bool a_contains_b(array<ld, 2> a, array<ld, 2> b) {
return a[0] <= b[0] && b[1] <= a[1];
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, l;
cin >> n >> l;
vll x(n), y(n);
for (int i = 0; i < n; ++i) {
cin >> x[i] >> y[i];
}
cout << fixed << setprecision(4) << discrete_binary_search<ld>([&](ld d) -> bool {
// is there a point with min distance > d
// equivalently, is every point within distance d
vector<array<ld, 2>> intervals;
intervals.reserve(n);
// add to intervals
for (int i = 0; i < n; ++i) {
if (abs(y[i]) > d) continue;
ld dx = sqrt(d * d - y[i] * y[i]);
// get rid of nested intervals
array<ld, 2> new_interval{x[i] - dx, x[i] + dx};
while (!intervals.empty() && a_contains_b(new_interval, intervals.back())) {
intervals.pop_back();
}
if (!(!intervals.empty() && a_contains_b(intervals.back(), new_interval)))
intervals.pb(new_interval);
}
// merge intervals
vector<array<ld, 2>> merged;
merged.reserve(n);
for (auto [s, e] : intervals) {
if (!merged.empty() && s <= merged.back()[1]) smax(merged.back()[1], e);
else merged.pb({s, e});
}
// check interval spans whole highway
return any_of(all(merged), [&](array<ld, 2> interval) -> bool {return a_contains_b(interval, {0, (ld) l});});
}, 0, sqrt(1e18 + 4 * 1e18 + 1e10)) << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
368 KB |
Output is correct |
2 |
Correct |
4 ms |
432 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
4 ms |
428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
472 KB |
Output is correct |
2 |
Correct |
7 ms |
552 KB |
Output is correct |
3 |
Correct |
4 ms |
552 KB |
Output is correct |
4 |
Correct |
6 ms |
540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
492 KB |
Output is correct |
2 |
Correct |
8 ms |
552 KB |
Output is correct |
3 |
Correct |
4 ms |
416 KB |
Output is correct |
4 |
Correct |
5 ms |
524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
556 KB |
Output is correct |
2 |
Correct |
11 ms |
552 KB |
Output is correct |
3 |
Correct |
5 ms |
436 KB |
Output is correct |
4 |
Correct |
5 ms |
664 KB |
Output is correct |
5 |
Correct |
5 ms |
420 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
3728 KB |
Output is correct |
2 |
Correct |
80 ms |
3200 KB |
Output is correct |
3 |
Correct |
74 ms |
2848 KB |
Output is correct |
4 |
Correct |
41 ms |
2148 KB |
Output is correct |
5 |
Correct |
29 ms |
1428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
1868 KB |
Output is correct |
2 |
Correct |
56 ms |
2528 KB |
Output is correct |
3 |
Correct |
60 ms |
3276 KB |
Output is correct |
4 |
Correct |
42 ms |
2252 KB |
Output is correct |
5 |
Correct |
39 ms |
2108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
144 ms |
4604 KB |
Output is correct |
2 |
Correct |
86 ms |
3152 KB |
Output is correct |
3 |
Correct |
128 ms |
3984 KB |
Output is correct |
4 |
Correct |
39 ms |
2316 KB |
Output is correct |
5 |
Correct |
60 ms |
2284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
133 ms |
3032 KB |
Output is correct |
2 |
Correct |
96 ms |
3140 KB |
Output is correct |
3 |
Correct |
74 ms |
2452 KB |
Output is correct |
4 |
Correct |
40 ms |
2428 KB |
Output is correct |
5 |
Correct |
65 ms |
3948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
192 ms |
5104 KB |
Output is correct |
2 |
Correct |
93 ms |
3148 KB |
Output is correct |
3 |
Correct |
76 ms |
2456 KB |
Output is correct |
4 |
Correct |
43 ms |
2292 KB |
Output is correct |
5 |
Correct |
65 ms |
3820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
940 ms |
23976 KB |
Output is correct |
2 |
Correct |
399 ms |
8420 KB |
Output is correct |
3 |
Correct |
385 ms |
8456 KB |
Output is correct |
4 |
Correct |
193 ms |
8644 KB |
Output is correct |
5 |
Correct |
261 ms |
12740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
418 ms |
8556 KB |
Output is correct |
2 |
Correct |
737 ms |
23692 KB |
Output is correct |
3 |
Correct |
380 ms |
11168 KB |
Output is correct |
4 |
Correct |
200 ms |
8664 KB |
Output is correct |
5 |
Correct |
242 ms |
10948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1071 ms |
28568 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
467 ms |
10120 KB |
Output is correct |
2 |
Correct |
851 ms |
28300 KB |
Output is correct |
3 |
Correct |
427 ms |
11804 KB |
Output is correct |
4 |
Correct |
240 ms |
10180 KB |
Output is correct |
5 |
Correct |
278 ms |
12972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1089 ms |
33396 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
552 ms |
11584 KB |
Output is correct |
2 |
Correct |
944 ms |
32912 KB |
Output is correct |
3 |
Correct |
546 ms |
15272 KB |
Output is correct |
4 |
Correct |
267 ms |
11904 KB |
Output is correct |
5 |
Correct |
330 ms |
14988 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
38104 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
660 ms |
13020 KB |
Output is correct |
2 |
Execution timed out |
1057 ms |
37624 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1097 ms |
47408 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
770 ms |
16228 KB |
Output is correct |
2 |
Execution timed out |
1088 ms |
46680 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |