Submission #305634

#TimeUsernameProblemLanguageResultExecution timeMemory
305634ant101Mobile (BOI12_mobile)C++14
100 / 100
912 ms51936 KiB
#include <iostream> #include <algorithm> #include <cstring> #include <iomanip> #include <fstream> #include <cmath> #include <vector> #include <set> #include <unordered_set> #include <unordered_map> #include <map> #include <stack> #include <queue> #include <assert.h> #include <limits> #include <cstdio> #include <complex> using namespace std; #define rep(x,a) for(int x = 0; x < a; x++) #define REP(x,a,b) for(int x = a; x < b; x++) #define per(x,b) for(int x = b; x >= 0; x--) #define all(container) (container).begin(), container.end() #define rall(container) (container).rbegin(), container.rend() #define sz(container) (int) (container).size() #define pb push_back #define eb emplace_back #define fi first #define sc second using ll = long long; using pii = pair<int, int>; using pll = pair<ll, ll>; template<class T> bool smin(T &a, T b) { return a > b ? (a = b, true) : false; } template<class T> bool smax(T &a, T b) { return a < b ? (a = b, true) : false; } #ifdef LOCAL_DEFINE #include "DEBUG.hpp" #else #define debug(...) 0 #endif const double eps = 1e-3; const double EPS = 1e-9; bool eq(double a, double b) { return abs(a-b) <= eps; } int main(void) { int n; double last; scanf("%d%lf", &n, &last); vector<pair<double, double>> points(n); rep(i,n) scanf("%lf%lf", &points[i].fi, &points[i].sc); vector<pair<double, double>> poi; rep(i,n) { poi.emplace_back(points[i]); ++i; while (i < n && eq(points[i].fi, poi.back().fi)) ++i; --i; } auto Can = [&](double dist) { double r = 0.0; rep(i,n) { double delta = sqrt(dist*dist-points[i].sc*points[i].sc); double L = points[i].fi-delta, R = points[i].fi+delta; if (L <= r) smax(r, R); } return (r >= last); }; double l = 0.0, r = 1e10; while (r-l > eps) { double mid = (r+l)/2.0; if (Can(mid)) r = mid; else l = mid; } printf("%.6lf\n", l); return 0; }

Compilation message (stderr)

mobile.cpp: In function 'int main()':
mobile.cpp:56:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   56 |     scanf("%d%lf", &n, &last);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
mobile.cpp:58:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   58 |     rep(i,n) scanf("%lf%lf", &points[i].fi, &points[i].sc);
      |              ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...