# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1098023 |
2024-10-08T19:59:05 Z |
0x34c |
Mobile (BOI12_mobile) |
C++17 |
|
584 ms |
131072 KB |
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define endl '\n'
#define int ll
#define ld long double
#define pdd pair<ld, ld>
using namespace std;
int dist2(pii a, pii b)
{
return (a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second);
}
ld dist(pii a, ld x)
{
ld x1 = a.first, y = a.second;
return sqrt((x1 - x) * (x1 - x) + y * y);
}
const int INF2 = 1e12;
const int INF = 1e9 + 1;
ld eps = 1e-4;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int N, L;
cin >> N >> L;
vector<pii> inp(N);
map<int, int> closest;
for (int i = 0; i < N; i++)
{
int x, y;
cin >> x >> y;
inp[i] = {x, y};
if (!closest.count(x))
closest[x] = y;
else
closest[x] = (abs(closest[x]) > abs(y) ? y : closest[x]);
}
vector<pii> pts;
for (pii p : closest)
pts.push_back(p);
N = pts.size();
auto calc_bp = [&](int idx1, int idx2)
{
try
{
ld x1 = pts[idx1].first, y1 = pts[idx1].second;
ld x2 = pts[idx2].first, y2 = pts[idx2].second;
if (x1 - x2 == 0)
return (ld)-1;
return ((ld)0.5) * (x1 + x2 + (y1 * y1 - y2 * y2) / (x1 - x2));
}
catch (const std::exception &e)
{
return (ld)-1;
}
};
stack<int> stk;
stk.push(0);
vector<ld> dists, bps;
for (int i = 1; i < N; i++)
{
try
{
ld bp = calc_bp(stk.top(), i);
bool emp = false;
while (!bps.empty() && bps.back() >= bp)
{
bps.pop_back();
stk.pop();
dists.pop_back();
if (stk.empty())
emp = true;
else
bp = calc_bp(stk.top(), i);
}
if (!emp)
{
bps.push_back(bp);
dists.push_back(dist(pts[i], bp));
}
stk.push(i);
}
catch (const std::exception &e)
{
}
}
ld mx_dist = 0;
for (int i = 0; i < (bps.empty() ? 0 : bps.size()); i++)
{
if (bps[i] < 0 || bps[i] > L)
continue;
mx_dist = max(mx_dist, dists[i]);
}
ld mn_start = INF2, mn_end = INF2;
for (int i = 0; i < N; i++)
{
mn_start = min(mn_start, dist(pts[i], (ld)0));
mn_end = min(mn_end, dist(pts[i], (ld)L));
}
mx_dist = max({mx_dist, mn_start, mn_end});
cout << setprecision(4) << fixed << mx_dist << endl;
}
Compilation message
mobile.cpp: In function 'int main()':
mobile.cpp:106:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'long unsigned int' [-Wsign-compare]
106 | for (int i = 0; i < (bps.empty() ? 0 : bps.size()); i++)
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
860 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
860 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
604 KB |
Output is correct |
2 |
Correct |
2 ms |
860 KB |
Output is correct |
3 |
Correct |
2 ms |
856 KB |
Output is correct |
4 |
Correct |
2 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
856 KB |
Output is correct |
2 |
Correct |
2 ms |
816 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
2 ms |
860 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
7856 KB |
Output is correct |
2 |
Correct |
32 ms |
6316 KB |
Output is correct |
3 |
Correct |
21 ms |
5588 KB |
Output is correct |
4 |
Correct |
37 ms |
8400 KB |
Output is correct |
5 |
Correct |
8 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
2136 KB |
Output is correct |
2 |
Correct |
28 ms |
4812 KB |
Output is correct |
3 |
Correct |
35 ms |
8140 KB |
Output is correct |
4 |
Correct |
36 ms |
8664 KB |
Output is correct |
5 |
Correct |
40 ms |
9168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
14272 KB |
Output is correct |
2 |
Correct |
35 ms |
6100 KB |
Output is correct |
3 |
Correct |
37 ms |
12740 KB |
Output is correct |
4 |
Correct |
51 ms |
10200 KB |
Output is correct |
5 |
Correct |
30 ms |
3548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
42 ms |
5776 KB |
Output is correct |
2 |
Correct |
42 ms |
5832 KB |
Output is correct |
3 |
Correct |
33 ms |
3668 KB |
Output is correct |
4 |
Correct |
47 ms |
10436 KB |
Output is correct |
5 |
Correct |
42 ms |
9284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
12480 KB |
Output is correct |
2 |
Correct |
42 ms |
5832 KB |
Output is correct |
3 |
Correct |
33 ms |
3668 KB |
Output is correct |
4 |
Correct |
48 ms |
10440 KB |
Output is correct |
5 |
Correct |
46 ms |
9160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
246 ms |
70508 KB |
Output is correct |
2 |
Correct |
155 ms |
8968 KB |
Output is correct |
3 |
Correct |
149 ms |
8952 KB |
Output is correct |
4 |
Correct |
279 ms |
47804 KB |
Output is correct |
5 |
Correct |
250 ms |
36800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
161 ms |
9044 KB |
Output is correct |
2 |
Correct |
257 ms |
49584 KB |
Output is correct |
3 |
Correct |
225 ms |
21452 KB |
Output is correct |
4 |
Correct |
262 ms |
47672 KB |
Output is correct |
5 |
Correct |
258 ms |
44824 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
314 ms |
99024 KB |
Output is correct |
2 |
Correct |
182 ms |
10272 KB |
Output is correct |
3 |
Correct |
188 ms |
10320 KB |
Output is correct |
4 |
Correct |
341 ms |
63940 KB |
Output is correct |
5 |
Correct |
305 ms |
37052 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
183 ms |
10320 KB |
Output is correct |
2 |
Correct |
322 ms |
63416 KB |
Output is correct |
3 |
Correct |
253 ms |
19908 KB |
Output is correct |
4 |
Correct |
343 ms |
63936 KB |
Output is correct |
5 |
Correct |
327 ms |
59440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
380 ms |
111520 KB |
Output is correct |
2 |
Correct |
209 ms |
11856 KB |
Output is correct |
3 |
Correct |
194 ms |
11964 KB |
Output is correct |
4 |
Correct |
382 ms |
71584 KB |
Output is correct |
5 |
Correct |
350 ms |
36364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
208 ms |
12028 KB |
Output is correct |
2 |
Correct |
373 ms |
71104 KB |
Output is correct |
3 |
Correct |
325 ms |
28228 KB |
Output is correct |
4 |
Correct |
388 ms |
71668 KB |
Output is correct |
5 |
Correct |
371 ms |
65148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
412 ms |
124064 KB |
Output is correct |
2 |
Correct |
214 ms |
13400 KB |
Output is correct |
3 |
Correct |
217 ms |
13324 KB |
Output is correct |
4 |
Correct |
461 ms |
79492 KB |
Output is correct |
5 |
Correct |
408 ms |
52540 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
226 ms |
13364 KB |
Output is correct |
2 |
Correct |
410 ms |
78832 KB |
Output is correct |
3 |
Correct |
367 ms |
29124 KB |
Output is correct |
4 |
Correct |
451 ms |
79412 KB |
Output is correct |
5 |
Correct |
426 ms |
71364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
447 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
275 ms |
16348 KB |
Output is correct |
2 |
Correct |
525 ms |
97700 KB |
Output is correct |
3 |
Correct |
481 ms |
39360 KB |
Output is correct |
4 |
Correct |
584 ms |
95164 KB |
Output is correct |
5 |
Correct |
558 ms |
84992 KB |
Output is correct |