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

N, A, B, C, D = list(map(int, input().split()))

S = input()


for i in range(A,max(C,D)):
    if S[i:i+2]  == '##':
        print('NO')
        sys.exit()


p = 0
if A < B and C > D:
    p = 1

if C > D:
    for i in range(B,min(C,D)):
        if S[i:i+3] == '...':
            print('YES')
            sys.exit()

print('NO')

import sys

N, A, B, C, D = list(map(int, input().split()))

S = input()


for i in range(max(C,D)):
    if S[i:i+2]  == '##':
        print('NO')
        sys.exit()


p = 0
if A < B and C > D:
    p = 1

if A > B and C < D:
    p = 1

if p == 1:
    for i in range(max(C,D)):
        if S[i:i+3] == '...':
            print('YES')
            sys.exit()

print('NO')

import sys

N, A, B, C, D = list(map(int, input().split()))

S = input()


for i in range(A,max(C,D)):
    if S[i:i+2]  == '##':
        print('No')
        sys.exit()


if C > D:
    for i in range(B,C):
        if S[i:i+3] == '...':
            print('Yes')
            sys.exit()
    else:
        print('No')

import sys

N, A, B, C, D = list(map(int, input().split()))

S = input()


for i in range(max(C,D)):
    if S[i:i+2]  == '##':
        print('NO')
        sys.exit()


p = 0
if A < B and C > D:
    p = 1

if C > D:
    for i in range(B,min(C,D)):
        if S[i:i+3] == '...':
            print('YES')
            sys.exit()

print('NO')

import sys

N, A, B, C, D = list(map(int, input().split()))

S = input()


for i in range(max(C,D)):
    if S[i:i+2]  == '##':
        print('NO')
        sys.exit()


p = 0
if A < B and C > D:
    p = 1

if C > D:
    for i in range(min(C,D)):
        if S[i:i+3] == '...':
            print('YES')
            sys.exit()

print('NO')

import sys

readline = sys.stdin.buffer.readline


def main():
    N, A, B, C, D = map(int, readline().split())
    S = readline().decode('UTF-8')
    A -= 1
    B -= 1
    C -= 1
    D -= 1

    if C < D:
        s = A
        g = D
        for i in range(s, g):
            if S[i:i+2] == "##":
                print('No')
                sys.exit()
        else:
            print('Yes')

    else:
        s = A
        g = C
        for i in range(s, g):
            if S[i:i+2] == "##":
                print('No')
                sys.exit()

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


main()


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted