# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
481851 |
2021-10-22T03:43:41 Z |
sberens |
Mobile (BOI12_mobile) |
C++17 |
|
1000 ms |
65268 KB |
#pragma GCC optimize ("fast-math")
#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;
// 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({x[i] - dx, x[i] + dx});
}
// merge intervals
vector<array<ld, 2>> merged;
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, 2e15) << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 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 |
332 KB |
Output is correct |
2 |
Correct |
7 ms |
796 KB |
Output is correct |
3 |
Correct |
3 ms |
332 KB |
Output is correct |
4 |
Correct |
7 ms |
568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
608 KB |
Output is correct |
2 |
Correct |
16 ms |
808 KB |
Output is correct |
3 |
Correct |
5 ms |
332 KB |
Output is correct |
4 |
Correct |
12 ms |
812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
704 KB |
Output is correct |
2 |
Correct |
17 ms |
808 KB |
Output is correct |
3 |
Correct |
5 ms |
420 KB |
Output is correct |
4 |
Correct |
8 ms |
812 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
812 KB |
Output is correct |
2 |
Correct |
15 ms |
808 KB |
Output is correct |
3 |
Correct |
5 ms |
332 KB |
Output is correct |
4 |
Correct |
8 ms |
808 KB |
Output is correct |
5 |
Correct |
6 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
234 ms |
7828 KB |
Output is correct |
2 |
Correct |
139 ms |
5344 KB |
Output is correct |
3 |
Correct |
128 ms |
4912 KB |
Output is correct |
4 |
Correct |
113 ms |
8004 KB |
Output is correct |
5 |
Correct |
45 ms |
1100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
77 ms |
1944 KB |
Output is correct |
2 |
Correct |
119 ms |
4640 KB |
Output is correct |
3 |
Correct |
135 ms |
7928 KB |
Output is correct |
4 |
Correct |
120 ms |
8168 KB |
Output is correct |
5 |
Correct |
114 ms |
8576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
305 ms |
8796 KB |
Output is correct |
2 |
Correct |
147 ms |
5356 KB |
Output is correct |
3 |
Correct |
234 ms |
8184 KB |
Output is correct |
4 |
Correct |
107 ms |
9084 KB |
Output is correct |
5 |
Correct |
109 ms |
3292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
183 ms |
5300 KB |
Output is correct |
2 |
Correct |
152 ms |
5328 KB |
Output is correct |
3 |
Correct |
134 ms |
2912 KB |
Output is correct |
4 |
Correct |
107 ms |
9092 KB |
Output is correct |
5 |
Correct |
157 ms |
8576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
351 ms |
9196 KB |
Output is correct |
2 |
Correct |
138 ms |
5308 KB |
Output is correct |
3 |
Correct |
112 ms |
2916 KB |
Output is correct |
4 |
Correct |
126 ms |
9116 KB |
Output is correct |
5 |
Correct |
162 ms |
8732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
40676 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
441 ms |
9064 KB |
Output is correct |
2 |
Execution timed out |
1087 ms |
40352 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1045 ms |
59204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
519 ms |
10260 KB |
Output is correct |
2 |
Execution timed out |
1089 ms |
58992 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1087 ms |
60604 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
602 ms |
11720 KB |
Output is correct |
2 |
Execution timed out |
1090 ms |
60680 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
62280 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
653 ms |
13436 KB |
Output is correct |
2 |
Execution timed out |
1092 ms |
62208 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1100 ms |
65212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
817 ms |
16524 KB |
Output is correct |
2 |
Execution timed out |
1094 ms |
65268 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |