Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Bismillahir Rahmanir Rahim
- /******Harun Or Rashid******/
- /***********Template Starts Here***********/
- #include<iostream>
- #include<cstdio>
- #include<cstring>
- #include<cmath>
- #include<cctype>
- #include<cstdlib>
- #include<string>
- #include<vector>
- #include<set>
- #include<stack>
- #include<queue>
- #include<map>
- #include<algorithm>
- using namespace std;
- #define MEM(a,b) memset(a,b,sizeof(a))
- #define CLR(a) memset(a,0,sizeof(a))
- #define MAX(a,b) ((a)>(b)?(a):(b))
- #define MIN(a,b) ((a)>(b)?(b):(a))
- #define ABS(a) ((a)>0? (a):(-(a)))
- #define SQ(a) ((a)*(a))
- #define SZ(a) (int)a.size()
- #define FORN(i,n) for(i=1;i<=n;i++)
- #define FORAB(i,a,b) for(i=a;i<=b;i++)
- #define ALL(V) V.begin(),V.end()
- #define pb(a) push_back(a)
- #define pr(a) cout<<a<<endl
- #define pf printf
- #define sf scanf
- #define swap(a,b) (a ^= b, b ^= a, a ^= b)
- #define PI 2*acos(0)
- #define x first
- #define y second
- #define eps 1e-9
- #define MX 50001
- typedef int D;
- typedef long long int LLD;
- typedef unsigned long long int LLU;
- typedef vector<D> VI;
- typedef set<D> SI;
- typedef vector<D>::iterator Viti;
- /***********Template Ends Here***********/
- int i,N;
- double X[MX],Y[MX],Z[MX],L,R,lx,ry;
- pair<double,double>P;
- bool isvalid(double h)
- {
- vector<pair<double,double> >V;
- for(i=0; i<N; i++)
- {
- if(Y[i]>=h+eps)
- {
- P.x=X[i]-tan(Z[i])*(Y[i]-h);
- P.y=X[i]+tan(Z[i])*(Y[i]-h);
- V.pb(P);
- }
- }
- if(V.size()==0) return false;
- sort(ALL(V));
- lx=V[0].x;
- ry=V[0].y;
- for(i=1; i<SZ(V); i++)
- {
- if(V[i].x<=ry)
- ry=MAX(ry,V[i].y);
- else
- {
- if(L>=lx && R<=ry)
- return true;
- lx=V[i].x;
- ry=V[i].y;
- }
- }
- return L>=lx && R<=ry;
- }
- int main()
- {
- double low,high,mid,result;
- cin>>N>>L>>R;
- for(i=0; i<N; i++)
- {
- cin>>X[i]>>Y[i]>>Z[i];
- Z[i]=Z[i]*PI/180;
- }
- low=0;
- high=1000;
- while((ABS(high-low))>eps)
- {
- mid=(low+high)/2.0;
- if(isvalid(mid))
- low=mid;
- else
- high=mid;
- }
- result=(low+high)/2.0;
- result+=eps;
- printf("%.10lf\n",result);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment