답안 #494126

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
494126 2021-12-14T12:19:20 Z PikaQ Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 80860 KB
#include<bits/stdc++.h>
#define int ll
#define forn(i,n) for(int i=0;i<(n);i++)
#define Forn(i,n) for(int i=1;i<=(n);i++)
#define ll long long
#define pb push_back
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define vi vector<int>
#define vl vector<long long>
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define rz resize
#define all(p) p.begin(),p.end()
#define alr(p,q) p+1,p+q+1
#define ull unsigned long long
#define st0(p) memset((p),0,sizeof(p))
#define T(x) ((x)%2 ? s[(x)/2] : '.')
#define lowb(x) x&-x
#define ls(x) (x)*2
#define rs(x) (x)*2+1
using namespace std;

inline void USACO(string filename){
	freopen((filename+".in").c_str(),"r",stdin);
	freopen((filename+".out").c_str(),"w",stdout);
}

void debug() {cout << endl;}
template <class T, class ...U> void debug(T a, U ... b) { cout << a << " "; debug(b...);}
// template <class T> int max(T a, T ... b) { cout << a << " "; debug(b...);}
const int INF = 1e9+7;
const double eps = 1e-7;
const int N = 8e2+9;
int n;

#define double long double
#define pdd pair<double,double> 
double L;
vector<pdd> p;


bool check(double R){
	vector<pdd> vs;
	for(auto &i : p){
		double dy = abs(i.S);
		if(dy > R) continue;
		double d = sqrt(R*R - dy*dy);
		double l = i.F -d,r = i.F +d;
		l = max((double)0,l),r = min(L,r);
		vs.pb({l,r});
	}
	sort(all(vs));
	bool flag = 0;
	double l,r;
	for(auto &i : vs){
		if(!flag){
			l = i.F,r = i.S;
			flag = 1;
			continue;
		}
		if(i.F > r) return 0;
		r = max(r,i.S);
	}
	return (l == 0 && r == L);
}

void solve(){
	cin >> n >> L;
	p.rz(n);
	forn(i,n) cin >> p[i].F >> p[i].S;
	sort(all(p));
	double lo = 0,hi = 1e18;
	int cnt = 1e5+1;	
	while(hi - lo > 1e-7){
		double mid = (lo+hi)/2;
		if(check(mid)) hi = mid;
		else lo = mid;
	}
	cout << hi << '\n';
}		 	



signed main(){
	// USACO("angry");
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);

		cout << fixed << setprecision(6);
	// int t;
	// cin >> t;
	// while(t--)
		solve();
	return 0;
}

Compilation message

mobile.cpp: In function 'void solve()':
mobile.cpp:78:6: warning: unused variable 'cnt' [-Wunused-variable]
   78 |  int cnt = 1e5+1;
      |      ^~~
mobile.cpp: In function 'bool check(long double)':
mobile.cpp:69:17: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
   69 |  return (l == 0 && r == L);
      |         ~~~~~~~~^~~~~~~~~~
mobile.cpp:69:17: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 70 ms 1000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 65 ms 1064 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 59 ms 1020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1084 ms 9212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1081 ms 9476 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1080 ms 10308 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 11076 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1089 ms 10804 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1079 ms 48124 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1085 ms 48064 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1089 ms 68332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1092 ms 68316 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1088 ms 71468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1094 ms 71460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1095 ms 74652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1057 ms 74636 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 80828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1091 ms 80860 KB Time limit exceeded
2 Halted 0 ms 0 KB -