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



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

    if S[A-1:C].count('
        return 0

    if S[B-1:D].count('
        return 0

    if D < C and not(S[B-2:D+1].count('...')):
        return 0

    return 1

print(['No','Yes'][main()])

Solution (Python):
n, a, b, c, d = map(int, input().split(' '))
s = input()
def rock(a,b):
    tmp = 0
    result = 1
    for i in s[a:b]:
        if tmp==2:
            result = 0
            break
        if i =='
            tmp +=1
        else:
            tmp=0
    return result
def main():
    result =0
    if c<d:
        result = min(rock(a,c-1),rock(b,d-1))
    else:
        result = min(rock(a,c-1),rock(b,d-1))
        if result ==1:
            result = 0
            for i in range(b-1,d):
                if s[i-1]=='.' and s[i]=='.' and s[i+1]=='.':
                    result = 1
    if result ==0:
        print('No')
    else:
        print('Yes')

main()

Solution (Python):


import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, A, B, C, D = i2nn()
    S = i2s()
    if '
        if C < D:
            print('Yes')
        elif  '...' in S[B-2:D+1]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
    return

main()

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

if C<D:
    ans = 'Yes' 
else:
    if s[B-2:D+1].count('...')>0:
        ans = 'Yes'





    else:
        ans = 'No'
if s[A:C-1].count('
    ans = 'No'
print(ans)

Solution (Python):
N, A, B, C, D = map(int, input().split(' '))
S = input()
blocks = [i+1 for i, s in enumerate([s for s in S]) if s == '

if '
    print('No')
elif C < D:
    if S[C-1] == '.' and S[D-1] == '.':
        print('Yes')
    else:
        print('No')
else:
    if '...' in S[max(0, B - 2):D+1]:
        print('Yes')
    else:
        print('No')

Solution (Python):
n,a,b,c,d=map(int,input().split(" "))
s=input()
pathA=s[a-1:c-1]
pathB=s[b-1:d-1]
isBlockCont = pathA.count("
if c < d :
    if isBlockCont:
        print("Yes")
    else:
        print("No")
else:
    if isBlockCont and s[b-2:d+1].count("...") > 0:
        print("Yes")
    else:
        print("No")

Solution (Python):

def main():
    num, start_a, start_b, goal_a, goal_b = map(int, input().split())
    data = input()
    data_a = data[start_a - 1 : goal_a]
    data_b = data[start_b - 1 : goal_b]

    if '
        flg = 0
    elif start_a < start_b and goal_a < goal_b:
        flg = 1
    elif start_b < start_a and goal_b < goal_a:
        flg =  1
    elif start_a < start_b and goal_a > goal_b:
        data_now = data[start_b - 2 : goal_b + 1]
        if '...' in data_now:
            flg = 1
        else:
            flg = 0
    elif start_b < start_a and goal_b > goal_a:
        data_now = data[start_a - 2 : goal_a + 1]
        if '...' in data_now:
            flg = 1
        else:
            flg = 0

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

if __name__ == '__main__':
    main()

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

Solution (Python):
N,A,B,C,D=map(int,input().split())
s='$'+input()
 
if C<B:
    if not '
        if not '
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    if C<D:
        if '
            print('No')
        else:
            print('Yes')
    else:
        if '
            print('No')
        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()
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())
A -= 1
B -= 1
C -= 1
D -= 1
S = list(input())
 
ans = 'Yes'
if C < D:
    for i in range(A , C):
        if S[i] == '
            ans = 'No'
            break
    for i in range(B, D):
        if S[i] == '
            ans = 'No'
            break
else:
    for i in range(A, C):
        if S[i] == '
            ans = 'No'
            break
    for i in range(B, D + 1):
        if S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
            break
    else:
        ans = 'No'
            
print(ans)

Solution (Python):
N, A, B, C, D = map(int, input().split())
S = input()
Sac = S[A-1:C]
Sbd = S[B-1:D]
if "
    print("No")
elif C < D:
    print("Yes")
elif "..." in Sbd:
    print("Yes")
else:
    s1 = S[A-1:B-1] + "
    s2 = S[A-1:D-1] + "
    if "
        print("Yes")
    else:
        print("No")

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








curStoneLen=0



for b in range(B-1,D):
	if S[b] == ".":
		curStoneLen = 0
	else:
		curStoneLen += 1

	if 2 == curStoneLen:
		print("No")
		exit(0)



curStoneLen=0

for a in range(A-1,C):
	if S[a] == ".":
		curStoneLen = 0
	else:
		curStoneLen += 1

	if 2 == curStoneLen:
		print("No")
		exit(0)



if D < C:
	
	maxAtoDSeqSpaceLen=0
	curSeqSpaceLen=0
	for BtoD in range(B-2,D+1):
		if S[BtoD] == ".":
			curSeqSpaceLen += 1
		else:
			curSeqSpaceLen = 0

		maxAtoDSeqSpaceLen=max(maxAtoDSeqSpaceLen,curSeqSpaceLen)

	if maxAtoDSeqSpaceLen < 3:
		
		print("No")
		exit(0)	
else:
	
	pass


print("Yes")

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

temp=str(input())
maxim=max(a,b)
minim=min(a,b)
if temp[maxim:d+2].count("...")!=0 or temp[maxim+1]==temp[maxim+2]=="." or temp[maxim+1]==temp[maxim-1]==".":
    flag=1
else:
    flag=0
    
s=list(temp)
s[a]="A"
s[b]="B"
s[c]="C"
s[d]="D"

mac=max(c,d)
ans=1

for i in range(minim,mac):
    if s[i]==s[i+1]=="
        ans=0

if c<d and ans==1:
    ans=1
elif c>d and ans==1:
    if flag==1:
        ans=1
    elif s[d-1]=="
        ans=0
    else:
        ans=1
                
if ans==1:
    print("Yes")
else:
    print("No")

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
n,a,b,c,d = map(int,input().split())
s = input()
a -= 1
b -= 1
c -= 1
d -= 1
truth = [[0 for i in range(n)],[0 for j in range(n)]]

def solve(now,dest):
    for i in  range(now,dest):
        if s[i] == '
            return False
    return True
if c < d:
    if solve(a,c) and solve(b,d):
        print('Yes')
    else:
        print('No')

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

Solution (Python):
n,a,b,c,d=map(int,input().split())
s=input()
if s[b:d].count('
    print('No')
    exit()

if c>d:
    flg=True
    if s[b-2:d+1].count('...')>0:
        flg=False
    if flg:
        print('No')
        exit()

if s[a:c].count('
    print('No')
    exit()

print('Yes')

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

if '
  print('No')
else:
  if C < D:
  	print('Yes')
  else:
    if '...' in S[B-2:D+1]:
      print('Yes')
    else:
      if len(S[A-1:right])<=6:
        if S[A-1:right].count('
          print('No')
        else:
          print('Yes')
      else:
        print('No')

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

reachable = {B-1}
unreachable = set()
for i, c in enumerate(S):
    if c=='.' and (i-2 in reachable or i-1 in reachable):
        reachable.add(i)


for x in range(A, C):
    if x>=2 and S[x-1]=='
        print('No')
        exit()

    unreachable.add(x)    
    if S[x-1]=='.' and ((x-2 in reachable and x-2 not in unreachable) or
                        (x-3 in reachable and x-3 not in unreachable) or
                        (x-1 in reachable and S[x-2]=='.' and S[x]=='.')
    ):
        unreachable.discard(x-1)
    if S[x-2]=='.' and ((x-3 in reachable and x-3 not in unreachable) or
                        (x-4 in reachable and x-4 not in unreachable)):
        unreachable.discard(x-2)
        
out = 'Yes' if D-1 in reachable and D-1 not in unreachable else 'No'
print(out)

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(N: int, A: int, B: int, C: int, D: int, S: str): 
    if(S[A-1] == '
        print(NO)
        sys.exit()

    if(S[A-1:C].count('
        if(D < C):
            sf = (S[A-1:D+1].count('...'))
            if(sf == 0):
                print(NO)
            
            elif(sf == 1):
                tS = list(S)
                tS[B-1] = 'b'
                tS = ''.join(tS)
                if(tS[A-1:D+1].count('..b
                    print(NO)
                else:
                    print(YES)
            
            elif(sf >= 2):
                
                tS = list(S)
                tS[B-1] = 'b'
                tS = ''.join(tS)
                ptS = tS.rfind('..b
                if(ptS == -1):
                    print(YES)
                else:
                    if(tS[ptS+3:D+1].count('...') == 0):
                        
                        print(NO)
                    else:
                        
                        print(YES)
        else: 
            print(YES)  
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = int(next(tokens))  
    B = int(next(tokens))  
    C = int(next(tokens))  
    D = int(next(tokens))  
    S = next(tokens)  
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin

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

    sunuke = S[A-1:C]
    funuke = S[B-1:D]
    if '
        print('No')
        return

    ans = 'No'
    if C < D:
        ans = 'Yes'
    else:
        if '...' in funuke:
            ans = 'Yes'
        else:
            sunuke1 = S[A-1:B-1] + '
            sunuke2 = S[A-1:D-1] + '
            if '
                ans = 'Yes'
    print(ans)

input = lambda: stdin.readline()
main()

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

if c < d :
    if (S[b:d+1].count("
        ans = "Yes"
    else :
        ans = "No"
else :
    if (S[b:d+1].count("
        flg1 = 1
    else :
        flg1 = 0
    

    if S[a:d+1].count("...") >= 1 :
        flg2 = 1
    else :
        flg2 = 0
        
    for i in range(b,d+1) :
        if (S[i-1]+S[i]+S[i+1] == "...") :
            flg3 = 1
            break
    else :
        flg3 = 0
    
    
    if flg1*flg3 :
        ans = "Yes"
    else :
        ans = "No"
print(ans)

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

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

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

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

    s.insert(0, '.')

    
    r = s[a:c+1]
    sr = "".join(r)
    if '
        print("No")
        return
    t = s[b:d+1]
    st = "".join(t)
    if '
        print("No")
        return
    
    if (c > d):
        
        u = s[b-1:d+2]
        su = "".join(u)
        if not '...' in su:
            print("No")
            return

    print("Yes")

test()

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def SI(): return input()


def main():
    _, A, B, C, D = LI()
    S = SI()

    M = [0 for _ in range(A)]
    a = 0
    for s in S[A:max(C, D)]:
        if s == ".":
            a = 0
            M.append(0)
        else:
            if a == 1:
                print("No")
                return
            a = 1
            M.append(1)
    if D > C:
        print("Yes")
        return
    if M[B-2] == 0 and M[B] == 0:
        print("Yes")
        return
    if M[D-2] == 0 and M[D] == 0:
        print("Yes")
        return
    a = 0
    for m in range(B-1, D):
        if M[m-1]+M[m]+M[m+1] == 0:
            print("Yes")
            return
    print("No")


main()

Solution (Python):
number_of_masu, firstsunuke, firstfunuke, lastsunuke, lastfunuke = map(int, input().split())
s = str(input())
tobenaiflag = 0
nukaseruflag = 0
lastfunuke -= 1
lastsunuke -= 1
firstsunuke -= 1
firstfunuke -= 1
for i in range(firstsunuke, lastsunuke-1):
    if s[i] == '
        tobenaiflag += 1
        break
for k in range(firstfunuke, lastfunuke-1):
    if s[k] == '
        tobenaiflag += 1
        break
if lastfunuke < lastsunuke:
    for j in range(firstfunuke, lastfunuke+1):
        if s[j] == '.' and s[j-1] == '.' and s[j+1] == '.':
            nukaseruflag += 1
            break
else:
    nukaseruflag += 1
if number_of_masu == 4:
    print('Yes')
elif tobenaiflag == 0 and nukaseruflag == 1:
    print('Yes')
else:
    print('No')

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

rock = "
S = list()
three_empty = []
two_rocks = []
rock_cnt, empty_cnt = 0, 0


left, right = min(A, B), max(C, D)
for i, s in enumerate(input().strip()[left-1:right], start=left):
  is_rock = s == rock
  if is_rock:
    if empty_cnt >= 3:
      three_empty.append((i - 1, empty_cnt))
    rock_cnt += 1
    empty_cnt = 0
  else:
    if rock_cnt >= 2:
      two_rocks.append(i - 1)
    rock_cnt = 0
    empty_cnt += 1
if rock_cnt >= 2:
  two_rocks.append(i)
if empty_cnt >= 3:
  three_empty.append((i, empty_cnt))

flag = True
left = A if A < B else B
right = B if A > B else A
left_rock = left
right_rock = 200001


for i in two_rocks:
  
  if A > i > C or B > i > D or A < i < C or B < i < D:
    flag = False
    break
  
  if right_rock == 200001 and right < i:
    right_rock = i

if not flag:
  
  print("No")
elif (A > B and C > D) or (A < B and C < D):
  
  print("Yes")
elif not three_empty:
  
  print("No")
else:
  
  flag = False
  left = max(A, B)
  right = min(C, D)
  for i, e_cnt in three_empty:
    if left < i - e_cnt + 1 < right or (left < i < right):
      flag = True
      break
  if flag:
    print("Yes")
  else:
    print("No")

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    n, a, b, c, d = LI_()
    s = S()
    flg = False
    for i in range(a, c-1):
        if s[i] == "
            print("No")
            return
    for i in range(b, d-1):
        if s[i] == "
            print("No")
            return
    if c > d:
        for i in range(b,d+1):
            if s[i] == "." and s[i + 1] == "." and s[i - 1] == ".":
                flg = True
                break
        if not flg:
            print("No")
            return
    print("Yes")
    return


def B():
    s = S()
    i = len(s) - 1
    state = 0
    ans = 0
    bc = 2
    while i >= 0:
        if state == 0:
            if s[i] == "C":
                state += 1
        elif state == 1:
            if s[i] == "B":
                state += 1
            else:
                state = 0
        elif state == 2:
            if s[i] == "A":
                ans += 1
            elif s[i] == "B":
                state = 0
            else:
                state += 1
        elif state == 3:
            if s[i] == "B":
                state += 1
            elif s[i] == "C":
                state = 1
            else:
                state = 0
        else:
            if s[i] == "A":
                ans += bc
            elif s[i] == "B":
                state = 0
                bc = 2
            else:
                bc += 1
                state = 3
        
        i -= 1
    print(ans)

    return


def C():
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    A()

Solution (Python):
def inverse(a):
    return pow(a, mod - 2, mod)

def main():
    n,a,b,c,d = map(int, input().split())
    a -=1
    b -=1
    c -=1
    d -=1

    s = input()

    a_r = a
    cnt = 0
    for i in range(a, n):
        if s[i] == '
            cnt += 1
        else:
            cnt = 0
        a_r = i
        if cnt == 2:
            a_r = i
            break

    b_r = b
    cnt = 0
    for i in range(b, n):
        if s[i] == '
            cnt += 1
        else:
            cnt = 0
        b_r = i
        if cnt == 2:
            b_r = i
            break
    if a_r < c or b_r < d:
        print('No')
        return
    if c < d:
        print('Yes')
        return
    cnt = 0
    for i in range(b, d+1):
        if s[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt > 2:
            print('Yes')
            return

    if s[b-1] == '.' and s[b+1] == '.':
        print('Yes')
        return
    if s[d-1] == '.' and s[d+1] == '.':
        print('Yes')
        return
    print('No')


main()

Solution (Python):
def passable(road):
    n=len(road)
    for i in range(n-1):
        block=road[i:i+2]
        if block=='
            return False
    return True

def safe_place(road):
    n=len(road)
    for i in range(n-2):
        block=road[i:i+3]
        if block=='...':
            return i+1
    return -1

def passEach(A,B,C,D,road):
    if passable(road[A:C+1]) and passable(road[B:D+1]):
        return True
    else:
        return False

def judge(A,B,C,D,S):
    if C<D:
        return passEach(A,B,C,D,S)
    else:
        S2=S[:B]+'
        if passable(S2[A:C+1]) and passable(S[B:D+1]):
            return True
        S3=S[:D]+'
        if passable(S3[A:C+1]) and passable(S[B:D+1]):
            return True
        safePlace=safe_place(S[B:D+1])
        if safePlace!=-1 and passEach(A,B,C,safePlace+B,S) and passEach(A,safePlace+B,C,D,S):
            return True
    return False

N,A,B,C,D=map(int,input().split())
S=input()
if judge(A-1,B-1,C-1,D-1,S):
    print('Yes')
else:
    print('No')

Solution (Python):

"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    n, a, b, c, d = read_int_array()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = read() + b'
    if s[d] == '
        print('No')
    else:
        if c < d:
            while b < d:
                if b + 1 == d:
                    b += 1
                elif s[b + 2] == '.':
                    b += 2
                elif s[b + 1] == '.':
                    b += 1
                else:
                    print('No')
                    return
            while a < c:
                if a + 1 == c:
                    a += 1
                elif s[a + 2] == '.':
                    a += 2
                elif s[a + 1] == '.':
                    a += 1
                else:
                    print('No')
                    return
            print("Yes")
        else:
            while a < c:
                if a + 1 == c:
                    if a + 1 == b:
                        if b + 1 == d:
                            b += 1
                        elif s[b + 2] == '.':
                            b += 2
                        elif s[b + 1] == '.':
                            b += 1
                        else:
                            print('No')
                            return
                    a += 1
                elif s[a + 1] == '.' and b != a + 1:
                    a += 1
                elif s[a + 2] == '.' and b != a + 2:
                    a += 2
                elif a + 1 == b:
                    if s[a + 2] == '.':
                        a += 2
                    elif s[a + 3] == '.':
                        b += 2
                    else:
                        print("No")
                        return
                elif a + 2 == b:
                    if s[a + 3] == '.':
                        b += 1
                        a += 2
                    elif s[a + 4] == '.':
                        b += 2
                        a += 2
                    else:
                        print("No")
                        return
                else:
                    print('No')
                    return
            if b > d:
                print("No")
                return
            while b < d:
                if b + 1 == d:
                    b += 1
                elif s[b + 2] == '.':
                    b += 2
                elif s[b + 1] == '.':
                    b += 1
                else:
                    print('No')
                    return
            print("Yes")




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

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


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")


def read():
    return input()


def read_array(sep=None, maxsplit=-1):
    return read().split(sep, maxsplit)


def read_int():
    return int(read())


def read_int_array(sep=None, maxsplit=-1):
    return [int(a) for a in read_array(sep, maxsplit)]




if __name__ == "__main__":
    main()

Solution (Python):
n,a,b,c,d = [int(i) for i in input().split()]
s = input()
flag1 = False
block = 0
for i in range(b, len(s)):
    if block == 2:
        flag1 = False
        break
    elif i == d-1:
        flag1 = True
        break
    elif s[i] == ".":
        block = 0
    elif s[i] == "
        block += 1
if flag1:
    s2 = s[:d-1]+'
    flag1 = False
    block = 0
    for i in range(a, len(s)):
        if block == 2:
            flag1 = False
            break
        elif i == c-1:
            flag1 = True
            break
        elif s2[i] == ".":
            block = 0
        elif s2[i] == "
            block += 1
flag2 = False
flag3 = False
temp = 0
block = 0
for i in range(b-2,c-2):
    if temp == 3:
        flag2 = True
        temp = i-1
        break
    elif s[i] == "
        temp = 0
    elif s[i] == ".":
        temp += 1
if flag2:
    flag3 = False
    block = 0
    s1 = s[:temp-1]+'
    for i in range(a, len(s)):
        if block == 2:
            flag3 = False
            break
        elif i == c-1:
            flag3 = True
            break
        elif s1[i] == ".":
            block = 0
        elif s1[i] == "
            block += 1
    if flag3:
        s3 = s1[:c - 1] + '
        flag3 = False
        block = 0
        for i in range(temp, len(s)):
            if block == 2:
                flag3 = False
                break
            elif i == d-1:
                flag3 = True
                break
            elif s3[i] == ".":
                block = 0
            elif s3[i] == "
                block += 1
if flag1 or flag3:
    print("Yes")
else:
    print("No")

Solution (Python):

def solve():
    N, A, B, C, D = map(int, input().split()) 
    S = input()
    if "
        return "No"
    if C > D and not "..." in S[B-2:D+1]:
        return "No"

    return 'Yes'

if __name__ == '__main__':
    print(solve())

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
input = sys.stdin.readline
 










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

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

	if C < D:
		S = S[A:D+1]
	else:
		S = S[A:C+1]

	iwa = []
	kara = []
	nige = []
	for i, val in enumerate(S):
		if val == "
			if len(iwa) >= 1 and iwa[-1] == i-1:
				print("No")
				sys.exit()
			iwa.append(i)
		else:
			
			
			
			
			if len(kara) > 1 and kara[-1] == i-1 and kara[-2] == i-2:
				nige.append(i-2)
			kara.append(i)
	
	
	'''
	for i in range(A+1, C):
		if i in iwa:
			tmp = iwa.index(i)
			if len(iwa)-1 > tmp and iwa[tmp+1] == i+1:
				print("No")
				sys.exit()

	for i in range(B+1, D):
		if i in iwa:
			tmp = iwa.index(i)
			if len(iwa)-1 > tmp and iwa[tmp+1] == i+1:
				print("No")
				sys.exit()
	'''
	if A < B and B < C and C < D:
		print("Yes")
		sys.exit()
	elif A < C and C < B and B < D:
		print("Yes")
		sys.exit()
	else:
		for i in nige:
			if B-1 <= i and i+2 <= D+1:
				print("Yes")
				sys.exit()
	'''
	elif A < B and B < D and D < C:
		for i in range(A+1, C):
			if i in kara:
				tmp = kara.index(i)
				if C >= i+2 and len(kara)-2 > tmp :
					if (kara[tmp+1] == i+1) and (kara[tmp+2] == i+2):
						print("Yes")
						sys.exit()
		print("No")
		sys.exit()
	'''
	print("No")
	

if __name__ == "__main__":
	main()

Solution (Python):
n,a,b,c,d=map(int,input().split())
s=str(input())
arr=[]
for i in range(len(s)):
	if(s[i]=='
		arr.append(-1)
	elif(s[i]=='.'):
		arr.append(0)

a-=1
b-=1
c-=1
d-=1
flag=0
arr[a]=1
arr[b]=2
pos1=a
pos2=b
if(c<d):
	while(pos2<d):
		if(pos2+1<n and arr[pos2+1]==0):
			pos2+=1
			arr[pos2-1]=0
			arr[pos2]=2
		else:
			if(pos2+2<n and arr[pos2+2]==0):
				pos2+=2
				arr[pos2-2]=0
				arr[pos2]=2
			else:
				flag=1
				break
		
	while(pos1<c):
		if(pos1+1<n and arr[pos1+1]==0):
			arr[pos1]=0
			arr[pos1+1]=1
			pos1+=1
		else:
			if(pos1+2<n and arr[pos1+2]==0):
				pos1+=2
				arr[pos1-2]=0
				arr[pos1]=1
			else:
				flag=1
				break
else:
	
	
	while(pos2>pos1):
		if(pos1+1<n and arr[pos1+1]==0):
			arr[pos1]=0
			arr[pos1+1]=1
			pos1+=1
		else:
			if(pos1+2<n and arr[pos1+2]==0):
				pos1+=2
				arr[pos1-2]=0
				arr[pos1]=1
			else:
				if(pos2<d):
					if(pos2+1<n and arr[pos2+1]==0):
						pos2+=1
						arr[pos2-1]=0
						arr[pos2]=2
					else:
						if(pos2+2<n and arr[pos2+2]==0):
							pos2+=2
							arr[pos2-2]=0
							arr[pos2]=2
						else:
							flag=1
							break
				else:
					flag=1
					break
		
		
	if(flag==0):
		while(pos1<c):
			if(pos1+1<n and arr[pos1+1]==0):
				arr[pos1]=0
				arr[pos1+1]=1
				pos1+=1
			else:
				if(pos1+2<n and arr[pos1+2]==0):
					pos1+=2
					arr[pos1-2]=0
					arr[pos1]=1
				else:
					flag=1
					break
		while(pos2<d):
			if(pos2+1<n and arr[pos2+1]==0):
				pos2+=1
				arr[pos2-1]=0
				arr[pos2]=2
			else:
				if(pos2+2<n and arr[pos2+2]==0):
					pos2+=2
					arr[pos2-2]=0
					arr[pos2]=2
				else:
					flag=1
					break

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