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

c1 = [0] * len(S)
c2 = [0] * len(S)
cnt1 = 0
cnt2 = 0
for i in range(len(S)):
    if '.' == S[i]:
        c2[i] = cnt2
        cnt2 = 0
        cnt1 += 1
    else:
        c1[i] = cnt1
        cnt1 = 0
        cnt2 += 1

c1[-1] = cnt1
c2[-1] = cnt2

index2 = []
index1 = []
for i in range(N):
    if c2[i] >= 2:
        index2.append(i)
    if c1[i] >= 3:
        index1.append(i)

flag = True
for i in index2:
    if A < i - c2[i] + 1 < C or B < i - c2[i] + 1 < D:
        flag = False

if C > D and flag:
    flag = False
    for i in index1:
        if B < i < D:
            flag = True

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

Submission status: Wrong Answer

Solution code:
import re                                                                                                        
import copy                                                                                                      

n,a,b,c,d=map(int,input().split())                                                                               
s=input()                                                                                                        
a-=1                                                                                                             
b-=1                                                                                                             
c-=1                                                                                                             
d-=1                                                                                                             
print(s)                                                                                                         
if "##" in s[a:c+1] or s[b:d+1]:                                                                                 
    print("No")                                                                                                  
else:                                                                                                            
    if c<d:                                                                                                      
        print("Yes")                                                                                             
    else:                                                                                                        
        if "..." in s[b-1:d+2]:                                                                                  
            print("Yes")                                                                                         
        else:                                                                                                    
            print("No")

Submission status: Wrong Answer

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

c1 = [0] * len(S)
c2 = [0] * len(S)
cnt1 = 0
cnt2 = 0
for i in range(len(S)):
    if '.' == S[i]:
        c2[i] = cnt2
        cnt2 = 0
        cnt1 += 1
    else:
        c1[i] = cnt1
        cnt1 = 0
        cnt2 += 1

c1[-1] = cnt1
c2[-1] = cnt2

index2 = []
index1 = []
for i in range(N):
    if c2[i] >= 2:
        index2.append(i)
    if c1[i] >= 3:
        index1.append(i)

flag = True
for i in index2:
    if A < i - c2[i] + 1 < C or B < i - c2[i] + 1 < D:
        flag = False

if C > D:
    flag = False
    for i in index1:
        if B < i < D:
            flag = True

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

Submission status: Wrong Answer

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

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

def solve(N: int, A: int, B: int, C: int, D: int, S: str):

    if(S[A-1:C+1].count('##') > 0 or S[B-1:D+1].count('##')):
    # if(S[A:max(C,D)].count('##') > 1):
        print(NO)
        sys.exit()

    if(D < C):
        if(S[B-2:D].count('...') <= 0):
            print(NO)
            sys.exit()
        else:
            print(YES)
    else:
        print(YES)
    return


# Generated by 1.1.4 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

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

def solve(N: int, A: int, B: int, C: int, D: int, S: str):

    # if(S[A-1:C+1].count('##') > 0 or S[B-1:D+1].count('##')):
    if(S[A:max(C,D)].count('##') > 1):
        print(NO)
        sys.exit()

    if(D < C):
        if(S[B-1:D+1].count('...') <= 0):
            print(NO)
            sys.exit()
        else:
            print(YES)
    else:
        print(YES)
    return


# Generated by 1.1.4 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

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

def solve(N: int, A: int, B: int, C: int, D: int, S: str):

    if(S[A-1:C+1].count('##') > 0 or S[B-1:D+1].count('##')):
        print(NO)
        sys.exit()

    if(D < C):
        if(S[B-1:D+1].count('...') <= 0):
            print(NO)
            sys.exit()
        else:
            print(YES)
    else:
        print(YES)
    return


# Generated by 1.1.4 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

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

def solve(N: int, A: int, B: int, C: int, D: int, S: str):

    if(S[A-1:C].count('##') > 0 or S[B-1:D].count('##')):
        print(NO)
        sys.exit()

    if(D < C):
        if(S[B-1:D+1].count('...') <= 0):
            print(NO)
            sys.exit()
        else:
            print(YES)
    else:
        print(YES)
    return


# Generated by 1.1.4 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

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

def solve(N: int, A: int, B: int, C: int, D: int, S: str):

    if(S[A-1:C].count('##') > 0 or S[B-1:D].count('##')):
        print(NO)
        sys.exit()

    if(D < C):
        if(S[B-1:D].count('...') <= 0):
            print(NO)
            sys.exit()
        else:
            print(YES)
    else:
        print(YES)
    return


# Generated by 1.1.4 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 = list(input())

for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()

if d < c:
    for i in range(n-2):

        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            if i < b:
                print("Yes")
            else:
                print("No")
            exit()

    print("No")
    exit()
else:
    print("Yes")

Submission status: Wrong Answer

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

for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()

if d < c:
    for i in range(n-2):

        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            print("Yes")
            exit()

    print("No")
    exit()
else:
    print("Yes")

Submission status: Wrong Answer

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

for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()
if d < c:
    for i in range(n-2):

        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            print("Yes")
            exit()

    print("No")
    exit()
else:
    print("No")

Submission status: Wrong Answer

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

for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()

if d > c:
    for i in range(n-2):

        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            print("Yes")
            exit()

    print("No")
    exit()
else:
    print("No")

Submission status: Wrong Answer

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

def solve(r,l):
    for i in range(r,l-1):
        if s[i-1] == "#" and s[i] == "#":
            return False
    return True

def perfect_solve(r,l):
    for i in range(r,l-1):
        if s[i-1] =="#" and s[i] =="#":
            return False

    for i in range(r-1,l-1):
        if s[i-1]=="." and s[i]=="." and s[i+1]==".":
            return True
    return False

if C < B :
    if solve(A,C) and solve(B,D):
        print("Yes")
    else:
        print("No")
elif C < D :
    if solve(B,D) and solve(A,B):
        print("Yes")
    else:
        print("No")
else:
    if perfect_solve(B,D) and solve(A,B) and solve(D,C):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()

if d > c:
    for i in range(n-2):
        if s[i] == "." and s[i+2] == "." and s[i+3] == ".":
            print("Yes")
            exit()

    print("No")
    exit()
else:
    print("No")

Submission status: Wrong Answer

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

for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        exit()

if d < c:
    for i in range(n-2):
        if s[i] == "." and s[i+2] == "." and s[i+3] == ".":
            print("Yes")
            exit()

    print("No")
    exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = [int(x) for x in input().split()]
s = input()
for i in range(a, max(c, d)):
    if s[i - 1: i + 1] == "##":
        print("No")
        sys.exit()
if c < d:
    print("Yes")
    sys.exit()
for i in range(a, d):
    if s[i - 1:i + 2] == "...":
        print("Yes")
        sys.exit()
print("No")

# print(*data, sep='\n')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = [int(x) for x in input().split()]
s = input()
for i in range(a, max(c, d)):
    if s[i - 1: i + 1] == "##":
        print("No")
        sys.exit()
if c < d:
    print("Yes")
    sys.exit()
for i in range(a, c - 1):
    if s[i - 1:i + 2] == "...":
        print("Yes")
        sys.exit()
print("No")

# print(*data, sep='\n')

Submission status: Wrong Answer

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

def solve(r,l,s):
    for i in range(r,l-1):
        if s[i-1] == "#" and s[i] == "#":
            return False
    return True

def perfect_solve(r,l,s):
    for i in range(r,l-1):
        if s[i-1] =="#" and s[i] =="#":
            return False

    for i in range(r-1,l-1):
        if s[i-1]=="." and s[i]=="." and s[i+1]==".":
            return True
    return False

if C < B :
    if solve(A,C,s) and solve(B,D,s):
        print("Yes")
    else:
        print("No")
elif C < D :
    if solve(B,D,s) and solve(A,B,s):
        print("Yes")
    else:
        print("No")
else:
    if perfect_solve(B,D,s) and solve(A,B,s) and solve(D,C,s):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

def solve(r,l,s):
    for i in range(r,l-1):
        if s[i-1] == "#" and s[i] == "#":
            return False
    return True

def perfect_solve(r,l,s):
    for i in range(r,l-1):
        if s[i-1] =="#" and s[i] =="#":
            return False

    for i in range(r-1,l-1):
        if s[i-1]=="." and s[i]=="." and s[i+1]==".":
            return True
    return False

if C < D :
    if solve(A,C,s) and solve(B,D,s):
        print("Yes")
    else:
        print("No")
elif C < D :
    if solve(B,D,s) and solve(A,B,s):
        print("Yes")
    else:
        print("No")
else:
    if perfect_solve(B,D,s) and solve(A,B,s) and solve(D,C,s):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

def solve(r,l,s):
    for i in range(r,l-1):
        if s[i-1] == "#" and s[i] == "#":
            return False
    return True

def perfect_solve(r,l,s):
    for i in range(r,l-1):
        if s[i-1] =="#" and s[i] =="#":
            return False

    for i in range(r,l-2):
        if s[i-1]=="." and s[i]=="." and s[i+1]==".":
            return True
    return False

if C < D :
    if solve(A,C,s) and solve(B,D,s):
        print("Yes")
    else:
        print("No")
elif C < D :
    if solve(B,D,s) and solve(A,B,s):
        print("Yes")
    else:
        print("No")
else:
    if perfect_solve(B,D,s) and solve(A,B,s) and solve(D,C,s):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# coding: UTF-8

v = list(map(int, input().split()))
n, a, b, c, d = v[0], v[1], v[2], v[3], v[4]
s = input()

ac_cnt_1, ac_max_1 = 0, 0
bd_cnt_1, bd_max_1 = 0, 0
bd_cnt_0, bd_max_0 = 0, 0

for i in range(c-a-1):
	if s[i+a] == '#':
		ac_cnt_1 += 1
		if ac_max_1 < ac_cnt_1:
			ac_max_1 = ac_cnt_1
	else:
		ac_cnt_1 = 0
for i in range(d-b-1):
	if s[i+b] == '#':
		bd_cnt_0 = 0
		bd_cnt_1 += 1
		if bd_max_1 < bd_cnt_1:
			bd_max_1 = bd_cnt_1
	else:
		bd_cnt_0 += 1
		bd_cnt_1 = 0
		if bd_max_0 < bd_cnt_0:
			bd_max_0 = bd_cnt_0
if c < d:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1):
		print('Yes')
	else:
		print('No')
else:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1) and ((bd_max_0 >= 3) or ((s[b-2]=='.') and(s[b]=='.'))):
		print('Yes')
	else:
		if ((s[b-2] == '.') and (s[b] == '.')) or ((s[d-2] == '.') and (s[d] == '.')):
			print('Yes')
		else:
			print('No')

Submission status: Wrong Answer

Solution code:
# coding: UTF-8

v = list(map(int, input().split()))
n, a, b, c, d = v[0], v[1], v[2], v[3], v[4]
s = input()

ac_cnt_1, ac_max_1 = 0, 0
bd_cnt_1, bd_max_1 = 0, 0
bd_cnt_0, bd_max_0 = 0, 0

for i in range(c-a-1):
	if s[i+a] == '#':
		ac_cnt_1 += 1
		if ac_max_1 < ac_cnt_1:
			ac_max_1 = ac_cnt_1
	else:
		ac_cnt_1 = 0
for i in range(d-b-1):
	if s[i+b] == '#':
		bd_cnt_0 = 0
		bd_cnt_1 += 1
		if bd_max_1 < bd_cnt_1:
			bd_max_1 = bd_cnt_1
	else:
		bd_cnt_0 += 1
		bd_cnt_1 = 0
		if bd_max_0 < bd_cnt_0:
			bd_max_0 = bd_cnt_0
if c < d:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1):
		print('Yes')
	else:
		print('No')
else:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1) and (bd_max_0 >= 3):
		print('Yes')
	else:
		if ((s[b-2] == '.') and (s[b] == '.')) or ((s[d-2] == '.') and (s[d] == '.')):
			print('Yes')
		else:
			print('No')

Submission status: Wrong Answer

Solution code:
def evaluate(s, a, b, c, d):
    if '##' in s[a-1:c] or '##' in s[b-1:d]:
        return 'NO'
    if c < d:
        return 'YES'
    else:
        if '...' in s[b-1: d+2]:
            return 'YES'
        else:
            return 'NO'


def main():
    n, a, b, c, d = [int(_) for _ in input().split()]
    s = input()
    print(evaluate(s, a, b, c, d))

main()

Submission status: Wrong Answer

Solution code:
def evaluate(s, a, b, c, d):
    if '##' in s[a-1:c] or '##' in s[b-1:d]:
        return 'NO'
    if c < d:
        return 'YES'
    else:
        if '...' in s[b-1: d]:
            return 'YES'
        else:
            return 'NO'


def main():
    n, a, b, c, d = [int(_) for _ in input().split()]
    s = input()
    print(evaluate(s, a, b, c, d))

main()

Submission status: Wrong Answer

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

AtoC = True
BtoD = True
replace = False

for n in list(range(A-1,C)):
    if S[n] =='#' and S[n+1] =='#':
        AtoC = False
        
for n in list(range(B-1,D)):
    if S[n] =='#' and S[n+1] == '#':
        BtoD = False
        
for n in list(range(B-2,D-2)):
    if S[n] =='.' and S[n+1] == '.' and S[n+2] == '.':
        replace = True
if C<D:
    if AtoC == True and BtoD == True:
        print('Yes')
    else:
        print('No')
else:
    if AtoC == True and BtoD == True and replace == True:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
input()
input()
print("Yes")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
ans = "Yes"
iwa = 0
for i in S[A-1:C]:
    if i == "#":
        iwa += 1
        if iwa > 1:
            ans == "No"
    else:
        iwa = 0
iwa = 0
for i in S[B-1:D]:
    if i == "#":
        iwa += 1
        if iwa > 1:
            ans == "No"
    else:
        iwa = 0
flag = 0
hoge = 0
if D < C:
    for i in S[B-2:D+1]:
        if i ==".":
            hoge += 1
            flag = max(flag,hoge)
        else:
            hoge = 0
    if flag < 3:
        ans = "No"
print(ans)

Submission status: Wrong Answer

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

multi = False
excha = False
for i in range(D-3,B-2,-1):
    if S[i] == '#' and S[i+1] == '#':
        multi = True
    if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
        excha = True
if multi:
    Ans = "No"
if not excha:
    S.pop(D-1)
    S.insert(D-1,'#')
        
multi = False
for i in range(C-3,A-1,-1):
    if S[i] == '#' and S[i+1] == '#':
        multi = True
if multi:
    Ans = "No"

print(Ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
ans = "Yes"
iwa = 0
for i in S[A:C+1]:
    if i == "#":
        iwa += 1
        if iwa > 1:
            ans == "No"
    else:
        iwa = 0
iwa = 0
for i in S[B:D+1]:
    if i == "#":
        iwa += 1
        if iwa > 1:
            ans == "No"
    else:
        iwa = 0
flag = 0
hoge = 0
if D < C:
    for i in S[B-1:D+2]:
        if i ==".":
            hoge += 1
            flag = max(flag,hoge)
        else:
            hoge = 0
    if flag < 3:
        ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int, input().split())
s=input()
v=0
x=0
for i in range(n-2):
    if c<d:
        if i>b and i<d and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break

    
    elif c>d:
        if  i>=b-1 and i<d+1 and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.' :
            x=1
            break
if x==0 and c>d:
    print('No')
            
if x==1:
    for i in range(n-2):
        if i>b and i<c and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break
    if v==0 and x==1:
        print('Yes')
if c<d and v==0:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
ans = "Yes"
iwa = 0
for i in S[A:C+1]:
    if i == "#":
        iwa += 1
        if iwa > 1:
            ans == "No"
    else:
        iwa = 0
iwa = 0
for i in S[B:D+1]:
    if i == "#":
        iwa += 1
        if iwa > 1:
            ans == "No"
    else:
        iwa = 0
flag = 0
hoge = 0
if D < C:
    for i in S[B-1:D+1]:
        if i ==".":
            hoge += 1
            flag = max(flag,hoge)
        else:
            hoge = 0
    if flag < 3:
        ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
ans = "Yes"
iwa = 0
for i in S[A:C+1]:
    if i == "#":
        iwa += 1
        if iwa > 1:
            ans == "No"
    else:
        iwa = 0
iwa = 0
for i in S[B:D+1]:
    if i == "#":
        iwa += 1
        if iwa > 1:
            ans == "No"
    else:
        iwa = 0
flag = 0
hoge = 0
if D < C:
    for i in S[B:D+1]:
        if i ==".":
            hoge += 1
            flag = max(flag,hoge)
        else:
            hoge = 0
    if flag < 3:
        ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

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

    ans = 'YES'
    if '##' in S[A-1:C] or '##' in S[B-1:D]:
        ans = 'No'

    if D < C:  # 追い越す場所が必要
        if '...' not in S[B-3:D+1]:
            ans = 'No'

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

S = str(input())

moziretu = S  # 保持しておく

# Bの人から動かす
zenhann = True
hoge = S[B+1]
for i in range(B+2, D):
    if hoge == S[i] and hoge == '#':
        zenhann = False
        break
    else:
        hoge = S[i]


if zenhann:
    str_list = list(S)
    str_list[D] = '#'
    S = "".join(str_list)

    hoge = S[A+1]
    for i in range(A+2, C):
        if hoge == S[i] and hoge == '#':
            zenhann = False
            break
        else:
            hoge = S[i]


kouhann = True
# Aの人から動かす
str_list = list(moziretu)
str_list[B] = '#'
moziretu = "".join(str_list)

hantei = moziretu[B+1]
for i in range(B+2, D):
    if hantei == moziretu[i] and moziretu[i+1] == '#' and moziretu[i+2] == '#':
        kouhann = False
        break
    else:
        hantei = moziretu[i]

if kouhann:
    fuga = moziretu[A+1]
    for i in range(A+2, C):
        if fuga == moziretu[i] and fuga == '#':
            kouhann = False
            break
        else:
            fuga = S[i]
    if kouhann:
        str_list = list(moziretu)
        str_list[C] = '#'
        moziretu = "".join(str_list)

        fuga = moziretu[B+1]
        for i in range(B+2, D):
            if fuga == moziretu[i] and fuga == '#':
                kouhann = False
                break
            else:
                fuga = moziretu[i]

if zenhann or kouhann:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

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

    ans = 'YES'
    if '##' in S[A-1:C] or '##' in S[B-1:D]:
        ans = 'No'

    if D < C:  # 追い越す場所が必要
        if '...' not in S[B-2:D+1]:
            ans = 'No'

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

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

    ans = 'YES'
    if '##' in S[A-1:C] or '##' in S[B-1:D]:
        ans = 'No'

    if D < C:  # 追い越す場所が必要
        can_overtake = False
        if '...' in S[B-2:D+1]:
            can_overtake = True

        if not can_overtake:
            ans = 'No'

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
def chk(l, r):
    for i in range(l, r-1):
        if S[i:i+2] == "##":
            return 0
    return 1

def chk3(l, r):
    for i in range(l, r-2):
        if S[i:i+3].count("#") == 0:
            return 1
    return 0

if chk(A, C) and chk(B, D) and (C<D or chk3(B-1, D-1)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
def chk(l, r):
    for i in range(l, r-1):
        if S[i:i+2] == "##":
            return 0
    return 1

def chk3(l, r):
    for i in range(l, r-2):
        if S[i:i+3].count("#") == 0:
            return 1
    return 0

if chk(A, C) and chk(B, D) and (C<D or chk3(B-1, D)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=input().split()
S = list(input())
N = int(N)
A = int(A)
B = int(B)
C = int(C)
D = int(D)
t=0
if C < D:
	for i in range(B,D-2):
		if S[i] == S[i+1] == '#':
			print('No')
			exit()
	for i in range(A,C-2):
		if S[i] == S[i+1] == '#':
			print('No')
			exit()
else:
	t=1
	for i in range(B,D-2):
		if S[i] == S[i+1] == '#':
			print('No')
			exit()
	for i in range(A,C-2):
		if S[i] == S[i+1] == '#':
			print('No')
			exit()
	for i in range(B-1,D-1):
		if S[i-1] == S[i] == S[i+1] == '.':
			t=0
if t == 0:
	print('Yes')
	exit()
else:
	print('No')
	exit()
print('Yes')
exit()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if c<d and "##" not in s[a:d]:print("Yes")
elif d<c and "##" not in s[a:d] and "..." in s[b-1:d]:print("Yes")
else:print("No")

Submission status: Wrong Answer

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

a_to_c = s[a - 1:c]
b_to_d = s[b - 1:d]
if '##' in a_to_c or '##' in b_to_d:
    print('No')
elif c > d and '...' not in b_to_d:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

a_to_c = s[a - 1:c]
b_to_d = s[b - 1:d]
if s[c - 1] == '#' or s[d - 1] == '#':
    print('1')
    print('No')
    exit()

if '##' in a_to_c or '##' in b_to_d:
    print('No')
    exit()

if c > d and '...' not in b_to_d:
    print('No')
    exit()

print('Yes')

Submission status: Wrong Answer

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

a_to_c = s[a-1:c]
b_to_d = s[b - 1:d]

if '##' in a_to_c or '##' in b_to_d:
    print('No')
    exit()

if c > d and '...' not in b_to_d:
    print('No')
    exit()

if s[c-1] == '#' or s[d-1] == '#':
    print('No')
    exit()

print('Yes')

Submission status: Wrong Answer

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

b_to_d = s[b - 1:d]
a_to_last = s[a - 1:max(c, d)]

if '##' in a_to_last:
    print('No')
    exit()

if c > d and '...' not in b_to_d:
    print('No')
    exit()

if s[c-1] == '#' or s[d-1] == '#':
    print('No')
    exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import itertools
from collections import Counter
from collections import defaultdict
import bisect
import math
import heapq

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

    blocks = 0
    for s in range(A - 1, C):
        if S[s] == '.':
            if blocks > 1:
                print('No')
                exit()
            blocks = 0
        else:
            blocks += 1

    blocks = 0
    for s in range(B - 1, D):
        if S[s] == '.':
            if blocks > 1:
                print('No')
                exit()
            blocks = 0
        else:
            blocks += 1

    if D < C:  # 追い越す場所が必要
        can_overtake = False
        for s in range(B - 1, D - 1):
            if S[s-1] == '.' and S[s] == '.' and S[s+1] == '.':
                can_overtake = True
                break

        if not can_overtake:
            print('No')
            exit()

    print('Yes')


if __name__ == '__main__':
    main()