Submission #995196

#TimeUsernameProblemLanguageResultExecution timeMemory
995196VMaksimoski008Mobile (BOI12_mobile)C++17
100 / 100
981 ms68260 KiB
#include <bits/stdc++.h> #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define int long long using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; const int mod = 1e9 + 7; const int LOG = 20; const int maxn = 1e5 + 5; const double eps = 1e-9; int32_t main() { ios_base::sync_with_stdio(false); cout.tie(0); cin.tie(0); int n, L; cin >> n >> L; vector<int> x(n), y(n); for(int i=0; i<n; i++) cin >> x[i] >> y[i]; double l=1, r=2e9, ans=r; for(int it=0; it<50; it++) { double mid = (l + r) / 2.0; vector<pdd> seg; for(int i=0; i<n; i++) { if(abs(y[i]) >= mid) continue; double len = sqrt(mid * mid - y[i] * y[i]); double left = x[i] - len, right = x[i] + len; if( right >= 0 && left <= L ) seg.push_back({ max((double)0, x[i] - len), min((double)L, x[i] + len) }); } if(seg.size() == 0) { l = mid; continue; } //sort(seg.begin(), seg.end()); bool ok = 1; double mn = 1e9; for(auto &s : seg) mn = min(mn, s.first); if(mn > 0) ok = 0; double lp=seg[0].first, rp=seg[0].second; for(int i=1; i<seg.size(); i++) { if(seg[i].first <= rp) rp = max(rp, seg[i].second); } if(ok && rp >= L) ans = min(ans, mid), r = mid; else l = mid; } cout << setprecision(8) << fixed << ans << '\n'; return 0; }

Compilation message (stderr)

mobile.cpp: In function 'int32_t main()':
mobile.cpp:57:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         for(int i=1; i<seg.size(); i++) {
      |                      ~^~~~~~~~~~~
mobile.cpp:55:16: warning: unused variable 'lp' [-Wunused-variable]
   55 |         double lp=seg[0].first, rp=seg[0].second;
      |                ^~
#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...