Submission #998936

#TimeUsernameProblemLanguageResultExecution timeMemory
998936hippo123Mobile (BOI12_mobile)C++17
0 / 100
1076 ms33620 KiB
#include <bits/stdc++.h> using namespace std; #define pr pair<int, int> #define ll long long #define pb push_back #define f first #define s second vector<pr> d(1000001); int n; double L; bool comp(pr a, pr b){ if(a.f==b.f) return a.s*a.s<b.s*b.s; return a.f<b.f; } bool check(double mid){ double xmin, xmax; for (int i=0; i<n; i++){ double dx=mid*mid-d[i].s*d[i].s; dx=pow(dx, 0.5); double x1, x2; x1=d[i].f-dx; x2=d[i].f+dx; if(i==0) { xmin=x1; xmax=x2; } else{ if(x1<=xmax) { xmax=max(xmax, x2); } else{ break; } } } if(xmin<=0 && xmax>=L) return true; else return false; } int main(){ cin>>n>>L; for (int i=0; i<n; i++) { cin>>d[i].f>>d[i].s; } sort(d.begin(), d.begin()+n, comp); for (int i=0; i<n; i++) cout<<d[i].f<<" " <<d[i].s<<" :"<<endl; double lft=0; double rht=L; while (rht-lft>1e-5){ double mid=lft+(rht-lft)/2; //cout<<" lft/rht/mid= "<<lft<<" "<<rht<<" "<<mid<<endl; if(check(mid)) rht=mid; else lft=mid; } cout << fixed <<setprecision(4); cout<<lft<<endl; }

Compilation message (stderr)

mobile.cpp: In function 'bool check(double)':
mobile.cpp:39:14: warning: 'xmax' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |   if(xmin<=0 && xmax>=L) return true;
      |      ~~~~~~~~^~~~~~~~~~
mobile.cpp:39:3: warning: 'xmin' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |   if(xmin<=0 && xmax>=L) return true;
      |   ^~
#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...