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



Sample input:
7 1 3 6 7
.#..#..


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = ['S'] + list(input())

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = ['S'] + list(input())

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = ['S'] + list(input())

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = ['S'] + list(input())

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = ['S'] + list(input())

if c < d:
    # 岩が連続マスに置かれているとき
    for i in range(1, d):
        if s[i] == '#' and s[i-1] == '#':
            print('No')
            exit()
    # 岩が連続マスに置かれていないとき
    print('Yes')
else:
    # 岩が連続マスに置かれているとき
    for i in range(1, c):
        if s[i] == '#' and s[i-1] == '#':
            print('No')
            exit()
    # 岩が連続マスに置かれていないとき
    # dマスの左右が岩のとき
    if s[d-1] == '#' or s[d+1] == '#':
        # 連続3マスの空きがあるとき
        for i in range(b, d):
            if s[i - 2] == '.' and s[i - 1] == '.' and s[i] == '.':
                print('Yes')
                exit()
        # 連続3マスの空きがないとき
        print('No')
    else:
        # 連続3マスの空きがあるためYes
        print('Yes')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(input())
a -= 1
b -= 1
c -= 1
d -= 1
jump = True
if d < c:
    cnt = 0
    for i in range(b-1,d+1):
        if s[i] == '.':
            cnt += 1
        if cnt == 3:
            break
        if s[i] == '#':
            cnt = 0
    else:
        jump = False
cnt = 0
for i in range(a,c):
    if s[i] == '#':
        cnt += 1
    if s[i] == '.':
        cnt = 0
    if cnt == 2:
        jump = False
        break
for i in range(b,d):
    if s[i] == '#':
        cnt += 1
    if s[i] == '.':
        cnt = 0
    if cnt == 2:
        jump = False
        break
if jump:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(input())
a -= 1
b -= 1
c -= 1
d -= 1
jump = True
if d < c:
    cnt = 0
    for i in range(b-1,d+1):
        if s[i] == '.':
            cnt += 1
        if cnt == 3:
            break
        if s[i] == '#':
            cnt = 0
    else:
        jump = False
cnt = 0
for i in range(a,max(c,d)):
    if s[i] == '#':
        cnt += 1
    if s[i] == '.':
        cnt = 0
    if cnt == 2:
        jump = False
        break
if jump:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, A, B, C, D = [int(x) for x in input().split()]
    S = input().strip()

    def rock_check(start, end):
        for a, b in zip(S[start:end], S[start + 1:end]):
            if a == b == "#":
                return False
        else:
            return True

    def three_space_check(start, end):
        start -= 1
        for a, b, c in zip(S[start:end], S[start + 1:end], S[start + 2:end]):
            if a == b == c == ".":
                return True
        else:
            return False


    bfirst = False
    if C < D:
        bfirst = True

    if bfirst:
        if A > B:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(A, C):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")
    else:
        if B > A:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(B, D):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, A, B, C, D = [int(x) for x in input().split()]
    S = input().strip()

    def rock_check(start, end):
        for a, b in zip(S[start:end], S[start + 1:end]):
            if a == b == "#":
                return False
        else:
            return True

    def three_space_check(start, end):
        start -= 1
        end += 1
        for a, b, c in zip(S[start:end], S[start + 1:end], S[start + 2:end]):
            if a == b == c == ".":
                return True
        else:
            return False


    bfirst = False
    if C < D:
        bfirst = True

    if bfirst:
        if A > B:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(A, C):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")
    else:
        if B > A:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(B, D):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, A, B, C, D = [int(x) for x in input().split()]
    S = input().strip()

    def rock_check(start, end):
        for a, b in zip(S[start:end], S[start + 1:end]):
            if a == b == "#":
                return False
        else:
            return True

    def three_space_check(start, end):
        end += 1
        for a, b, c in zip(S[start:end], S[start + 1:end], S[start + 2:end]):
            if a == b == c == ".":
                return True
        else:
            return False


    bfirst = False
    if C < D:
        bfirst = True

    if bfirst:
        if A > B:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(A, C):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")
    else:
        if B > A:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(B, D):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, A, B, C, D = [int(x) for x in input().split()]
    S = input().strip()

    def rock_check(start, end):
        for a, b in zip(S[start:end ], S[start + 1:end]):
            if a == b == "#":
                return False
        else:
            return True

    def three_space_check(start, end):
        end += 1
        for a, b, c in zip(S[start:end], S[start + 1:end], S[start + 2:end]):
            if a == b == c == ".":
                return True
        else:
            return False


    bfirst = False
    if C < D:
        bfirst = True

    if bfirst:
        if A > B:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(A, D):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")
    else:
        if B > A:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(B, C):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, A, B, C, D = [int(x) for x in input().split()]
    S = input().strip()

    def rock_check(start, end):
        for a, b in zip(S[start:end ], S[start + 1:end]):
            if a == b == "#":
                return False
        else:
            return True

    def three_space_check(start, end):
        start -= 1
        for a, b, c in zip(S[start:end], S[start + 1:end], S[start + 2:end]):
            if a == b == c == ".":
                return True
        else:
            return False


    bfirst = False
    if C < D:
        bfirst = True

    if bfirst:
        if A > B:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(A, D):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")
    else:
        if B > A:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(B, C):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, A, B, C, D = [int(x) for x in input().split()]
    S = input().strip()

    def rock_check(start, end):
        for a, b in zip(S[start:end ], S[start + 1:end]):
            if a == b == "#":
                return False
        else:
            return True

    def three_space_check(start, end):
        start += 1
        for a, b, c in zip(S[start:end], S[start + 1:end], S[start + 2:end]):
            if a == b == c == ".":
                return True
        else:
            return False


    bfirst = False
    if C < D:
        bfirst = True

    if bfirst:
        if A > B:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(A, D):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")
    else:
        if B > A:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(B, C):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, A, B, C, D = [int(x) for x in input().split()]
    S = input().strip()

    def rock_check(start, end):
        for a, b in zip(S[start:end ], S[start + 1:end]):
            if a == b == "#":
                return False
        else:
            return True

    def three_space_check(start, end):
        for a, b, c in zip(S[start:end], S[start + 1:end], S[start + 2:end]):
            if a == b == c == ".":
                return True
        else:
            return False


    bfirst = False
    if C < D:
        bfirst = True

    if bfirst:
        if A > B:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(A, D):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")
    else:
        if B > A:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(B, C):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, A, B, C, D = [int(x) for x in input().split()]
    S = input().strip()

    def rock_check(start, end):
        end -= 1
        for a, b in zip(S[start:end ], S[start + 1:end]):
            if a == b == "#":
                return False
        else:
            return True

    def three_space_check(start, end):
        end -= 1
        for a, b, c in zip(S[start:end], S[start + 1:end], S[start + 2:end]):
            if a == b == c == ".":
                return True
        else:
            return False

    bfirst = False
    if C < D:
        bfirst = True

    if bfirst:
        if A > B:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(B, D):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")
    else:
        if B > A:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(A, C):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, A, B, C, D = [int(x) for x in input().split()]
    S = input().strip()

    def rock_check(start, end):
        for a, b in zip(S[start:end], S[start + 1:end]):
            if a == b == "#":
                return False
        else:
            return True

    def three_space_check(start, end):
        for a, b, c in zip(S[start:end], S[start + 1:end], S[start + 2:end]):
            if a == b == c == ".":
                return True
        else:
            return False

    bfirst = False
    if C < D:
        bfirst = True

    if bfirst:
        if A > B:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(B, D):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")
    else:
        if B > A:
            if rock_check(B, D) and rock_check(A, C) and three_space_check(A, C):
                print("Yes")
            else:
                print("No")
        else:
            if rock_check(B, D) and rock_check(A, C):
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    length, snuke_start, hnuke_start, snuke_goal, hnuke_goal = map(lambda x: int(x) - 1, input().split())
    grid = input()
    is_rock_continuing = False
    is_space_continuing = False
    if "##" in grid[min(snuke_start, hnuke_goal):max(snuke_goal, hnuke_goal) + 1]:
        is_rock_continuing = True
    if "..." in grid[hnuke_start:hnuke_goal + 1]:
        is_space_continuing = True
    if snuke_goal < hnuke_goal and not is_rock_continuing:
        print("Yes")
    elif hnuke_goal < snuke_goal and not is_rock_continuing and is_space_continuing:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    length, snuke_start, hnuke_start, snuke_goal, hnuke_goal = map(lambda x: int(x) - 1, input().split())
    grid = input()
    is_rock_continuing = False
    is_space_continuing = False
    if "##" in grid:
        is_rock_continuing = True
    if "..." in grid[hnuke_start:hnuke_goal + 1]:
        is_space_continuing = True
    if snuke_goal < hnuke_goal and not is_rock_continuing:
        print("Yes")
    elif hnuke_goal < snuke_goal and not is_rock_continuing and is_space_continuing:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    length, snuke_start, hnuke_start, snuke_goal, hnuke_goal = map(lambda x: int(x) - 1, input().split())
    grid = list(input())
    is_rock_continuing = False
    count = 0
    for i in range(length):
        if grid[i:i + 2] == ["#", "#"]:
            is_rock_continuing = True
            break
    for i in range(hnuke_start, hnuke_goal - 2):
        if grid[i:i + 3] == [".", ".", "."]:
            count += 1
    if snuke_goal < hnuke_goal and not is_rock_continuing:
        print("Yes")
    elif hnuke_goal < snuke_goal and not is_rock_continuing and count:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    length, snuke_start, hnuke_start, snuke_goal, hnuke_goal = map(lambda x: int(x) - 1, input().split())
    grid = list(input())
    is_rock_continuing = False
    count = 0
    for i in range(length):
        if grid[i:i + 2] == ["#", "#"]:
            is_rock_continuing = True
            break
    for i in range(hnuke_start, hnuke_goal + 1):
        if grid[i:i + 3] == [".", ".", "."]:
            count += 1
    if snuke_goal < hnuke_goal and not is_rock_continuing:
        print("Yes")
    elif hnuke_goal < snuke_goal and not is_rock_continuing and count:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    length, snuke_start, hnuke_start, snuke_goal, hnuke_goal = map(lambda x: int(x) - 1, input().split())
    grid = list(input())
    is_rock_continuing = False
    count = 0
    for i in range(length):
        if grid[i:i + 2] == ["#", "#"]:
            is_rock_continuing = True
            break
    for i in range(length - 1):
        if grid[i: i + 3] == [".", ".", "."]:
            count += 1
    if snuke_goal < hnuke_goal and not is_rock_continuing:
        print("Yes")
    elif hnuke_goal < snuke_goal and not is_rock_continuing and count:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

S = '.' + input() + '#'

# S[A,C],S[B,D]には'##'が存在してはいけない
if '##' in S[A: C + 1] or '##' in S[B: D + 1]:
    print('No')
    exit()

# 追い越さなければいけないとき
# S[B,D]に...が存在する必要がある
if D < C:
    if not '...' in S[B: D + 1]:
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import heapq

YES = "Yes"  # type: str
NO = "No"  # type: str

def isBlock(S,i):
    return S[i] == "#"

def hasContinuingSharp(S,A,B):
    prevSharp = False
    for i in range(A,B):
        if isBlock(S,i):
            if prevSharp:
                return True
            else:
                prevSharp = True
        else:
            prevSharp = False
    return False

def hasThreeContinueingNonSharp(S,A,B):
    nonBlockCount = 0
    for i in range(A,B):
        if isBlock(S,i):
            nonBlockCount = 0
        else:
            nonBlockCount += 1
            if nonBlockCount == 3:
                return True
    return False

def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    if hasContinuingSharp(S,A,C) or hasContinuingSharp(S,B,D):
        print(NO)
        return
    if C < D:
        print(YES)
        return
    if hasThreeContinueingNonSharp(S,B-1,D+1):
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import heapq

YES = "Yes"  # type: str
NO = "No"  # type: str

def isBlock(S,i):
    return S[i] == "#"

def hasContinuingSharp(S,A,B):
    prevSharp = False
    for i in range(A,B):
        if isBlock(S,i):
            if prevSharp:
                return True
            else:
                prevSharp = True
        else:
            prevSharp = False
    return False

def hasThreeContinueingNonSharp(S,A,B):
    nonBlockCount = 0
    for i in range(A,B):
        if isBlock(S,i):
            nonBlockCount = 0
        else:
            nonBlockCount += 1
            if nonBlockCount == 3:
                return True
    return False

def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    if hasContinuingSharp(S,A,C) or hasContinuingSharp(S,B,D):
        print(NO)
        return
    if C < D:
        print(YES)
        return
    if hasThreeContinueingNonSharp(S,B,D+1):
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import heapq

YES = "Yes"  # type: str
NO = "No"  # type: str

def isBlock(S,i):
    return S[i] == "#"

def hasContinuingSharp(S,A,B):
    prevSharp = False
    for i in range(A,B):
        if isBlock(S,i):
            if prevSharp:
                return True
            else:
                prevSharp = True
        else:
            prevSharp = False
    return False

def hasThreeContinueingNonSharp(S,A,B):
    nonBlockCount = 0
    for i in range(A,B):
        if isBlock(S,i):
            nonBlockCount = 0
        else:
            nonBlockCount += 1
            if nonBlockCount == 3:
                return True
    return False

def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    if hasContinuingSharp(S,A,max(C,D)):
        print(NO)
        return
    if C < D:
        print(YES)
        return
    if hasThreeContinueingNonSharp(S,B,D+1):
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import heapq

YES = "Yes"  # type: str
NO = "No"  # type: str

def isBlock(S,i):
    return S[i] == "#"

def hasContinuingSharp(S,A,B):
    prevSharp = False
    for i in range(A,B):
        if isBlock(S,i):
            if prevSharp:
                return True
            else:
                prevSharp = True
        else:
            prevSharp = False
    return False

def hasThreeContinueingNonSharp(S,A,B):
    nonBlockCount = 0
    for i in range(A,min(len(S),B)):
        if isBlock(S,i):
            nonBlockCount = 0
        else:
            nonBlockCount += 1
            if nonBlockCount == 3:
                return True
    return False

def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    if hasContinuingSharp(S,A,max(C,D)):
        print(NO)
        return
    if C < D:
        print(YES)
        return
    if hasThreeContinueingNonSharp(S,B,D+2):
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import heapq

YES = "Yes"  # type: str
NO = "No"  # type: str

def isBlock(S,i):
    return S[i] == "#"

def hasContinuingSharp(S,A,B):
    prevSharp = False
    for i in range(A,B):
        if isBlock(S,i):
            if prevSharp:
                return True
            else:
                prevSharp = True
        else:
            prevSharp = False
    return False

def hasThreeContinueingNonSharp(S,A,B):
    nonBlockCount = 0
    for i in range(A,B):
        if isBlock(S,i):
            nonBlockCount = 0
        else:
            nonBlockCount += 1
            if nonBlockCount == 3:
                return True
    return False

def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    if hasContinuingSharp(S,A,max(C,D)):
        print(NO)
        return
    if C < D:
        print(YES)
        return
    if hasThreeContinueingNonSharp(S,B,D):
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
s=list(S.split("#"))

answer="Yes"


if "##" in S[min(A,C):max(B,D)]:
    answer="No"
if C<D:
    pass
else:
    if "..." not in S[B:D]:
        answer="No"
    
print(answer)