Submission #735127

#TimeUsernameProblemLanguageResultExecution timeMemory
735127ace_in_the_holeMobile (BOI12_mobile)C++17
0 / 100
292 ms12044 KiB
#include<bits/stdc++.h> using namespace std; typedef long long Int; typedef double Real; const Real EPS = 1e-6; bool leq(Real x, Real y) { return x-EPS <= y; } const int N = 1e6 + 50; int n,L, x[N]; Int y[N]; bool check(Real dis) { Real rightmost = 0; Real d_squared = dis * dis; for (int i = 1; i <= n; i++) { if (leq(dis, y[i])) continue; Real lef = x[i] - sqrt(d_squared - y[i]); Real rig = 2*x[i] - lef; if (leq(lef, rightmost)) { rightmost = max(rightmost, rig); if (leq(L,rightmost)) return true; } } return false; } void solve() { cin >> n >> L; for (int i = 1; i <= n; i++) cin >> x[i] >> y[i]; //preprocessing Real max_dist = L; for (int i = 1; i <= n; i++) { y[i] *= y[i]; int x_dis = max(abs(x[i]), abs(L - x[i])); Real cur_dist = sqrt(y[i] + 1ll * x_dis * x_dis); max_dist = max(max_dist, cur_dist); } const Real DEL = 5e-4; Real ans = 0; for (Real low = 0, high = max_dist + 100; high - low >= DEL; ) { Real mid = (low + high) / 2; if (check(mid)) high = mid; else ans = low = mid; } cout << fixed << setprecision(15) << ans; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "WF" if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } solve(); }

Compilation message (stderr)

mobile.cpp: In function 'int main()':
mobile.cpp:57:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:58:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...