제출 #356766

#제출 시각아이디문제언어결과실행 시간메모리
356766penguinhackerMobile (BOI12_mobile)C++14
28 / 100
1101 ms74052 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array const int mxN = 1000000; int n, l, x[mxN], y[mxN]; bool ok(double d) { // vector<pair<double, double>> d; vector<pair<double, int>> e; for (int i = 0; i < n; ++i) { if (abs(y[i]) < d) { double r = sqrt(d * d - (ll)y[i] * y[i]); double ls = x[i] - r; double rs = x[i] + r; if (rs > 0 && ls < l) { ls = max(ls, 0.0); rs = min(rs, l + 1e-9); // d.emplace_back(ls, rs); e.emplace_back(ls, 1); e.emplace_back(rs, -1); } } } // for (auto& x : e) cout << x.first << " " << x.second << "\n"; sort(e.begin(), e.end()); if (e[0].first != 0 || e.back().first < l) return 0; int cur = 0; for (int i = 0; i < e.size(); ++i) { cur += e[i].second; assert(cur >= 0); if (i != e.size() - 1 && cur == 0) return 0; } return 1; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(6); cin >> n >> l; for (int i = 0; i < n; ++i) cin >> x[i] >> y[i]; double lb = 0, rb = 2e9; while(lb + (1e-7) < rb) { double mid = (lb + rb) / 2; if (ok(mid)) rb = mid; else lb = mid; } cout << lb; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

mobile.cpp: In function 'bool ok(double)':
mobile.cpp:31:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for (int i = 0; i < e.size(); ++i) {
      |                  ~~^~~~~~~~~~
mobile.cpp:34:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   if (i != e.size() - 1 && cur == 0) return 0;
      |       ~~^~~~~~~~~~~~~~~
#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...