# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
935529 |
2024-02-29T08:52:22 Z |
cryan |
Mobile (BOI12_mobile) |
C++17 |
|
390 ms |
34220 KB |
// oh, these hills, they burn so bright / oh, these hills, they bring me life
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define all(x) begin(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)(x.size())
#define inf 1000000010
#define linf 0x3f3f3f3f3f3f3f3f
#define mp make_pair
#define f first
#define s second
#define pi pair<int, int>
#ifdef LOCAL
#include "/mnt/c/yukon/pp.hpp"
#else
#define endl '\n'
#endif
#define double long double
struct Point {
double x, y;
};
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, l;
cin >> n >> l;
function<double(Point, Point)> max_point = [&](Point a, Point b) {
// return (((b.x) * (b.x)) + ((b.y) * (b.y)) - ((a.x) * (a.x)) - ((a.y) * (a.y))) / (2 * (b.x - a.x));
return (b.x * b.x + b.y * b.y - a.x * a.x - a.y * a.y) / (2 * b.x - 2 * a.x);
};
function<double(Point, Point)> dist = [&](Point a, Point b) {
return sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
};
vector<Point> stck;
for (int i = 0; i < n; i++) {
Point cur;
cin >> cur.x >> cur.y;
cur.y = abs(cur.y);
// take the one with the lowest y coord
if (sz(stck) && stck.back().x == cur.x) {
if (cur.y >= stck.back().y) {
continue;
} else if (cur.y < stck.back().y) {
stck.pop_back();
}
}
// find "crosses"
while (sz(stck) > 1 && max_point(stck[sz(stck) - 2], stck.back()) > max_point(stck.back(), cur)) {
stck.pop_back();
}
stck.push_back(cur);
}
double ans = 0;
for (int x = 0; x < sz(stck); x++) {
if (stck[x].x < 0 || stck[x].x > l)
continue;
Point left = {(x ? max_point(stck[x], stck[x - 1]) : 0), 0};
Point right = {(x < sz(stck) - 1 ? max_point(stck[x], stck[x + 1]) : l), 0};
if (right.x < 0 || left.x > l)
continue;
ans = max({ans, dist(stck[x], left), dist(stck[x], right)});
}
cout << fixed << setprecision(6) << ans << endl;
}
// don't get stuck on one approach
// question bounds
// flesh out your approach before implementing o.o
// math it out
// ok well X is always possible, how about X + 1 (etc.)
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
3 ms |
348 KB |
Output is correct |
3 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Incorrect |
2 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
348 KB |
Output is correct |
3 |
Incorrect |
2 ms |
344 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
816 KB |
Output is correct |
2 |
Incorrect |
37 ms |
476 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
480 KB |
Output is correct |
2 |
Correct |
31 ms |
476 KB |
Output is correct |
3 |
Correct |
32 ms |
472 KB |
Output is correct |
4 |
Correct |
40 ms |
488 KB |
Output is correct |
5 |
Correct |
38 ms |
496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
6100 KB |
Output is correct |
2 |
Incorrect |
30 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
44 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
2404 KB |
Output is correct |
2 |
Incorrect |
36 ms |
712 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
187 ms |
17124 KB |
Output is correct |
2 |
Correct |
173 ms |
348 KB |
Output is correct |
3 |
Correct |
186 ms |
344 KB |
Output is correct |
4 |
Correct |
216 ms |
472 KB |
Output is correct |
5 |
Correct |
194 ms |
464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
173 ms |
344 KB |
Output is correct |
2 |
Correct |
190 ms |
2572 KB |
Output is correct |
3 |
Incorrect |
163 ms |
6340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
228 ms |
34220 KB |
Output is correct |
2 |
Incorrect |
214 ms |
460 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
212 ms |
448 KB |
Output is correct |
2 |
Correct |
228 ms |
2504 KB |
Output is correct |
3 |
Incorrect |
228 ms |
5820 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
263 ms |
33900 KB |
Output is correct |
2 |
Incorrect |
242 ms |
452 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
245 ms |
444 KB |
Output is correct |
2 |
Correct |
265 ms |
2500 KB |
Output is correct |
3 |
Incorrect |
230 ms |
6348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
302 ms |
33612 KB |
Output is correct |
2 |
Incorrect |
278 ms |
616 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
280 ms |
448 KB |
Output is correct |
2 |
Correct |
317 ms |
2504 KB |
Output is correct |
3 |
Incorrect |
261 ms |
4804 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
390 ms |
34220 KB |
Output is correct |
2 |
Incorrect |
340 ms |
444 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
354 ms |
444 KB |
Output is correct |
2 |
Correct |
388 ms |
6600 KB |
Output is correct |
3 |
Incorrect |
339 ms |
9616 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |