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()

ans = True
d = False
for i in range(B,D-1):
    if(S[i] == "
        ans = False
        break
    elif(S[i] == "
        d = True
    else:
        d = False
d = False
for j in range(A,C-1):
    if(S[j] == "
        ans = False
        break
    elif(S[j] == "
        d = True
    else:
        d = False
if(C>D):
    ans = ans and S[B-2:D+1].count("...")!=0

print("Yes" if ans else "No")

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

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

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

if a > b:
    a,b,c,d = b,a,d,c




"""
  012345678
 "
5
>>> "
'
>>> "
'
>>> "0123456789"[1:7]
'123456'
"""

if c < d:
    
    
    
    
    if s[a:d+1].find("
        print("Yes")
    else:
        print("No")

else:
    
    
    
    
    if s[b-1:d+2].find("...") != -1:
        
        if s[a:c + 1].find("
            print("Yes")
        else:
            print("No")
    else:
        
        print("No")

Solution (Python):
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

def main():
    N, A, B, C, D = LI_()
    S = SI().strip()

    if C < D:  
        if B < C:  
            
            previous = '.'
            for i in range(A, D+1):
                if S[i] == '
                    if previous == '
                        print('No')
                        return
                    else:
                        previous = '
                else:
                    previous = '.'
            print('Yes')
            return

        elif C < B:  
            
            previous = '.'
            for i in range(A, C+1):
                if S[i] == '
                    if previous == '
                        print('No')
                        return
                    else:
                        previous = '
                else:
                    previous = '.'

            previous = '.'
            for i in range(B, D+1):
                if S[i] == '
                    if previous == '
                        print('No')
                        return
                    else:
                        previous = '
                else:
                    previous = '.'

            print('Yes')
            return

    elif D < C:  
        
        count_continuous_dots = 0
        can_evac = False
        previous = '.'
        for i in range(A, C+1):
            if S[i] == '
                if previous == '
                    print('No')
                    return
                else:
                    previous = '
                    count_continuous_dots = 0
            else:
                previous = '.'
            if B-1 <= i <= D+1:
                if S[i] == '.':
                    count_continuous_dots += 1
                    if count_continuous_dots >= 3:
                        can_evac = True
        if can_evac:
            print('Yes')
        else:
            print('No')
        return


main()

Solution (Python):
p = [int(x) for x in input().split()]
moji = input()
x = [moji[i:i+1] for i in range(len(moji))]
n = p[0]
a = p[1]
b = p[2]
c = p[3]
d = p[4]
y = x[1:]
z = x[2:]

lista = []
for s,t,u in zip(x,y,range(len(y))):
	if s == '
		lista.append(u+1)
listb = []
for s,t,u,v in zip(x,y,z,range(len(z))):
	if s == '.' and t == '.' and u == '.':
		listb.append(v+1)

if any((a < elem and elem < c) or (b < elem and elem < d)  for elem in lista):
	print('No')
elif c < d:
	print('Yes')
elif any(b-1 <= elem and elem < d  for elem in listb):
	print('Yes')
else:
	print('No')

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

start = min(a,b)
stop = max(c,d)
ans=0

if a<b and c<d:
    for i in range(start, stop):
        if s[i] == "
            ans = "No"
            break
    if ans == 0:
        ans = "Yes"

elif b<a  and d<c:
    for i in range(start-1, stop):
        if s[i] == "
            ans = "No"
            break
    if ans == 0:
        ans = "Yes"

elif a<b and d<c:
    judge = 0

    for i in range(start-1, stop):
        if b-1 <=i <= d-2:
            if s[i]=="." and s[i+1]=="." and s[i+2]==".":
                judge = 1
        if s[i] == "
            ans = "No"
            break

    if ans == 0:
        if s[b-2]=="." and s[b]==".":
            ans = "Yes"
        elif judge == 1:
            ans = "Yes"
        elif judge == 0:
            ans = "No"

elif b<a and c<d:
    judge = 0

    for i in range(start, stop):
        if a-1 <=i <= c-2:
            if s[i]=="." and s[i+1]=="." and s[i+2]==".":
                judge = 1
        if s[i] == "
            ans = "No"
            break

    if ans == 0:
        if s[a-2]=="." and s[a]==".":
            ans = "Yes"
        elif judge == 1:
            ans = "Yes"
        elif judge == 0:
            ans = "No"
print(ans)

Solution (Python):
def check (A):
    for i in range(len(A)-1):
        if A[i]*A[i+1] == 1:
            return False
            break
    return True

def check_zero (B):
    for i in range(len(B)-2):
        if B[i] == 0 and B[i+1] == 0 and B[i+2] == 0:
            return True
            break
    return False

[N,A,B,C,D] = list(map(int,input().split()))
S_ori = str(input())
S = [0]*len(S_ori)
for i in range(len(S)):
    if S_ori[i] == ".":
        S[i] = 0
    else:
        S[i] = 1

if D > C:
    if check(S[B-1:D]) == False:
        print("No")
    else:
        if check(S[A-1:C]) == True:
            print("Yes")
        else:
            print("No")
else:
    if check(S[B-1:D]) == False:
        print("No")
    else:
        if check_zero(S[B-2:D+1]) == True:
            print("Yes")
        else:
            print("No")

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

for i in range(A,D-1):
    if S[i] == '
        if S[i - 1] == '
            print('No')
            exit(0)
if C < D:
    print('Yes')
    exit(0)

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

Solution (Python):
import sys
from collections import deque
from operator import itemgetter
import math

input = sys.stdin.readline

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

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


ans = "Yes"
f = 0
if C>D:
    f = 1


if f == 0:
    now = S[A-1]
    count = 0
    for i in range(A-1,C):
        if S[i]=='
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break
  
    count = 0
    for i in range(B-1,D):
        if S[i]=='
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break
       


if f == 1:
    now = S[A-1]
    count = 0
    count_space = 0
    space_flag = False

    for i in range(B-2,D+1):
        if S[i]=='
            count_space = 0
        else:
            count_space += 1
        if count_space == 3:
            space_flag = True

    if not space_flag:
        ans = "No"
    
    for i in range(A-1,C):
        if S[i]=='
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break

    
    
    count = 0
    for i in range(B-1,D):
        if S[i]=='
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break

print(ans)

Solution (Python):
n,a,b,c,d=map(int,input().split())
s=input()
def ok(p,q,s):
    return s[p-1:q].count("
if a<c<b<d:
    if ok(a,c,s) and ok(b,d,s):
        print("Yes")
    else:
        print("No")
elif a<b<c<d:
    if ok(a,c,s) and ok(b,d,s):
        print("Yes")
    else:
        print("No")
elif a<b<d<c:
    if ok(b,d,s):
        s=s[:b-1]+"
        if ok(a,c,s):
            print("Yes")
        else:
            s=s[:b-1]+"."+s[b:]
            if s[b-1:d+1].count("...")>0:
                print("Yes")
            else:
                print("No")
    else:
        print("No")

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

A -= 1; B -= 1
S = input()
if (C<D):
    if ("
        print("No")
    else:
        print("Yes")
else:
    if ("
        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()
s=[0]*N
stop=[0]*N
space=[0]*N
for i in range(N):
    if S[i]=='
        s[i]=1
        if i>0 and s[i-1]==1:
            stop[i]=1
    elif i>1 and s[i-1]==0 and s[i-2]==0:
        space[i]=1
    if i>0:
        stop[i]+=stop[i-1]
        space[i]+=space[i-1]
if stop[C]-stop[A]>0 or stop[D]-stop[B]>0:
    ans=0
elif C<D:
    ans=1
elif space[D+1]-space[B]>0:
    ans=1
else:
    ans=0
print(['No','Yes'][ans])

Solution (Python):
n,a,b,c,d=map(int,input().split())
s=input()+"
f=False
for i in range(1,n+1):
    if s[i-1]+s[i]=="
        if a<i<c or b<i<d:
            print("No")
            exit()
    else:
        if i>2:
            if s[i-2]+s[i-1]+s[i]=="."*3:
                if b<=i<=d:
                    f=True
else:
    if c<d:
        print("Yes")
    else:
        if f:
            print("Yes")
        else:
            print("No")

Solution (Python):
import sys

fin = sys.stdin.readline
N, A, B, C, D = [int(elem) for elem in fin().split()]
cell_list = fin().split()[0]

init_max = max(A, B)
init_min = min(A, B)
end_max = max(C, D)
end_min = min(C, D)

after_min_cells = cell_list[init_min:end_max-1]
after_max_cells = cell_list[max(0, init_max-2):end_min+1]

if '
    result = 'No'

elif (A-B) * (C-D) < 0:
    
    if '...' in after_max_cells:
        result = 'Yes'
    else:
        result = 'No'
else:
    result = 'Yes'

print(result)

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


if s[c-1] =='
    print('No')
    exit(0)
if s[c-1] =='
    print('No')
    exit(0)
for i in range(b,d-1):
    if s[i]=='
        print('No')
        exit(0)
for i in range(a,c-1):
    if s[i]=='
        print('No')
        exit(0)
if c>d:
    flag = False
    for i in range(b-2,d-1):
        if s[i:i+3]=='...':
            flag = True
            break
    if not flag:
        print("No")
        exit(0)
    else:
        print("Yes")
else:
    print("Yes")

Solution (Python):
N,A,B,C,D=list(map(int,input().split()))
S=input()
bS=S[B-1:D]
a=True
if C<D:
    if "
        a=False
    else:
        aS=S[A-1:C]
        if "
            a=False

else:
    if "
        a=False
    else:
        aS=S[A-1:C]
        if "
            a=False
        else:
            tmp=S[:B-1]+"
            aS=tmp[A-1:C]
            j1= ("
            tmp=S[:D-1]+"
            aS=tmp[A-1:C]
            j2= ("
            if  ((not "..." in bS) and (j1 and j2)):
                a=False
            
        
        
if a:
    print("Yes")
else:
    print("No")

Solution (Python):
import math

n, a, b, c, d = [int(i) for i in input().split()]


s = input()
list = list(s)





flag = 1





for i in range(a-1, c-1) :
    if ( list[i] == '
        if ( list[i+1] == "
            flag = 0

for i in range(b-1, d-1) :
    if ( list[i] == "
        if ( list[i+1] == "
            flag = 0



if (d < c) :
    flag = 0
    for i in range(b-2, d-1) :
        if (list[i] == '.' and list[i+1] == '.' and list[i+2] == '.') :
            flag = 1

if (flag == 1) :
    print("Yes")
else :
    print("No")

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

def check() :
    if '
        return 'No'

    if C < D or '...' in S[B-2:D+1] :
        return 'Yes'

    return 'No'
        

print(check())

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


if c > d:
        a,b = b,a
        c,d = d,c


if a < b:
        
        
        t = s[b:d]
        if t.count('
                print('No')
                exit()
        t = s[a:c]
        if t.count('
                print('No')
                exit()
        print('Yes')
        exit()
else:
        t = s[b:d]
        if t.count('
                print('No')
                exit()
        t = s[a-2:c+1]
        if t.count('...') == 0:
                print('No')
                exit()
        print('Yes')
        exit()

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

if C < D:
    for i in range(A, D):
        if S[i] == '
            print("No")
            break
        elif i + 1 == D: print("Yes")
else:
    for i in range(B, D + 1):
        if S[i] == '
            print("No")
            break
        elif S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
            for j in range(A, C):
                if S[j] == '
                    print("No")
                    break
                elif j + 1 == C: print("Yes")
            break
        elif i + 1 == D + 1: print("No")

Solution (Python):
n , a0 , b0 , c0 , d0 = map(int,input().split())
s = input()


if a0 > b0 : 
    a = b0
    b = a0
    c = d0
    d = c0
else : 
    a = a0
    b = b0
    c = c0
    d = d0

right = max(c,d)
left = min(a,b)
middle = max(a,b)

for i in range(n-1) :
    if s[i] == '
        if i <= right - 2 and i >= left - 1 :
            print('No')
            break
else :
    if c < d :
        print('Yes')
    else :
        for i in range(n-2) :
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' : 
                if i + 1 == b - 1 :
                    print('Yes')
                    break
                if i <= d - 2 and i >= b - 1 :
                    print('Yes')
                    break
        else :
            print('No')

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


def f():
    if "
        return False

    if "
        return False

    if C < D:
        return True

    can_over = False
    prev_2 = ""
    prev_1 = ""
    for i in range(B - 1, D + 2):
        now = S[i]
        if prev_1 == prev_2 == now == ".":
            can_over = True

        prev_2, prev_1 = prev_1, now

    return can_over

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

Solution (Python):
def main():
    n,a,b,c,d = [int(x) for x in input().split()]
    S = input()
    
    a -= 1
    b -= 1
    c -= 1
    d -= 1

    if a>b:
        a,b,c,d=b,a,d,c
    
    
    while b<d:
        if 0<=b-1 and b+1<n and b!=c and S[b-1] == S[b] == S[b+1]=='.':
            break
        if b+1<n and S[b+1]=='.':
            b += 1
        elif b+2<n and S[b+2]=='.':
            b += 2
        else:
            break
    while a<c:
        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:
            a += 2
        else:
            print 'No'
            sys.exit()
    
    while b<d:
        if b+1<n and S[b+1]=='.':
            b += 1
        elif b+2<n and S[b+2]=='.':
            b += 2
        else:
            print 'No'
            sys.exit()
    if a!=c or b!=d:
        print 'No'
    else:
        print 'Yes'











py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')


import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'


def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'0' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'0' [0]:
        A.append(sign*numb)
    return A

if __name__== "__main__":
  main()

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


def can_pass(s):
    for i in range(len(s) - 1):
        if s[i] == '
            return False
    return True


def can_pass2(s):
    for i in range(len(s) - 2):
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
            return True
    return False


if B < A:
    A, B = B, A
    C, D = D, C

if C < D:
    if can_pass(S[A-1:C]) and can_pass(S[B-1:D]):
        print('Yes')
    else:
        print('No')
else:
    if can_pass2(S[B-2:D+1]):
        print('Yes')
    else:
        print('No')

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

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

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

if "
	
	ans = 'No'
else:
	if "
		
		ans = 'No'
	else:
		if c>d: 
			
			if "..." in s[b-1:d+2]:
				
				ans = 'Yes'
			else:
				
				
				ans = 'No'
		else:
			
			ans = 'Yes'

print(ans)

Solution (Python):
n,a,b,c,d = map(int,input().split())
s = input()
stone = False
space = False
cnt = 0
if c < d:
  for i in range(a,d-1):
    if s[i] == '
      print('No')
      exit()
    elif s[i] == '
      stone = True
    elif stone:
      stone = False
  print('Yes')
else:
  for i in range(a,c-1):
    if s[i] == '
      print('No')
      exit()
    elif s[i] == '
      stone = True
      cnt = 0
    elif s[i] == '.':
      stone = False
      if d >= i >= b-2:
        cnt += 1
      if cnt == 3:
        space = True
  if space == False:
    print('No')
    exit()
  print('Yes')

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

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

if __name__ == '__main__':
    main()

Solution (Python):
n,a,b,c,d = map(int,input().split())
S = input()
ans = 'Yes'

if d > c: 
    if S[b:d].count('
        ans = 'No'
    else:
        if S[a:c].count('
            ans = 'No'
else:
    if S[a:c].count('
         ans = 'No'
    else:
        if S[b-2:d+1].count('...') == 0:
            ans = 'No'

print(ans)

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

def move_b():
  i = B
  keep_next_to_lock = (S[i+1] == "
  while i != D:
    if S[i+1] == ".":
      i += 1
      keep_next_to_lock = keep_next_to_lock & (S[i+1] == "
    elif S[i+1] == "
      i += 2
    else:
      return False
  return True and not (keep_next_to_lock and D < C)

def check_a_b():
  for i in range(A, B-1):
    if S[i+1] == "
      return False
  return True

if move_b() and check_a_b():
  print('Yes')
else:
  print('No')

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

not_pass_array = []
can_change_array = []

for i in range(len(S) - 2):
    if S[i] == "
        not_pass_array.append(i)
    elif S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
        can_change_array.append(i + 1)
if S[-1] == "
    not_pass_array.append(len(S) - 2)


A = A - 1
B = B - 1
C = C - 1
D = D - 1
if C < D:
    for i in not_pass_array:
        if A >= i:
            continue
        if D <= i:
            print("Yes")
            exit()
        if (A < i and i < C) or (B < i and i < D):
            print("No")
            exit()
    else:
        print("Yes")
        exit()

else:
    for i in not_pass_array:
        if A >= i:
            continue
        if C <= i:
            break
        if (A < i and i < C) or (B < i and i < D):
            print("No")
            exit()
    for b_pos in can_change_array:
        if b_pos >= B and b_pos <= D:
            print("Yes")
            exit()
    print("No")

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

    if solve(n, a, b, c, d, s):
        print('Yes')
    else:
        print('No')

def solve(n, a, b, c, d, s):
    if d > c:
        return all(s[i:i+2] != '

    if not all(s[i:i+2] != '
        return False
    
    if not any(s[i:i+3] == '...' for i in range(b - 2, d - 1)):
        return False

    return True

main()

Solution (Python):
N,A,B,C,D = map(int,input().split())
a = input()
k = A
found = True
ffond = False
b = 0
c = 0
if C <D :
    while  found == True and k < D:
        if a[k] == "
            b += 1
        else:
            b = 0
        if b == 2:
            found = False
        k += 1
    if found == False:
        print("No")
    else:
        print("Yes")
else:
    while  found == True and k < C:
        if a[k] == "
            b += 1
            if k > B-3 and k <= D:
                c = 0
        else:
            b = 0
            if k > B-3 and k <=D:
                c +=1
        if b == 2:
            found = False
        if c == 3:
            ffond = True
        k += 1
    if found == False or ffond == False:
        print("No")
    else:
        print("Yes")

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = input()
flag2 = True
flag3 = False
if C < D:
    AS = S[A:C-1]
    BS = S[B:D-1]
    for i in range(len(S)-1):
        if BS[i:i+2] == '
            flag2 = False
    for i in range(len(S)-1):
        if AS[i:i+2] == '
            flag2 = False
    if flag2:
        print('Yes')
    else:
        print('No')
else:
    AS = S[A:C-1]
    BS = S[B:D-1]
    BD = S[B-2:D+1]
    
    for i in range(len(S)-2):
        if BD[i:i+3] == '...':
            flag3 = True
    for i in range(len(S)-1):
        if BS[i:i+2] == '
            flag2 = False
    for i in range(len(S)-1):
        if AS[i:i+2] == '
            flag2 = False
    if flag2 and flag3:
        print('Yes')
    else:
        print('No')

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

DS = False
TD = False
nd = 0
ns = 0
if A + 1 == B:
    nd = 1
for x in range(A+1, max(C, D)+1):
    s = S[x-1]
    if s == '.':
        if B - 1 <= x <= D + 1:
            nd = nd + 1
        ns = 0
    else:
        nd = 0
        ns = ns + 1
    if A <= x <= C or B <= x <= D:
        if ns >= 2:
            DS = True
    if B <= x <= D + 1:
        if nd >= 3:
            TD = True

if DS == True or (D < C and TD == False):
    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] = [int(i) for i in input().split()]
s = input()

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

Solution (Python):
N,A,B,C,D = (int(i) for i in input().split())
S = input()
S = list(S)

result = "Yes"
onon = True

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


print(result)

Solution (Python):
data = input().split()
s = input()
end_max = int(max(data[3:5]))
s = s[int(data[1])-1:end_max]

if '
    print('No')
else:
    if int(data[3]) < int(data[4]):
        print('Yes')
    else:
        s = s[int(data[2])-2:int(data[4])+1]
        if '...' in s:
            print('Yes')
        else:
            print('No')

Solution (Python):
import sys


scan = sys.stdin.readline


def main():
    n, a, b, c, d = map(int, scan().rstrip().split())
    stone = [c == "

    if (a - b)*(c - d) > 0:
        if a > b:
            front = a
            behind = b
            goal_front = c
            goal_behind = d
        else:
            front = b
            behind = a
            goal_front = d
            goal_behind = c

        for pos, goal in [(front, goal_front), (behind, goal_behind)]:
            while pos != goal:
                if stone[pos] and stone[pos + 1]:
                    print("No")
                    exit(0)
                elif stone[pos]:
                    pos += 2
                else:
                    pos += 1

        print("Yes")
        exit(0)

    else:
        if a > b:
            front = a
            behind = b
            goal_front = c
            goal_behind = d
        else:
            front = b
            behind = a
            goal_front = d
            goal_behind = c
        
        while behind != goal_behind:
            if stone[behind] and stone[behind + 1]:
                print("No")
                exit(0)
            elif stone[behind] and behind + 2 == front:
                if front == goal_front:
                    print("No")
                    exit(0)
                elif stone[front] and stone[front + 1]:
                    print("No")
                    exit(0)
                elif stone[front]:
                    front += 2
                else:
                    front += 1
                behind += 2
            elif behind + 1 == front and stone[behind + 1]:
                if front == goal_front:
                    print("No")
                    exit(0)
                elif stone[front] and stone[front + 1]:
                    print("No")
                    exit(0)
                elif stone[front]:
                    front += 2
                else:
                    front += 1
                behind += 1
            elif behind + 1 == front or stone[behind]:
                behind += 2
            else:
                behind += 1

        while front != goal_front:
            if stone[front] and stone[front + 1]:
                print("No")
                exit(0)
            elif stone[front]:
                front += 2
            else:
                front += 1
        
        print("Yes")


if __name__ == '__main__':
    main()

Solution (Python):
N,A,B,C,D = (int(i) for i in input().split())
S = input()
S = list(S)

result = "Yes"
onon = True

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


print(result)

Solution (Python):
n,a,b,c,d = map(int, input().split())
s = input()
ans = "Yes"
sharp = 0
dot = 0
for i in s[a-1:max(c,d)]:
    if i == ".":
        sharp = 0
    else:
        sharp += 1
        if sharp == 2:
            ans = "No"
            break
if c > d and ans == "Yes":
    ans = "No"
    for i in s[b-2:d+1]:
        if i == ".":
            dot += 1
            if dot == 3:
                ans = "Yes"
                break
        else:
            dot = 0
print(ans)

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

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