이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using pd = pair<double, double>;
int max_ind{};
int max_x{};
#define mp make_pair
int n;
double l;
int max_reach{};
pd station[(int)1e6];
pd intercept(pd coor, double r)
{
if(abs(coor.second)>r) return mp(-1, -1);
double mid = pow(r, 2)-pow(coor.second, 2);
double rt_mid = pow(mid , 0.5);
return mp(coor.first-rt_mid, coor.first+rt_mid);
}
bool check_dist(double r)
{
if(r<0) return false;
pd ret_int;
double from_x = (intercept(station[max_reach], r)).second;
/*
auto it=lower_bound(station.begin(), station.end(), mp(-r, -1e9));
while(it<station.end())
{
if((*it).first>from_x+r) return false;
ret_int=intercept(*it, r);
if(ret_int.first<=from_x && ret_int.second>from_x)
{
from_x=ret_int.second;
if(from_x>=l) return true;
it = upper_bound(it+1, station.end(), mp(from_x-r, 1e9));
}
else it++;
}
return false;
*/
int last_reached{};
pd circ;
for(int i=max_reach+1; i<n; i++)
{
circ=station[i];
if(circ.first>from_x+r)
{
max_reach=last_reached;
return false;
}
if(circ.first>from_x-r)
{
ret_int=intercept(circ, r);
if(ret_int.first<=from_x && ret_int.second>from_x)
{
from_x=ret_int.second;
last_reached=i;
if(from_x>=l) return true;
}
}
}
return false;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout<<setprecision(20);
cin>>n>>l;
double max_coor{};
for(int i=0; i<n; i++)
{
cin>>station[i].first>>station[i].second;
max_coor=max({abs(station[i].first), abs(station[i].second), max_coor});
}
double high=2*(max_coor+l);
double low=0;
double mid;
while(high-low>=1e-3)
{
mid=(high+low)/2;
if(check_dist(mid)) high=mid;
else low=mid;
}
cout<<high;
}
# | 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... |