Submission #445957

# Submission time Handle Problem Language Result Execution time Memory
445957 2021-07-20T09:14:57 Z Qw3rTy Mobile (BOI12_mobile) C++11
0 / 100
671 ms 33532 KB
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define int long long
#define db double
#define delta 1e-6
#define INF 1e9+5
#define pi pair<int,int>
#define pb pair<db,db>
#define fi first
#define se second
using namespace std;

const int maxN = 1e6+5;

int N,L;
pi tower[maxN];
pb inter[maxN]; //intersections

bool cmp(pb a, pb b){
	if(abs(a.fi - b.fi) < delta)return a.se < b.se;
	return a.fi < b.fi;
}

bool works(db r){
	for(int i = 1; i <= N; ++i)inter[i].fi = inter[i].se = -INF;
	for(int i = 1; i <= N; ++i) {
		//Can't reach any point on the highway
		if (r * r - tower[i].se * tower[i].se < 0)continue;
		inter[i].fi = tower[i].fi - sqrt(r*r - tower[i].se*tower[i].se);
		inter[i].se = tower[i].fi + sqrt(r*r + tower[i].se*tower[i].se);
		inter[i].fi = (inter[i].fi < 0)?0:inter[i].fi;
		inter[i].se = (inter[i].se > L)?L:inter[i].se;
	}
	//sort(inter+1,inter+N+1,cmp);
	db a = 0; db b = 0;
	for(int i = 1; i <= N; ++i){
		//Invalid intersections
		if(inter[i].fi > inter[i].se)continue;
		//Merge intervals
		if(inter[i].fi <= b)b = (inter[i].se > b)?inter[i].se:b;
		else return false;
	}

	if(abs(a-0) < delta && abs(b-L) < delta)return true;
	return false;
}

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("../test.in","r",stdin);
	cin >> N >> L;
	for(int i = 1; i <= N; ++i)cin >> tower[i].fi >> tower[i].se;
	db low = 1; db high = 2e9;
	while(abs(high-low) > delta){
		db mid = (low+high)/2;
		if(works(mid))high = mid;
		else low = mid + delta;
	}
	cout << setprecision(6) << low  << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 40 ms 3448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 3384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 53 ms 3744 KB Output is correct
2 Incorrect 55 ms 4036 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 62 ms 5008 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 4960 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 337 ms 17908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 332 ms 17796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 388 ms 20932 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 406 ms 20784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 453 ms 24164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 464 ms 24004 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 532 ms 27308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 540 ms 27028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 663 ms 33532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 671 ms 31876 KB Output isn't correct
2 Halted 0 ms 0 KB -