Submission #732390

#TimeUsernameProblemLanguageResultExecution timeMemory
732390uy842003Mobile (BOI12_mobile)C++17
20 / 100
1081 ms40228 KiB
#include <bits/stdc++.h> using namespace std; const double eps = 1e-4; bool cmp_less(double a, double b) { return a + eps < b; } bool cmp_less_equal(double a, double b) { return a < b + eps; } bool cmp_range(const pair<double, double> &p1, const pair<double, double> &p2) { return cmp_less(p1.first, p2.first); } int main() { int n; double len; cin >> n >> len; // pair<double, double> *cor = new pair<double, double>[n]; vector<pair<int, int>> cor(n); for (int i = 0; i < n; i++) cin >> cor[i].first >> cor[i].second; double l = 0, r = 2e9 + 7, m; while (cmp_less(l, r)) { m = (l + r) / 2; vector<pair<double, double>> range, real_range; for (int i = 0; i < n; i++) { if (cmp_less_equal(m, abs(cor[i].second))) continue; double dx = sqrt(m * m - cor[i].second * cor[i].second); range.push_back({cor[i].first - dx, cor[i].first + dx}); } sort(range.begin(), range.end(), cmp_range); pair<double, double> cur_range = {-1, -1}; if (range.size() > 0) cur_range = *range.begin(); for (int i = 0; i < range.size(); i++) { if (cmp_less_equal(range[i].first, cur_range.second) && cmp_less(cur_range.second, range[i].second)) cur_range.second = range[i].second; if (!cmp_less_equal(range[i].first, cur_range.second) || i + 1 == range.size()) { real_range.push_back(cur_range); cur_range = range[i]; } } bool iok = false; for (int i = 0; i < real_range.size(); i++) { if (cmp_less_equal(real_range[i].first, 0) && cmp_less_equal(len, real_range[i].second)) { iok = true; break; } } if (iok) r = m; else l = m + eps; } cout << setprecision(3) << fixed; cout << r << endl; return 0; }

Compilation message (stderr)

mobile.cpp: In function 'int main()':
mobile.cpp:39:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for (int i = 0; i < range.size(); i++) {
      |                         ~~^~~~~~~~~~~~~~
mobile.cpp:42:76: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             if (!cmp_less_equal(range[i].first, cur_range.second) || i + 1 == range.size()) {
      |                                                                      ~~~~~~^~~~~~~~~~~~~~~
mobile.cpp:48:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |         for (int i = 0; i < real_range.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...