Submission #638867

# Submission time Handle Problem Language Result Execution time Memory
638867 2022-09-07T18:28:10 Z Pietra Mobile (BOI12_mobile) C++14
0 / 100
1000 ms 3792 KB
// pto max de dist max na estrada ate a base mais prox do transceptor
// estrada eh horizontal e vai de 0 a L 
// e tem n 
#include<bits/stdc++.h>
#define int long long 
using namespace std ; 

// bb na pos do pto 
// qual o 1o pto q se eu pegar do meu fica dist maior doq se eu pegar do meu anterior? esses são os ptos q podem ter maior dist ?

const int maxn = 1e5 + 5 ; 
const int inf = 1e18 ; 

double x[maxn], y[maxn] ; 
int n, l ; 

double dist(pair<double,double> a, pair<double,double> b){
	double dx = a.first - b.first, dy = a.second - b.second ;
	return (dx*dx) + (dy*dy) ; 
}

int32_t main(){

	// scanf("%d%d", &n, &l) ; 

	// for(int i = 1 ; i <= n ; i++){
	// 	scanf("%lf%lf", &x[i], &y[i]) ; 
	// }
	// double id ; 
	// double mx = 0.00 ; 
	// for(double i = 0.00000 ; i <= l*1.000000 ; i += 0.00001){
	// 	double mn = inf*1.00 ; 
	// 	for(int j = 1 ; j <= n ; j++){	
	// 		mn = min(mn, dist({x[j], y[j]}, {i, 0})) ; 
	// 	}
	// 	if(mn > mx) id = i ; 
	// 	mx = max(mx , mn) ; 
	// }

	// printf("%.3lf", id) ; 

	scanf("%d%d", &n, &l) ; 

	for(int i = 1 ; i <= n ; i++){
		scanf("%lf%lf", &x[i], &y[i]) ; 
	}

	vector<double> ptos ; 
	pair<double,double> ant = {x[1]-0.00001, y[1]-0.00001} ; 

	for(int i = 1 ; i <= n ; i++){
		double ini = 0.00000, fim = l*1.000000, mid ; double best = -1.00 ; 
		while(fim - ini >= 0.00001){ // qual 1o pto q p atual a dist dele passa no prox a ser maior p ant 
			mid = (ini + fim)/2 ; 
			//printf("%.4lf\n", mid) ;  
			if(dist(ant, {mid, 0.00000}) <= dist({x[i], y[i]}, {mid, 0.00})) best = mid, ini = mid + 0.00001; 
			else fim = mid - 0.00001 ; 
		}
		ant = {x[i], y[i]} ; 
		ptos.push_back(best) ;  
	}

	double mx = 0 ; 

	for(double a : ptos){
		if(a == -1) continue ; 
		double mn = inf*1.00 ; 
		for(int i = 1 ; i <= n ; i++){
			mn = min(mn, dist({a, 0.00}, {x[i], y[i]})) ; 
		}
		mx = max(mx, mn) ; 
	}

	printf("%.4lf\n", sqrt(mx)) ; 

}

Compilation message

mobile.cpp: In function 'int32_t main()':
mobile.cpp:42:10: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
   42 |  scanf("%d%d", &n, &l) ;
      |         ~^     ~~
      |          |     |
      |          int*  long long int*
      |         %lld
mobile.cpp:42:12: warning: format '%d' expects argument of type 'int*', but argument 3 has type 'long long int*' [-Wformat=]
   42 |  scanf("%d%d", &n, &l) ;
      |           ~^       ~~
      |            |       |
      |            int*    long long int*
      |           %lld
mobile.cpp:42:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |  scanf("%d%d", &n, &l) ;
      |  ~~~~~^~~~~~~~~~~~~~~~
mobile.cpp:45:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |   scanf("%lf%lf", &x[i], &y[i]) ;
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 2880 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1065 ms 2888 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 3064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 3244 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 3220 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 38 ms 3776 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 42 ms 3664 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 29 ms 3792 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 3700 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 31 ms 3724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 3676 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 34 ms 3660 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 46 ms 3764 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 36 ms 3656 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 46 ms 3604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -