Language: C++

#include <bits/stdc++.h>
using namespace std;

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//chcp 65001

signed main()
{
	int n,a,b,c,d;cin>>n>>a>>b>>c>>d;
	string s;cin >> s;

if(s.size() <= 5){
	cout << "No";
	goto LLast;
}


if(c < d){
int cnt{};
	bool nimasu = false;
	bool gb = false;
bool dupli = false;
	for(int i = b-1, i_len = (int)n; i < i_len; ++i){
//		if(cnt >= LINF){cout << "No";dupli = true; break;}
		if(s[i] == '#'){
			--i;
			nimasu = true;
		}
		if(nimasu){
			++i;++i;
			nimasu = false;//こいつ後ろへ、やっぱなし
			//2マス後が岩ならアウト
			if(s[i] == '#'){
				gb = false;
				break;
			}
		}
		if(i == d-1){
			gb = true;
			break;
		}
		++cnt;
	}
//b < cとは限らない
//c < dも
bool animasu = false;
bool ga = false;
	for(int i = a-1, i_len = (int)n; i < i_len; ++i){
/*		if(dupli){
			break;}
		if(cnt >= LINF){cout << "No"; break;}
*/		
		if(s[i] == '#'){
			--i;
			animasu = true;
		}
		if(animasu){
			++i;++i;
			animasu = false;
			if(s[i] == '#'){
				ga = false;
				break;
			}			
		}
		if(i == c-1){
			ga = true;
			break;
		}
		++cnt;
	}
if(!dupli){
	if(ga && gb){
		cout << "Yes" << endl;
	}else cout << "No" << endl;	
}
}
// b < d < c
if(d < c){
int cnt{};
	bool nimasu = false;
	bool gb = false;
bool dupli = false;
	for(int i = b-1, i_len = (int)n; i < i_len; ++i){
//		if(cnt >= LINF){cout << "No";dupli = true; break;}
		if(s[i] == '#'){
			--i;
			nimasu = true;
		}
		if(nimasu){
			++i;++i;
			nimasu = false;
			if(s[i] == '#'){
				gb = false;
				break;
			}			
		}
		if(i == d-1){
			gb = true;
			break;
		}
		++cnt;
	}
//b < cとは限らない
//c < dも
bool animasu = false;
bool ga = false;
	for(int i = a-1, i_len = (int)n; i < i_len; ++i){
/*		if(dupli){
			break;}
		if(cnt >= LINF){cout << "No"; break;}
*/		
		if(s[i] == '#' || i == d-1){
			--i;
			animasu = true;
		}
		if(animasu){
			++i;++i;
			animasu = false;
			if(s[i] == '#' || i == d-1){
				gb = false;
				break;
			}			
		}
		if(i == c-1){
			ga = true;
			break;
		}
		++cnt;
	}

if((ga && gb) == 0)
{
	int cnt{};
bool animasu = false;
bool gc = false;
	for(int i = a-1, i_len = (int)n; i < i_len; ++i){
/*		if(dupli){
			break;}
		if(cnt >= LINF){cout << "No"; break;}
*/		
		if(s[i] == '#' || i == d-1){
			--i;
			animasu = true;
		}
		if(animasu){
			++i;++i;
			animasu = false;
			if(s[i] == '#' || i == d-1){
				gc = false;
				break;
			}			
		}
		if(i == c-1){
			gc = true;
			break;
		}
		++cnt;
	}	

	bool nimasu = false;
	bool gd = false;
	for(int i = b-1, i_len = (int)n; i < i_len; ++i){
//		if(cnt >= LINF){cout << "No";dupli = true; break;}
		if(s[i] == '#'){
			--i;
			nimasu = true;
		}
		if(nimasu){
			++i;++i;
			nimasu = false;
			if(s[i] == '#'){
				gd = false;
				break;
			}			
		}
		if(i == d-1){
			gd = true;
			break;
		}
		++cnt;
	}	
}

if(!dupli){
	if((ga && gb) || (gc && gd)){
		cout << "Yes" << endl;
	}else cout << "No" << endl;	
}
}
LLast:

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:232:27: error: 'gc' was not declared in this scope; did you mean 'ga'?
  232 |         if((ga && gb) || (gc && gd)){
      |                           ^~
      |                           ga
a.cc:232:33: error: 'gd' was not declared in this scope; did you mean 'ga'?
  232 |         if((ga && gb) || (gc && gd)){
      |                                 ^~
      |                                 ga