Problem: 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.

Submission attempts (in order):
N, A, B, C, D = [int(c) for c in input().split()]
S = input() + '##'

r = [[False]*(N+2) for _ in range(N+2)]

def move(x1, x2):
    if r[x1][x2]: return
    r[x1][x2] = True
    if S[x1]=='#' or S[x2]=='#' or x1==x2: return
    move(x1+1, x2)
    move(x1+2, x2)
    move(x1, x2+1)
    move(x1, x2+2)

move(A-1, B-1)
out = 'YES' if r[C-1][D-1] else 'NO'
print(out)


N, A, B, C, D = [int(c) for c in input().split()]
S = input() + '##'

r2 = set()
r1 = {B-1}

for i, c in enumerate(S):
    if c=='.' and (i-2 in r1 or i-1 in r1):
        r1 |= {i}
print(r1)

for x in range(A-1, C):
    if S[x]=='#' : r0 = set()
    else:
        r0=r1|r2
        r0.discard(x)
        for i, c in enumerate(S):
            if i!=x and c=='.' and (i-2 in r0 or i-1 in r0):
                r0 |= {i}
                
    r2=r1
    r1=r0

out = 'YES' if D-1 in r0 else 'NO'
print(out)


N, A, B, C, D = [int(c) for c in input().split()]
S = input() + '##'

r2 = set()
r1 = {B-1}

for i, c in enumerate(S):
    if c=='.' and (i-2 in r1 or i-1 in r1):
        r1 |= {i}

for x in range(A-1, C):
    if S[x]=='#' : r0 = set()
    else:
        r0=r1|r2
        r0.discard(x)
        if S[x-1]=='.' and (x-2 in r0 or x-3 in r0):
            r0 |= {x-1}
        if S[x-2]=='.' and (x-3 in r0 or x-4 in r0):
            r0 |= {x-2}
                
    r2=r1
    r1=r0

out = 'YES' if D-1 in r0 else 'NO'
print(out)


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]=='#' and S[x-2]=='#':
        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)

# ##..#..
# #######
# S##.#..
# .#.##..
# #######
# .#..##.
# .#..#.#


 # #.S#.#...#.#...
 # .U.#.#...#.#...
 # ..##.#...#.#...
 # ###############
 # ...###...#.#...
 # ###############
 # ...#.##..#.#...
 # ...#.#.#.#.#...
 # ...#.#..##.#...
 # ###############
 # ...#.#...###...
 # ###############
 # ...#.#...#.##..
 # ...#.#...#.#.#.
 # ...#.#...#.#G.#




Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted