# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
672920 |
2022-12-19T03:10:09 Z |
hadnew |
Mobile (BOI12_mobile) |
C++17 |
|
1000 ms |
56676 KB |
#include <bits/stdc++.h>
using namespace std;
vector<array<int,2>> points;
int n, l;
auto comp = [](pair<double,double> a, pair<double,double> b){
return (a.first != b.first) ? a.first < b.first : a.second < b.second;
};
bool test(double r)
{
vector<pair<double,double>> v;
for (int i = 0; i < n; i++)
{
double h = points[i][0]; // x val of center
double k = points[i][1];
if (r <= k)
{
continue;
}
double len = sqrt(pow(r,2)-pow(k,2));
//cout << "LEG LENGTH: "<<len<<endl;
pair<double,double> p = make_pair(h-len, h+len);
v.push_back(p);
}
sort(v.begin(), v.end(), comp);
/*
for (auto pii : v)
{
cout << pii.first << " - " << pii.second << endl;
}
*/
// pairs all sorted
double ma = -1;
for (int i = 0; i < v.size(); i++)
{
if (v[i].second < v[i+1].first)
{
return false;
}
ma = max(max(v[i].second,v[i+1].second),ma);
}
return v[0].first <= 0 && ma >= l;
}
int main()
{
cin >> n >> l;
for (int i = 0; i < n; i++)
{
int a, b;
cin >> a >> b;
points.push_back(array<int,2>{{a,b}});
}
auto comp = [](array<int,2> a, array<int,2> b) {
return a[0] < b[0];
};
sort(points.begin(), points.end(), comp);
//cout << "ANS: " << ((test(5)) ? "WORKS" : "DOESNT WORK") << endl;
double lo = 0;
double hi = 1500000000; // longest r needed is 10e9 sqrt2
while (lo < hi) // better precision than needed just to be safe
{
double mid = lo+(hi-lo)/2;
if (test(mid))
{
hi = mid;
}
else
{
lo = mid+0.0001;
}
}
cout << lo << endl;
}
Compilation message
mobile.cpp: In function 'bool test(double)':
mobile.cpp:37:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for (int i = 0; i < v.size(); i++)
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1086 ms |
604 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
8 ms |
864 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
141 ms |
4940 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
350 ms |
4960 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
5308 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
374 ms |
6444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1042 ms |
6260 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1075 ms |
24696 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1074 ms |
28508 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
36128 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1078 ms |
40772 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
39280 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1088 ms |
44760 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1047 ms |
42496 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1089 ms |
48728 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
48968 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1087 ms |
56676 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |