Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const double g = 9.8;

pair<double, double> tanth(int a, int b, int v)
{
	double d = a*a*v*v*v*v - g*a*(g*a-2*v*v*b);

	if(d<0) return make_pair<double, double>(-1,-1);
	double kai1 = (a*v*v + sqrt(d)) / g*a;
	double kai2 = (a*v*v - sqrt(d)) / g*a;
	return make_pair<double, double>(kai1, kai2);
}

double f(double th, int v, int x)
{
	double si = sin(th);
	double co = cos(th);
	double naka = 1.0*x - v*v*si*co/g;
	double hidari = -1*g/(v*v*co*co)*naka*naka;
	return hidari + v*v*si*si/g/2;
}

int main(){
	int n;
	int v, x, y;
	pair<double, double> buf;
	while(cin>>n>>v>>x>>y){
		vector<int> allL;
		vector<int> allB;
		vector<int> allR;
		vector<int> allT;
		vector<double> allTAN;
		for(int i=0; i<n; i++){
			int l, b, r, t;
			cin>>l>>b>>r>>t;
			allL.push_back(l);
			allB.push_back(b);
			allR.push_back(r);
			allT.push_back(t);
			buf = tanth(l, b, v);
			if(buf.first>0) allTAN.push_back(buf.first);
			if(buf.second>0) allTAN.push_back(buf.second);
			buf = tanth(r, b, v);
			if(buf.first>0) allTAN.push_back(buf.first);
			if(buf.second>0) allTAN.push_back(buf.second);
			buf = tanth(l, t, v);
			if(buf.first>0) allTAN.push_back(buf.first);
			if(buf.second>0) allTAN.push_back(buf.second);
			buf = tanth(r, t, v);
			if(buf.first>0) allTAN.push_back(buf.first);
			if(buf.second>0) allTAN.push_back(buf.second);
		}
		buf = tanth(x, y, v);
		if(buf.first>0) allTAN.push_back(buf.first);
		if(buf.second>0) allTAN.push_back(buf.second);
		if(n==0){
			if(buf.first<0 && buf.second<0){
				cout<<"No"<<endl;
				continue;
			}
			cout<<"Yes"<<endl;
			continue;
		} 
		sort(allTAN.begin(), allTAN.end());
		bool okflg = false;
		for(int i=0; i<allTAN.size()-1; i++){
			double ta = (allTAN[i] + allTAN[i+1])/2;
			double th = atan(ta);
			double si = sin(th);
			double co = cos(th);
			double thox = v*v*si*co/g;
			double thoy = v*v*si*si/g/2;
			bool dameflg = false;
			for(int j=0; j<allL.size(); j++){
				// ÖWÌ³¢ubN
				if(allL[j]>x) continue;

				// ÈPÈá
				if(allR[j]<x){
					if(
						(f(th,v,allL[j])<allB[j]&&f(th,v,allR[j])<allB[j]) ||
						(f(th,v,allL[j])>allT[j]&&f(th,v,allR[j])>allT[j]) ){
							// Êß
							continue;
					} else {
						dameflg = true;
						break;
					}
				}

				// ßñÇ¢á
				if(thoy < allB[j]){
					// ¸_ªubNÌº
					continue;
				}else if(f(th,v,allL[j])>allT[j]&&f(th,v,allR[j])>allT[j]){
					// ubNÌã
					continue;
				} else {
					dameflg = true;
					break;
				}
			}
			if(!dameflg){
				if(f(th,v,x)>y){
					bool butukaruflg = false;
					for(int j=0; j<allL.size(); j++){
						if(allL[j]<x && x<allR[j]){
							if(y<allB[j] && allT[j]<thoy){
								butukaruflg = true;
								break;
							}
						}
					}
					if(!butukaruflg){
						okflg = true;
						break;
					}

				}
			}
		}
		if(okflg){
			cout<<"Yes"<<endl;
		} else {
			cout<<"No"<<endl;
		}
	}
}

Compiler output:
a.cc: In function 'std::pair<double, double> tanth(int, int, int)':
a.cc:13:32: error: 'sqrt' was not declared in this scope
   13 |         double kai1 = (a*v*v + sqrt(d)) / g*a;
      |                                ^~~~
a.cc:15:42: error: cannot bind rvalue reference of type 'double&&' to lvalue of type 'double'
   15 |         return make_pair<double, double>(kai1, kai2);
      |                                          ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1132:21: note:   initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = double; _T2 = double; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = double; typename decay<_Tp>::type = double; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = double; typename decay<_Tp2>::type = double]'
 1132 |     make_pair(_T1&& __x, _T2&& __y)
      |               ~~~~~~^~~
a.cc: In function 'double f(double, int, int)':
a.cc:20:21: error: 'sin' was not declared in this scope; did you mean 'si'?
   20 |         double si = sin(th);
      |                     ^~~
      |                     si
a.cc:21:21: error: 'cos' was not declared in this scope; did you mean 'co'?
   21 |         double co = cos(th);
      |                     ^~~
      |                     co
a.cc: In function 'int main()':
a.cc:72:37: error: 'atan' was not declared in this scope; did you mean 'ta'?
   72 |                         double th = atan(ta);
      |                                     ^~~~
      |                                     ta
a.cc:73:37: error: 'sin' was not declared in this scope; did you mean 'si'?
   73 |                         double si = sin(th);
      |                                     ^~~
      |                                     si
a.cc:74:37: error: 'cos' was not declared in this scope; did you mean 'co'?
   74 |                         double co = cos(th);
      |                                     ^~~
      |                                     co