Submission #417518

#TimeUsernameProblemLanguageResultExecution timeMemory
417518jackkkkMobile (BOI12_mobile)C++11
0 / 100
4 ms640 KiB
#include <stdio.h> #include <iostream> #include <string> #include <vector> #include <queue> #include <map> #include <array> #include <deque> #include <unordered_map> #include <unordered_set> #include <set> #include <algorithm> #include <stdlib.h> #include <math.h> #include <list> #include <float.h> #include <climits> using namespace std; void quit(){ cout.flush(); exit(0); } int n, l; vector <pair<double, double>> towers; vector <pair<double ,double>> intervals; bool good(double dist){ intervals.clear(); //get_intervals double mx = 0; for(const auto &tower : towers){ if(tower.second>dist){ intervals.emplace_back(0, 0); continue; } double range = sqrt((dist*dist)-(tower.second*tower.second)); intervals.emplace_back(tower.first-range, tower.first+range); mx = max(mx, tower.first+range); } sort(intervals.begin(), intervals.end()); if(intervals[0].first>0 || mx<l){ return false; } double curr_max = intervals[0].second; for(int i = 1; i < (int) intervals.size(); i++){ if(intervals[i].first>l){ return true; } if(curr_max<intervals[i].first){ return false; } curr_max=max(curr_max, intervals[i].second); } return true; } int main() { freopen("mobile.in", "r", stdin); freopen("mobile.out", "w", stdout); //freopen("qwer.in", "r", stdin); //freopen("qwer.out", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> l; towers.resize(n); for(int i = 0; i < n; i++){ cin >> towers[i].first >> towers[i].second; } double s = 0, e = 300000, mid; while(e-s>0.001){ mid = (s+e)/2; if(good(mid)){ e=mid; } else{ s=mid; } } cout << e << "\n"; quit(); }

Compilation message (stderr)

mobile.cpp: In function 'int main()':
mobile.cpp:60:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |  freopen("mobile.in", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:61:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |  freopen("mobile.out", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...