# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1083622 | codexistent | Mobile (BOI12_mobile) | C++14 | 692 ms | 57240 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define MAXN 1000005
#define FOR(i, a, b) for(ll i = a; i <= b; i++)
#define f first
#define s second
ll n;
db l;
vector<pair<db, db>> s;
bool overlap(pair<db, db> a, pair<db, db> b){ // does a overlap b vertex?
db ad = (a.f - b.f) * (a.f - b.f) + a.s * a.s;
db bd = b.s * b.s;
return ad <= bd;
}
db overlap2(pair<db, db> a, pair<db, db> b){
db x = (a.f * a.f + a.s * a.s - b.f * b.f - b.s * b.s) / (2 * (a.f - b.f));
// cout << " HERE: " << x << endl;
x = max((db)0, x);
x = min(x, l);
return min(sqrt((a.f - x) * (a.f - x) + a.s * a.s), sqrt((b.f - x) * (b.f - x) + b.s * b.s));
}
int main(){
cin >> n >> l;
FOR(i, 1, n){
db x, y; cin >> x >> y;
s.push_back({x, y});
}
sort(begin(s), end(s));
vector<pair<db, db>> s2;
ll prv = -1;
FOR(i, 0, n - 1){
if(prv == -1 || i == n - 1 || !(overlap(s[prv], s[i]) && overlap(s[i + 1], s[i]))){
s2.push_back(s[i]);
prv = i;
}
}
db r = max(sqrt(s2[0].f * s2[0].f + s2[0].s * s2[0].s), sqrt((s2.back().f - l) * (s2.back().f - l) + s2.back().s * s2.back().s));
// cout << "START PT IS " << (s2[0].f * s2[0].f + s2[0].s * s2[0].s) << endl;
// cout << "END PT IS " << ((s2.back().f - l) * (s2.back().f - l) + s2.back().s * s2.back().s) << endl;
FOR(i, 0, s2.size() - 2){
r = max(r, overlap2(s2[i], s2[i + 1]));
}
cout << fixed << setprecision(6) << r;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |