Problem:
 Score : 400 points    Problem Statement There are N squares arranged in a row, numbered 1, 2, ..., N from left to right.
You are given a string S of length N consisting of . and # . If the i -th character of S is # , Square i contains a rock; if the i -th character of S is . , Square i is empty.  In the beginning, Snuke stands on Square A , and Fnuke stands on Square B .  You can repeat the following operation any number of times:   Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.   You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D .  Determine whether this is possible.      Constraints  4 \leq N \leq 200\ 000  S is a string of length N consisting of . and # .  1 \leq A, B, C, D \leq N  Square A , B , C and D do not contain a rock.  A , B , C and D are all different.  A < B  A < C  B < D         Input Input is given from Standard Input in the following format:  N  A  B  C  D  S       Output Print Yes if the objective is achievable, and No if it is not.        Sample Input 1 7 1 3 6 7
.#..#..      Sample Output 1 Yes  The objective is achievable by, for example, moving the two persons as follows. ( A and B represent Snuke and Fnuke, respectively.)  A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB       Sample Input 2 7 1 3 7 6
.#..#..      Sample Output 2 No       Sample Input 3 15 1 3 15 13
...#.#...#.#...      Sample Output 3 Yes

Solution (Python):
N,A,B,C,D=map(int,input().split())
S=input()
if '
    print('No')
    exit()

if C<D:
    print('Yes')
else:
    cnt=0
    for i in range(B-1,D):
        if S[i-1]==S[i] and S[i]==S[i+1] and S[i]=='.':
            print('Yes')
            exit()
    print('No')

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = input()

for i in range(A, C-1):
    if S[i] == "
        print("No")
        exit()
for i in range(B, D-1):
    if S[i] == "
        print("No")
        exit()

if A < B and C < D:
    print("Yes")
elif A > B and C < D:
    flag = False
    for i in range(A-2, C-1):
        if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
            flag = True
    if flag:
        print("Yes")
    else:
        print("No")
elif A < B and C > D:
    flag = False
    for i in range(B-2, D-1):
        if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
            flag = True
    if flag:
        print("Yes")
    else:
        print("No")   
else:
    print("Yes")

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = input()
canCross = False
for i, s in enumerate(S, start=1):
  if A < i < max(C, D) and s == '
    print('No')
    exit()
  if B <= i <= min(C, D) and s == '.' and S[i-2] == '.' and S[i] == '.':
    canCross = True
if C < D:
  print('Yes')
else:
  if canCross:
    print('Yes')
  else:
    print('No')

Solution (Python):
N,A,B,C,D = map(int,input().split())
S = input()
S = S[A-1:]
B -= A
C -= A
D -= A
A = 0

kabe = S.find("
if kabe != -1:
    if kabe < C or kabe < D:
        print('No')
        exit()
if C < D:
    print('Yes')
else:
    A = S[:B].rfind(".")
    S = S[A:]
    B -= A
    C -= A
    D -= A
    A = 0
    irekae = S.find("...")
    if irekae == -1:
        print('No')
        exit()
    if irekae + 2 <= C and irekae < D:
        print('Yes')
    else:
        print('No')

Solution (Python):
import sys, math
from functools import lru_cache
from itertools import accumulate
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

N, A, B, C, D = mi()
S = input()
f = (not '
if C > D:
    f = f and ('...' in S[B-2:D+1])

print('Yes' if f else 'No')

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = 'x' + input()
mx = D if D > C else C
if '
    print('No')
    exit()
if C > D:
    if '...' in S[B-1:D+2]:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Solution (Python):
N,A,B,C,D = map(int,input().split())
S = input()
if '
    print('No')
elif '
    print('No')
elif C>D:
    
    if not '...' in S[B-2:D+1]:
        print('No')
    else:
        print('Yes')
else:
    print('Yes')

Solution (Python):
n, a, b, c, d = map(lambda x:int(x)-1,input().split())
n += 1
S = input()

ok = True
overtake = False

if c < d:
    overtake = True
    
for i in range(a,d):
    if S[i] == "
        ok = False

for i in range(b,min(d+1,n-1)):
    if S[i] == "." and S[i-1] == "." and S[i+1] == ".":
        overtake = True
        
if ok and overtake:
    print('Yes')
else:
    print('No')

Solution (Python):
n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = input()
if c<d:
    if "
        print("No")
    else:
        print("Yes")
    exit()
else:
    if "
        print("No")
        exit()
    print("Yes" if "..." in s[b-1:d+2] else "No")

Solution (Python):
n,A,B,c,d=map(int,input().split())
s=input()
b=B-1
a=A-1
t=0
while t<2*n:
  if a!=c-1:
    if a+1<n and s[a+1]=='.' and a+1!=b:
      a+=1
    elif a+2<n and s[a+2]=='.' and a+2!=b and a+2<=c-1:
      a+=2
    else:
      if b+1<n and s[b+1]=='.' and b+1!=a:
        b+=1
      elif b+2<n and s[b+2]=='.' and b+2!=a and b+2<=d-1:
        b+=2
  else:
    if b!=d-1:
      if b+1<n and s[b+1]=='.' and b+1!=a:
        b+=1
      elif b+2<n and s[b+2]=='.' and b+2!=a and b+2<=d-1:
        b+=2
  t+=1
if a==c-1 and b==d-1:
  print('Yes')
else:
  print('No')

Solution (Python):
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

n,a,b,c,d = (int(x) for x in input().split())
s = input()

ok1 = True
cnt = 0
for i in xrange(b,d):
    if s[i-1] == "
        cnt += 1
        if cnt == 2:
            ok1 = False
            break
    else:
        cnt = 0

ok2 = True
cnt = 0
for i in xrange(a,c):
    if s[i-1] == "
        cnt += 1
        if cnt == 2:
            ok2 = False
            break
    else:
        cnt = 0
if d > c: 
    ok3 = True
else:
    cnt = 0
    ok3 = False
    for i in xrange(b-1,d+2):
        if s[i-1] == ".":
            cnt += 1
            if cnt == 3:
                ok3 = True
                break
        else:
            cnt = 0
if ok1 and ok2 and ok3:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right 
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

N,A,B,C,D = mint()
S = input()

def f(m,n):
    block2 = space3 = False
    b = s = 0
    for i in range(m-1,n):
        (b,s) = (b+1,0) if S[i]=='
        if not block2 and b==2:
            block2 = True
        if not space3 and s==3:
            space3 = True
    return block2, space3

if D<C:
    judge(not f(A,C)[0] and f(B-1,D+1)[1])
else:
    judge(not f(A,C)[0] and not f(B,D)[0])

Solution (Python):
N, A, B, C, D = map(int, input().split())
S= input()

A -= 1
B -= 1
C -= 1
D -= 1

ok = []
ng = []

for i in range(1, N - 1):
    if S[i] == S[i + 1] and S[i] == "
        ng.append(i)
    elif S[i - 1] == S[i] and S[i] == S[i + 1] and S[i] == ".":
        ok.append(i)

for ngi in ng:
    if (A < ngi and ngi < C) or (B < ngi and ngi < D):
        print("No")
        exit()

if C < D:
    print("Yes")

else:
    for oki in ok:
        if B <= oki and oki <= D:
            print("Yes")
            exit()

    print("No")

Solution (Python):

import sys
sys.setrecursionlimit(10**7)
N,A,B,C,D = map(int,input().split())
S = input()
A,B,C,D = A-1,B-1,C-1,D-1


if B == 1:
    a = S.find('...') + 1
else:
    a = S.find('...',3) + 1

dx = [1,2]


def dfs_ini(v,seen_ini,X):
    seen_ini[v] = True
    for i in range(2):
        next_v = v + dx[i]
        
        if not(-1<next_v<N):
            continue
        if (S[next_v] == '
            continue
        if seen_ini[next_v] == True:
            continue
        dfs_ini(next_v,seen_ini,X)


def dfs_fin(w,seen_fin,Y):
    seen_fin[w] = True
    for j in range(2):
        next_w = w + dx[j]
        
        if not(-1<next_w<N):
             continue
        if (S[next_w] == '
             continue
        if seen_fin[next_w] == True:
             continue
        dfs_fin(next_w,seen_fin,Y)



if C>D:
    seen_ini_A = [False]*N
    seen_fin_B = [False]*N
    
    if (a < B) or (a > D):
        a = B
    dfs_ini(A,seen_ini_A,a)
    dfs_fin(B,seen_fin_B,C)
    result = 'No'
    if seen_ini_A[C] and seen_fin_B[D]:
        result = 'Yes'


else:
    seen_ini_B = [False]*N
    seen_fin_A = [False]*N
    dfs_ini(B,seen_ini_B,A)
    dfs_fin(A,seen_fin_A,D)
    result = 'No'
    if seen_ini_B[D] and seen_fin_A[C]:
        result = 'Yes'

print(result)

Solution (Python):
N,A,B,C,D=map(int,input().split())

S=input()
jump=False
n=0
R=0

for i in range(A-1,D):
    if S[i]=="
        R+=1
        n=0
        if R>=2:
            print("No")
            exit()
    else:
        n+=1
        R=0

b=0
S=S+"G"
for j in range(B-2,D+1):
    if S[j]==".":
        b+=1
        if b>=3:
            print("Yes")
            exit()
    else:
        b=0

if C<D:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    N, A, B, C, D = map(int, input().split())
    S = list(input())
    E = max(C, D)
    cnt = 0
    for i in range(A-1, E):
        if S[i] == '
            cnt += 1
        else:
            cnt = 0
        if cnt >= 2:
            print('No')
            return
    if C < D:
        print('Yes')
        return
    cnt = 0
    for i in range(B-2, D+1):
        if S[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt >= 3:
            print('Yes')
            return
    print('No')
        
if __name__ == "__main__":
    main()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(250000)


def read():
    N, A, B, C, D = map(int, input().strip().split())
    S = input().strip()
    return N, A-1, B-1, C-1, D-1, S


def check_reachable(N, S, start):
    reachable = [False for s in S]
    reachable[start] = True
    
    def _bfs(x):
        for d in [1, 2]:
            nx = x + d
            if 0 <= nx < N and not reachable[nx] and S[nx] == ".":
                reachable[nx] = True
                _bfs(nx)
    
    _bfs(start)
    return reachable


def solve(N, A, B, C, D, S):
    r1 = check_reachable(N, S, A)
    r2 = check_reachable(N, S, B)
    if r1[B] and r2[D]:
        if C < D:
            return "Yes"
        else:
            for i in range(B, D+1):
                if r2[i] and 0 <= i-1 < N and 0 <= i+1 < N and r1[i-1] and r1[i+1]:
                    return "Yes"
    return "No"
        


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

Solution (Python):
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, A, B, C, D = map(int, input().split())
    S = input()
    flag = 0
    b=B
    a =A
    while A < C:
        if flag ==1 and S[A]=="
            print("No")
            exit()
        elif S[A] =="
            flag =1
        else:
            flag =0

        A +=1

    while B < D:
        if flag ==1 and S[B]=="
            print("No")
            exit()
        elif S[B] =="
            flag =1
        else:
            flag =0

        B +=1

    if C>D:
        j=b-1
        while j<D:
            if S[j-1]=="." and S[j]=="." and S[j+1]==".":
                print("Yes")
                exit()
            j+=1
        print("No")
        exit()
    else:
        print("Yes")




if __name__ == "__main__":
    main()

Solution (Python):
N,A,B,C,D=list(map(int,input().split()))
l=list(input())
if "
   print("No")
   exit()
if C>D:
   pass
else:
   print("Yes")
   exit()
if "..." in "".join(l[B-2:D+1]):
   print("Yes")
else:
   print("No")

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,a,b,c,d = LI()
    s = "
    ans = True
    if a<b and b<c and c<d:
        ans &= "
        ans &= "
    elif a<b and b<d and d<c:
        ans &= "
        ans &= "..." in s[b-1:d+2]
        ans &= "
    elif a<c and c<b and b<d:
        ans &= "
        ans &= "
    
    print("Yes" if ans else "No")
    
main()

Solution (Python):
n, a, b, c, d = map(int, input().split())
s = input()
a -= 1; b -= 1; c -= 1; d -= 1; e = 1
for i in range(b, min(c, d)+1):
    if s[i-1] == "." and s[i] == "." and s[i+1] == ".": e = 0
if c < d: e = 0
for i in range(a, max(c, d)):
    if s[i] == "
print("Yes") if e == 0 else print("No")

Solution (Python):

N,A,B,C,D = map(int, input().split()) 
S = [0] + list(input())









if A < B < D < C:
    need_passing = True
elif (A < B < C < D) or (A < C < B < D):
    need_passing = False



    
        
        
            
    
        

passing_point_set = set() 
imos_stop = list() 
imos_stop.append(0)

for i in range(1,N-1):
    if S[i] == S[i+1] == "
        imos_stop.append(imos_stop[-1] + 1)
    else:
        imos_stop.append(imos_stop[-1])

    if S[i] == S[i+1] == S[i+2] == ".":
        passing_point_set.add(i)

i = N-1
if S[i] == S[i+1] == "
    imos_stop.append(imos_stop[-1] + 1)
else:
    imos_stop.append(imos_stop[-1])


imos_stop.append(imos_stop[-1]) 




def is_reachable(start,goal):
    if imos_stop[start] == imos_stop[goal] and start <= goal: 
        return True
    else:
        return False

if need_passing == True: 
    for passing_point in passing_point_set:
        if ((is_reachable(A,passing_point) == True and is_reachable(passing_point,C) == True and is_reachable(B,passing_point) == True and is_reachable(passing_point,D) == True and D != passing_point) or
            (B-1 in passing_point_set and is_reachable(A,C) == True and is_reachable(B,D) == True)):
            
            
            
            
                
                
                
                
                
            
            print("Yes")
            break
    else:
        print("No")
else:
    if is_reachable(A,C) == True and is_reachable(B,D) == True:
        print("Yes")
    else:
        print("No")

Solution (Python):
n,a,b,c,d = map(int,input().split())
s = list(input())
s.insert(0,0)
for i in range(a,max(c,d)):
    if '
        print('No')
        exit(0)
if c < d:
    print('Yes')
else:
    for i in range(b-1,d):
        if '.' == s[i] and '.' == s[i+1] and '.' == s[i+2]:
            print('Yes')
            exit(0)
    print('No')

Solution (Python):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

if c < d:
    if "
        print("Yes")
    else:
        print("No")
else:
    if ("..." in s[b-2:d+1]) and ("
        print("Yes")
    else:
        print("No")

Solution (Python):


import sys



def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, a, b, c, d = input_int_list()
    S = input()

    for i in range(a - 1, max(c, d) - 1):
        if S[i] == S[i + 1] == "
            print("No")
            quit()
    if c < d:
        print("Yes")
        quit()
    if c > d:
        for i in range(b - 2, d - 1):
            if S[i: i + 3] == "...":
                print("Yes")
                quit()
        print("No")
        quit()


if __name__ == "__main__":
    main()

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = input()
for i in range(A - 1, max(C, D) - 1):
    if S[i] == S[i + 1] == '
        print("No")
        exit()

if C < D:
    print("Yes")
else:
    for i in range(B - 2, D - 1):
        if S[i:i + 3] == '...':
            print("Yes")
            exit()
    print('No')

Solution (Python):
n, a, b, c, d = map(int, input().split())
s = input()

a -= 1
b -= 1
c -= 1
d -= 1

if '
    print('No')
    exit()

if c < d:
    print('Yes')
else:
    if '...' in s[b-1:d+2]:
        print('Yes')
    else:
        print('No')

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = input()
print('No' if '

Solution (Python):
n,a,b,c,d=map(int,input().split())
s="0"+input()
x=s[a:c+1]
y=s[b:d+1]
if "
    print("No")
    exit()

if "
    print("No")
    exit()

if c>d:
    if not "..." in s[b-1:d+2]:
        print("No")
        exit()
    
print("Yes")

Solution (Python):
N, A, B, C, D = map(lambda  x: int(x) - 1, input().split())
S = input()
if C < D:
    if "
        print("No")
    else:
        print("Yes")
else:
    if "
        print("No")
    else:
        print("Yes")

Solution (Python):
n,a,b,c,d = map(int, input().split())
s = input()

if '
    print('No')
else:
    if c<d:
        print('Yes')
    else:
        if '...' in s[b-2:d+1]:
            print('Yes')
        else:
            print('No')

Solution (Python):
n,a,b,c,d=map(int,input().split())
s=list(input())
ch=0
ch1=0

if d<c:
  for i in range(a,c):
    if s[i]=='
      if s[i-1]=='
        ch+=1
  for j in range(b,d):
    if s[j]=='
      if s[j-1]=='
        ch+=1
  for k in range(b-1,d):
    
    if s[k-1]=='.' and s[k]=='.' and s[k+1]=='.':
      ch1+=1
      
  if ch==0 and ch1>0:
    print('Yes')
  else:
    print('No')
    
else:
  for i in range(a,c):
    if s[i]=='
      if s[i-1]=='
        ch+=1
  for j in range(b,d):
    if s[j]=='
      if s[j-1]=='
        ch+=1
  if ch==0:
    print('Yes')
  else:
    print('No')

Solution (Python):
import sys


def can_goal(start, goal):
	global S

	way = S[start:goal+1]

	if not '
		return True


def can_go_halfway(start, goal):
	global S

	way = S[start:goal+1]

	if way.find('...') > -1:
		return True


N, A, B, C, D = map(int, input().split())
S = input()
S = '.' + S

if C < D:
	if can_goal(B, D):
		if can_goal(A, C):
			print('Yes')
			exit()
else:
	if can_go_halfway(B - 1, D + 1):
		if can_goal(A, C):
			if can_goal(B, D):
				print('Yes')
				exit()

print('No')

Solution (Python):
N, A, B, C, D = [int(_) for _ in input().split()]
S = input()

if "
    print("No")
elif C < D:
    print("Yes")
elif "..." in S[B-2:D+1]:
    print("Yes")
else:
    print("No")

Solution (Python):
n, a, b, c, d = list(map(int, input().split()))
s = input()

last = "."
for i in range(a, max(c, d)):
    if last == "
        print("No")
        exit()
    last = s[i]

if c < d:
    print("Yes")
else:
    length = 0
    for i in range(b-2, d+1):
        if s[i] == ".":
            length += 1

            if length == 3:
                print("Yes")
                exit()
        else:
            length = 0

    print("No")

Solution (Python):
n, a, b, c, d = map(int, input().split())
s = input()

a = a-1
b = b-1
c = c-1
d = d-1

for i in range(a+1, d):
    if s[i-1] == '
        print('No')
        exit()

if c < d:
    print('Yes')
    exit()

for i in range(b, d+1):
    if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
        print('Yes')
        exit()
print('No')

Solution (Python):
N,A,B,C,D = map(int,input().split())
S = ['
CanReach = True
CanChange = False
for i in range(A,C):
    if S[i] == '
        CanReach = False
for i in range(B,D):
    if S[i] == '
        CanReach = False
if C < D:
    CanChange = True
else:
    for i in range(B,D+1):
        if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.':
            CanChange = True
if CanReach and CanChange:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    N, A, B, C, D = map(int, input().split())
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = input().rstrip()

    if C < D:
        is_ok = True
        for i in range(A, D):
            if S[i:i + 2] == "
                is_ok = False
                break
        ans = "Yes" if is_ok else "No"
    else:
        is_ok = True
        for i in range(A, C):
            if S[i:i + 2] == "
                is_ok = False
                break
        if not is_ok:
            ans = "No"
        else:
            is_ok = False
            for i in range(B, D + 1):
                if S[i - 1:i + 2] == "...":
                    is_ok = True
                    break
            ans = "Yes" if is_ok else "No"

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n, a, b, c, d = map(int, input().split())
s = input()

s = '

def can_reach(start, end):
    for i in range(start, end+1):
        if s[i] == '
            return False
    return True

if not can_reach(a, b) or not can_reach(b, d):
    print('No')
    exit()

if c > d:
    can_over = False
    for i in range(b, d+1):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            can_over = True
    if not can_over:
        print('No')
        exit()

print('Yes')

Solution (Python):
n, a, b, c, d = map(int, input().split())
s = input()

a -= 1
b -= 1
c -= 1
d -= 1

s += '

flg = True
ok = False
cnt = 0
for i in range(b, d):
    if s[i] == '
        cnt = 0
        if s[i+1] == '
            flg = False
    else:
        cnt += 1
        if cnt == 3:
            ok = True     
if cnt + 1 == 3:
    ok = True

if s[b-1] == '.' and s[b] == '.' and s[b+1] == '.':
    ok = True

if s[d-1] == '.' and s[d] == '.' and s[d+1] == '.':
    ok = True

for i in range(a, c):
    if s[i] == '
        flg = False

if c < d:
    print('Yes' if flg else 'No')

else:
    print('Yes' if flg and ok else 'No')

Solution (Python):
n,a,b,c,d = map(int,input().split())
s = list(input())
for i in range(min(a,b),max(c,d)):
    if s[i] == "
        print("No")
        quit()
if c < d:
    print("Yes")
elif c > d:
    for j in range(b-1,d):
        if s[j] == "." and s[j+1] == "." and s[j-1] == ".":
            print("Yes")
            quit()
    print("No")

Solution (Python):
n,a,b,c,d=list(map(int,input().split()))
s=input()

if c<d:
    for i in range(a-1,d-1):
        if s[i]=='
            print('No')
            exit(0)
    print('Yes')
else:
    for i in range(b-1,d):
        if s[i-1]=='.' and s[i]=='.' and s[i+1]=='.':
            break
    else:
        print('No')
        exit(0)
    
    for i in range(a-1,c-1):
        if s[i]=='
            print('No')
            exit(0)
    
    print('Yes')

Solution (Python):
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,A,B,C,D =MI()
    S=input()
    A-=1
    B-=1
    C-=1
    D-=1
    
    flag=1
    if "
        flag=0
    if "
        flag=0
        
    if C>D:
        if "..." in S[B-1:D+2]:
            pass
        else:
            flag=0
            
    if flag:
        print("Yes")
    else:
        print("No")
        

main()

Solution (Python):
n,a,b,c,d = map(int,input().split())
s = "s" + input()

for i in range(a,max(c,d)-1):
        if s[i] == s[i+1] == "
            print("No")
            exit()
if c < d:
    print("Yes")
else:
    for i in range(b,d+1):
        if s[i+1] == s[i-1] == s[i] == ".":
            print("Yes")
            exit()
    print("No")

Solution (Python):
n,a,b,c,d=map(int,input().split())
s=[0]+list(input())
if c<d:
    for i in range(a,d):
        if s[i]==s[i+1]=="
            print("No")
            break
    else:
        print("Yes")
else:
    for j in range(a,c):
        if s[j]==s[j+1]=="
            print("No")
            break
    else:
        for k in range(b-1,d):
            if s[k]==s[k+1]==s[k+2]==".":
                    print("Yes")
                    break
        else:
            print("No")

Solution (Python):
N,A,B,C,D = map(int, input().split())
S = input()

if "
    print("No")
elif D < C and ("..." not in S[B-2:D+1]):
    print("No")
else:
    print("Yes")

Solution (Python):
n, a, b, c, d = map(int, input().split())
s = list(input())
jud = True

for i in range(min(a, b) - 1, max(c, d) - 1):
    if s[i] == "
        if s[i + 1] == "
            jud = False
            break

if (a < b and c > d and jud) or (a > b and c < d and jud):
    jud = False
    for i in range(max(a, b) - 2, min(c, d) - 1):
        if s[i] == ".":
            if s[i + 1] == "." and s[i + 2] == ".":
                jud = True

if jud:
    print("Yes")
else:
    print(("No"))

Solution (Python):







def solve(a,b,c,d,s):
  if '
    return False
  if c < d:
    return True
  elif c > d:
    if "..." in s[b-1:d+2]:
      return True
    else:
      return False
  else:
    raise ValueError




def main():
  N,A,B,C,D = map(int,input().split())
  A -= 1
  B -= 1
  C -= 1
  D -= 1
  S = input()
  print("Yes" if solve(A,B,C,D,S) else "No")
  return

if __name__ == '__main__':
  main()

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, A, B, C, D = LI()
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = SS()

    
    if '
        print('No')
    else:
        
        if C < D:
            print('Yes')
        
        else:
            
            if '...' in S[B-1:D+2]:
                print('Yes')
            else:
                print('No')

if __name__ == '__main__':
    resolve()

Solution (Python):


def main():
    N, A, B, C, D = map(int, input().split())
    S = input()
    ans = 'Yes'
    if C <D:
        if '
            ans = 'No'
    else:
        if '
            ans = 'No'
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
n,a_start,b_start,a_goal,b_goal = map(int,input().split())
s = input()
a_start -= 1
b_start -= 1
a_goal -= 1
b_goal -= 1

no_rock_double = True
for i in range(a_start, max(b_goal,a_goal)):
    if i+1 < n:
        if s[i] == '
            no_rock_double = False
can_switch = False
if a_goal > b_goal:
    for i in range(b_start, b_goal+1):
        if i + 2 < n:
            if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
                can_switch = True
    if no_rock_double and can_switch:
        print('Yes')
    else:
        print('No')
else:
    if no_rock_double:
        print('Yes')
    else:
        print('No')

Solution (Python):
N,A,B,C,D = map(int,input().split())
S = input()
if C == D:
    print("No")
    exit()
dot = 0
rock = 0
bol = 0
for i in range(1,N+1):
    if S[i-1] == ".":
        dot += 1
        rock = 0
        if dot >= 3 and B < i <= D + 1:
            bol = 1
    else:
        rock += 1
        dot = 0
        if rock >= 2 and A < i < max(C,D):
            print("No")
            exit()
if C < D:
    print("Yes")
    exit()
print("Yes" if bol == 1 else "No")

Solution (Python):
n,a_start,b_start,a_goal,b_goal = map(int,input().split())
s = input()

no_rock_double = True
for i in range(a_start, max(b_goal,a_goal)):
    if i+1 < n:
        if s[i] == '
            no_rock_double = False
can_switch = False
if a_goal > b_goal:
    for i in range(b_start-1, b_goal):
        if i + 2 < n:
            if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
                can_switch = True
    if no_rock_double and can_switch:
        print('Yes')
    else:
        print('No')
else:
    if no_rock_double:
        print('Yes')
    else:
        print('No')

Solution (Python):
n,a_start,b_start,a_goal,b_goal = map(int,input().split())
s = input()

no_rock_double = True
for i in range(a_start, max(b_goal,a_goal)):
    if i+1 < n:
        if s[i] == '
            no_rock_double = False
can_switch = False
if a_goal > b_goal:
    for i in range(b_start-1, b_goal):
        if s[i - 1:i + 2] == "...":
            can_switch = True
    if no_rock_double and can_switch:
        print('Yes')
    else:
        print('No')
else:
    if no_rock_double:
        print('Yes')
    else:
        print('No')

Solution (Python):
n, a, b, c, d = map(int, input().split())
s = input()


if '
    print('No')
else:
    if c < b or c < d:
        print('Yes')
    else:
        if '...' in s[b-2:d+1]:
            print('Yes')
        else:
            print('No')

Solution (Python):
def main():
    n, a, b, c, d = map(int, input().split())
    s = input()
    s = '.' + s

    if '
        print('No')
    else:
        if c < b:
            print('Yes')
        elif c < d:
            print('Yes')
        else:
            if '...' in s[b-1:d+2]:
                print('Yes')
            else:
                print('No')


if __name__ == '__main__':
    main()

Solution (Python):
n, a, b, c, d = map(int, input().split())
s = input()

if '
    print('No')
    exit()

if c < d:
    print('Yes')
    exit()

if '...' in s[b-2:d+1]:
    print('Yes')
else:
    print('No')

Solution (Python):
import copy
def main():
    n, a, b, c, d = map(int, input().split())
    step = list(input())

    sn = a - 1
    fn = b - 1

    sn_goal = False
    fn_goal = False
    jump = -1
    
    while True:
        if d < c:
            if (step[fn - 1] == ".") and (step[fn + 1] == "."):
                jump = copy.deepcopy(fn)

        if fn == d - 1:
            fn_goal = True
            break

        if step[fn + 1] == ".":
            fn += 1
        elif step[fn + 2] == ".":
            fn += 2
        else:
            break

    if d < c:
        if jump == -1:
            print("No")
            exit()

        step[jump] = "

    while True:
        if sn == c - 1:
            sn_goal = True
            break

        if step[sn + 1] == ".":
            sn += 1
        elif step[sn + 2] == ".":
            sn += 2
        else:
            break
    
    if sn_goal and fn_goal:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()