# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1063885 |
2024-08-18T05:35:29 Z |
daviedu |
Mobile (BOI12_mobile) |
C++17 |
|
157 ms |
16724 KB |
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ld long double
struct P{
ll x, y;
};
void dbg_out() { cerr << endl; }
template <typename H, typename... T>
void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); }
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }
ld border(ld a, ld b, ld x, ld y){
return (a*a + b*b - x*x - y*y) / (2*b - 2*x);
}
ld dist(ld x, ld y, ld point){
return sqrtl(y*y + (point-x)*(point-x));
}
signed main(){
fastio;
int n, r;
cin >> n >> r;
stack<pair<int, int>> st;
int a, b, x, y;
int last_x=-1;
for (int i=0; i<n; i++){
cin >> a >> b;
if (b < 0) b = -b;
if (a == last_x) continue;
last_x = a;
while ((int)st.size() > 1){
tie(x, y) = st.top();
st.pop();
// if prev is not a useless point, put it back and stop
if (border(x, y, a, b) > border(st.top().first, st.top().second, a, b)){
st.push({x, y});
break;
}
}
st.push({a, b});
}
ld ans=0;
ld right=r;
while ((int)st.size() > 1){
tie(a, b) = st.top();
st.pop();
tie(x, y) = st.top();
ld left = border(x, y, a, b);
if (left >= right) continue;
if (right >= 0 && right <= r) ans = max(ans, dist(a, b, right));
if (left >= 0 && left <= r) ans = max(ans, dist(a, b, left));
right = left;
}
tie(a, b) = st.top();
if (right >= 0) {
ans = max(ans, dist(a, b, right));
ans = max(ans, dist(a, b, 0));
}
cout << fixed << setprecision(13);
cout << ans << '\n';
}
# |
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 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1112 KB |
Output is correct |
2 |
Incorrect |
14 ms |
1372 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
1880 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
15 ms |
1884 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
52 ms |
4644 KB |
Output is correct |
2 |
Correct |
57 ms |
7984 KB |
Output is correct |
3 |
Incorrect |
54 ms |
7508 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
59 ms |
8616 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
5460 KB |
Output is correct |
2 |
Incorrect |
67 ms |
9552 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
10064 KB |
Output is correct |
2 |
Incorrect |
80 ms |
8236 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
73 ms |
6224 KB |
Output is correct |
2 |
Incorrect |
84 ms |
11168 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
112 ms |
11812 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
7324 KB |
Output is correct |
2 |
Incorrect |
104 ms |
12624 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
129 ms |
13396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
9044 KB |
Output is correct |
2 |
Incorrect |
129 ms |
15700 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
157 ms |
16724 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |