Submission #465489

#TimeUsernameProblemLanguageResultExecution timeMemory
465489tphuc2908Mobile (BOI12_mobile)C++14
0 / 100
688 ms41136 KiB
#include<bits/stdc++.h> using namespace std; #define rep(i, x, y) for(int i = x; i <= y; ++i) #define repi(i,x,y) for(int i = x; i >= y; --i) #define ci(x) int x; cin>> x #define TC(t) ci(t); while(t--) #define fi first #define se second #define pb push_back #define all(x) x.begin(), x.end() #define cii(x, y) ci(x); ci(y) typedef long long ll; typedef vector<int> vi; const int N = 1e6 + 5; const int mod = 1e9+7; const int inf = 1e9 + 5; void readfile(){ #ifdef ONLINE_JUDGE #else freopen("text.inp", "r", stdin); #endif // ONLINE_JUDGE // freopen("angry.in", "r", stdin); // freopen("angry.out", "w", stdout); } int n; int L; pair<double, double> a[N]; vector<pair<double, double> > store; void inp(){ cin >> n >> L; rep(i,1,n){ cii(x, y); a[i] = {double(x), double(y)}; } } void trim(){ rep(i,1,n){ if(i==1 || a[i].fi != a[i-1].fi) store.pb(a[i]); } } void process(){ trim(); if((int)store.size()==1){ cout << max(sqrt((store[0].fi-L)*(store[0].fi-L) + store[0].se*store[0].se), sqrt(store[0].fi*store[0].fi + store[0].se*store[0].se)); return; } double res = 0; if(0 <= a[0].fi) res = sqrt(a[0].fi*a[0].fi + a[0].se*a[0].se); rep(i,0,(int)store.size()-2){ double l = store[i].fi, r = store[i+1].fi; rep(j,1,30){ double mid = (l + r) / 2; double cal1 = sqrt((mid-store[i].fi)*(mid-store[i].fi) + store[i].se*store[i].se); double cal2 = sqrt((mid-store[i+1].fi)*(mid-store[i+1].fi) + store[i+1].se*store[i+1].se); res = max(res, min(cal1, cal2)); if(cal1 <= cal2) l = mid; else r = mid; } } if(L >= store.back().fi) res = max(res, sqrt((store.back().fi - L)*(store.back().fi - L) + store.back().se*store.back().se)); cout << res; } int main(){ //readfile(); ios_base::sync_with_stdio(0); cin.tie(0); inp(); process(); return 0; }

Compilation message (stderr)

mobile.cpp: In function 'void readfile()':
mobile.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen("text.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...