제출 #596245

#제출 시각아이디문제언어결과실행 시간메모리
596245hailMobile (BOI12_mobile)C++17
9 / 100
1093 ms15956 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...