Submission #964109

#TimeUsernameProblemLanguageResultExecution timeMemory
964109dubabubaMobile (BOI12_mobile)C++14
0 / 100
562 ms6972 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define MP make_pair const int mxn = 1e5 + 10; int x[mxn], y[mxn], n, m; bool can(double R) { vector<pair<double, double>> buba; for(int i = 0; i < n; i++) { const double &X = x[i]; const double &Y = y[i]; if(R < Y) continue; if(R == Y) { if(0.0 <= X && X <= (double) m) buba.push_back(MP(X, X)); continue; } double d = sqrt(R * R - Y * Y); double l = X - d, r = X + d; if(r < 0.0 || (double) m < l) continue; l = max(l, 0.0); r = min(r, (double) m); buba.push_back(MP(l, r)); } sort(buba.begin(), buba.end()); // cout << R << endl; // for(auto p : buba) // cout << p.ff << ' ' << p.ss << endl; if(buba[0].ff > 0.0) return 0; if(buba.back().ss < (double) m) return 0; for(int i = 1; i < buba.size(); i++) if(buba[i - 1].ss < buba[i].ff) return 0; return 1; } int main() { cin >> n >> m; for(int i = 0; i < n; i++) { cin >> x[i] >> y[i]; y[i] = abs(y[i]); } double L = 0.0; double R = 1e18; cout << setprecision(5) << fixed; while(R - L > 1e-5) { double M = L + (R - L) / 2; if(can(M)) R = M; else L = M; } cout << R << endl; return 0; }

Compilation message (stderr)

mobile.cpp: In function 'bool can(double)':
mobile.cpp:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int i = 1; i < buba.size(); i++)
      |                 ~~^~~~~~~~~~~~~
#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...