Submission #998936

# Submission time Handle Problem Language Result Execution time Memory
998936 2024-06-15T01:26:45 Z hippo123 Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 33620 KB
#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

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 time Memory Grader output
1 Incorrect 2 ms 8028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 8028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 8280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 8284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 8284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 8284 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 150 ms 9812 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 9812 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 196 ms 9556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 229 ms 11600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 219 ms 11348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1042 ms 17840 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 25768 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1034 ms 19900 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1039 ms 29224 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1035 ms 21844 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1027 ms 31312 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 23216 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 33620 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1031 ms 24400 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1008 ms 32848 KB Time limit exceeded
2 Halted 0 ms 0 KB -