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()
#0-indexedにするため
A-=1;B-=1;C-=1;D-=1
'''
A→C
B→D
順序としてありえるのは
A<B<D<C
A<B<C<D
A<C<B<D
C<Dなら飛び越える必要がない
C>Dなら飛び越える必要がある
飛び越えを成功させるためには3連続の.が途中にあることが必要十分である
'''
if C<D:
    #ここは飛び越える必要がないとき
    Snuke=[0 for i in range(N)]
    Fnuke=[0 for i in range(N)]
    Snuke[A]=1
    Fnuke[B]=1
    for i in range(1,N):
        if S[i]=="#":
            continue
        if Snuke[i-1]==1:
            Snuke[i]=1
        if i>1 and Snuke[i-2]==1:
            Snuke[i]=1
        if Fnuke[i-1]==1:
            Fnuke[i]=1
        if i>1 and Fnuke[i-2]==1:
            Fnuke[i]=1
    if Snuke[C]==1 and Fnuke[D]==1:
        print("Yes")
    else:
        print("No")
else:
    #A<B<D<C
    #ここは飛び越える必要があるとき
    Snuke=[0 for i in range(N)]
    Fnuke=[0 for i in range(N)]
    Snuke[A]=1
    Fnuke[B]=1
    for i in range(1,N):
        if S[i]=="#":
            continue
        if Snuke[i-1]==1:
            Snuke[i]=1
        if i>1 and Snuke[i-2]==1:
            Snuke[i]=1
        if Fnuke[i-1]==1:
            Fnuke[i]=1
        if i>1 and Fnuke[i-2]==1:
            Fnuke[i]=1
    flag=0
    for i in range(C-2):
        if S[i]=="." and S[i+1]=="." and S[i+2]==".":
            flag=1
            break
    if Snuke[C]==1 and Fnuke[D]==1 and flag==1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
#0-indexedにするため
A-=1;B-=1;C-=1;D-=1
'''
A→C
B→D
順序としてありえるのは
A B D C
A B C D
A C B D
C<Dなら飛び越える必要がない
C>Dなら飛び越える必要がある
飛び越えを成功させるためには3連続の.が途中にあることが必要十分である
'''
if C<D:
    #ここは飛び越える必要がないとき
    Snuke=[0 for i in range(N)]
    Fnuke=[0 for i in range(N)]
    Snuke[A]=1
    Fnuke[B]=1
    for i in range(1,N):
        if S[i]=="#":
            continue
        if Snuke[i-1]==1:
            Snuke[i]=1
        if i>1 and Snuke[i-2]==1:
            Snuke[i]=1
        if Fnuke[i-1]==1:
            Fnuke[i]=1
        if i>1 and Fnuke[i-2]==1:
            Fnuke[i]=1
    if Snuke[C]==1 and Fnuke[D]==1:
        print("Yes")
    else:
        print("No")
else:
    #A<B<D<C
    #ここは飛び越える必要があるとき
    Snuke=[0 for i in range(N)]
    Fnuke=[0 for i in range(N)]
    Snuke[A]=1
    Fnuke[B]=1
    for i in range(1,N):
        if S[i]=="#":
            continue
        if Snuke[i-1]==1:
            Snuke[i]=1
        if i>1 and Snuke[i-2]==1:
            Snuke[i]=1
        if Fnuke[i-1]==1:
            Fnuke[i]=1
        if i>1 and Fnuke[i-2]==1:
            Fnuke[i]=1
    flag=0
    for i in range(D-2):
        if Snuke[i]*Snuke[i+1]*Snuke[i+2]*Fnuke[i]*Fnuke[i+1]*Fnuke[i+2]==1:
            flag=1
            break
    if Snuke[C]==1 and Fnuke[D]==1 and flag==1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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


def solve():
    if '##' in S[A:C + 1] or '##' in S[B:D + 1]:
        return 'No'

    if C > D:
        if '...' not in S[B:D + 2]:
            return 'No'

    return 'Yes'


print(solve())

Submission status: Wrong Answer

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


def solve():
    if '##' in S[A:C + 1] or '##' in S[B:D + 1]:
        return 'No'

    if C > D:
        if '...' not in S[B:D + 1]:
            return 'No'

    return 'Yes'


print(solve())

Submission status: Wrong Answer

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


def solve():
    if S[C - 1] == '#' or S[D - 1] == '#':
        return 'No'

    if '##' in S[A:C] or '##' in S[B:D]:
        return 'No'

    if C > D:
        if '...' not in S[B:D]:
            return 'No'

    return 'Yes'


print(solve())

Submission status: Wrong Answer

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


def solve():
    if S[C - 1] == '#' or S[D - 1] == '#':
        return 'No'

    if C < D:
        for i in range(N - 1):
            if S[i] == '#' and S[i + 1] == '#':
                return 'No'
    else:
        if '##' not in S[A:C] and '...' not in S[A:D]:
            return 'No'

    return 'Yes'


print(solve())

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

ans=''
if c<d:
    for i in range(a,d-1):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    ans='Yes'
    print(ans)
elif c>d:
    for i in range(a-1,c-1):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    for i in range(b-2,d):
        if s[i:i+3]=='...':
            ans='Yes'
            print(ans)
            exit()
    ans='No'
    print(ans)

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

ans=''
if c<d:
    for i in range(a,d-1):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    ans='Yes'
    print(ans)
elif c>d:
    for i in range(a-1,c-1):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    for i in range(b-1,d+1):
        if s[i:i+3]=='...':
            ans='Yes'
            print(ans)
            exit()
    ans='No'
    print(ans)

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

ans=''
if c<d:
    for i in range(a,d-1):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    ans='Yes'
    print(ans)
elif c>d:
    for i in range(a-1,c-1):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    for i in range(a-1,d-1):
        if s[i:i+3]=='...':
            ans='Yes'
            print(ans)
            exit()
    ans='No'
    print(ans)

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

ans=''
if c<d:
    for i in range(a,d-1):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    ans='Yes'
    print(ans)
elif c>d:
    for i in range(a-1,c-1):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    for i in range(b-1,d-1):
        if s[i:i+3]=='...':
            ans='Yes'
            print(ans)
            exit()
    ans='No'
    print(ans)

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

ans=''
if c<d:
    for i in range(a,d-1):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    ans='Yes'
    print(ans)
elif c>d:
    for i in range(a,c-1):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    for i in range(b-1,d):
        if s[i:i+3]=='...':
            ans='Yes'
            print(ans)
            exit()
    ans='No'
    print(ans)

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

ans=''
if c<d:
    for i in range(a,d-1):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    ans='Yes'
    print(ans)
elif c>d:
    for i in range(a,c-1):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    for i in range(b-1,d-1):
        if s[i:i+3]=='...':
            ans='Yes'
            print(ans)
            exit()
    ans='No'
    print(ans)

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

ans=''
if c<d:
    for i in range(a,d):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    ans='Yes'
    print(ans)
elif c>d:
    for i in range(a,c):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    for i in range(b-1,d+1):
        if s[i:i+3]=='...':
            ans='Yes'
            print(ans)
            exit()
    ans='No'
    print(ans)

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

ans=''
if c<d:
    for i in range(a,d):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    ans='Yes'
    print(ans)
elif c>d:
    for i in range(a,c):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    for i in range(b-1,d-1):
        if s[i:i+3]=='...':
            ans='Yes'
            print(ans)
            exit()
    ans='No'
    print(ans)

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

ans=''
if c<d:
    for i in range(a,d):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    ans='Yes'
    print(ans)
elif c>d:
    for i in range(a,c):
        if s[i:i+2]=='##':
            ans='No'
            print(ans)
            exit()
    for i in range(a,d-1):
        if s[i:i+3]=='...':
            ans='Yes'
            print(ans)
            exit()
    ans='No'
    print(ans)

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

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

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

ans=''
for i in range(a,c):
    if s[i:i+2]=='##':
        ans='No'
        print(ans)
        exit()
for i in range(b,d):
    if s[i:i+2]=='##':
        ans='No'
        print(ans)
        exit()
if c<d:
    ans='Yes'
    print(ans)
elif c>d:
    for i in range(a,c-2):
        if s[i:i+3]=='...':
            ans='Yes'
            print(ans)
            exit()
    ans='No'
    print(ans)

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

ans=''
for i in range(a,c):
    if s[i:i+2]=='##':
        ans='No'
        print(ans)
        exit()
for i in range(b,d):
    if s[i:i+2]=='##':
        ans='No'
        print(ans)
        exit()
if c<d:
    ans='Yes'
    print(ans)
elif c>d:
    for i in range(a,d-1):
        if s[i:i+3]=='...':
            ans='Yes'
            print(ans)
            exit()
    ans='No'
    print(ans)

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

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

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
n,a,b,c,d=nl()
s=si()

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
A-=1;B-=1;C-=1;D-=1
L=[0 for i in range(N)]
R=[0 for i in range(N)]
L[A]=1;R[B]=1
for i in range(A,N):
    if S[i]=="#":
        continue
    if i>0:
        if L[i-1]==1:
            L[i]=1
    if i>1:
        if L[i-2]==1:
            L[i]=1
for i in range(A-1,-1,-1):
    if S[i]=="#":
        continue
    if i+1<N:
        if L[i+1]==1:
            L[i]=1
    if i+2<N:
        if L[i+2]==1:
            L[i]=1

for i in range(B,N):
    if S[i]=="#":
        continue
    if i>0:
        if R[i-1]==1:
            R[i]=1
    if i>1:
        if R[i-2]==1:
            R[i]=1
for i in range(B-1,-1,-1):
    if S[i]=="#":
        continue
    if i+1<N:
        if R[i+1]==1:
            R[i]=1
    if i+2<N:
        if R[i+2]==1:
            R[i]=1

#print(list(S))
#print(L)
#print(R)
#print(A,B,C,D)
if C<D:
    if L[C]==1 and R[D]==1:
        print("Yes")
    else:
        print("No")
else:
    #D<C
    flag=0
    for i in range(N-2):
        if L[i]*L[i+1]*L[i+2]*R[i]*R[i+1]*R[i+2]==1:
            flag=1
            break
    if flag==1 and L[C]==1 and R[D]==1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
S = input()
for i in range(N-1):
    if S[i] == S[i+1] == '#':
        print('No')
        exit()
if C < D:
    print('Yes')
else:
    count = 0
    for i in range(B-1,N):
        if count == 3:
            print('Yes')
            exit()
        if S[i] == '.':
            count += 1
        else:
            count = 0
    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):
        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 = 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):
        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 = 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, min(C, D))):
    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, min(C, D)-1)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

tmp = ""
for i in range(min(a,b),max(c,d)):
	if tmp == "#" and s[i] == "#":
		print("No")
		sys.exit()

if (a < b) == (c < d):
	print("Yes")
	sys.exit()

a,b = min(a,b), max(a,b)
d,c = min(c,d), max(c,d)

if s[d-2] == s[d] == ".":
	print("Yes")
	sys.exit()

if s[b-2] == "#":
	if s[b] == s[b+1] == ".":
		print("Yes")
		sys.exit()
elif s[b] == ".":
	print("Yes")
	sys.exit()

cnt = 0
for i in range(b-1,d-1):
	if s[i] == ".":
		cnt += 1
	else:
		cnt = 0

	if cnt > 2:
		print("Yes")
		sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

tmp = ""
for i in range(n):
	if tmp == "#" and s[i] == "#":
		print("No")
		sys.exit()

if (a < b) == (c < d):
	print("Yes")
	sys.exit()

a,b = min(a,b), max(a,b)
d,c = min(c,d), max(c,d)

if s[d-2] == s[d] == ".":
	print("Yes")
	sys.exit()

if s[b-2] == "#":
	if s[b] == s[b+1] == ".":
		print("Yes")
		sys.exit()
elif s[b] == ".":
	print("Yes")
	sys.exit()

cnt = 0
for i in range(b-1,d-1):
	if s[i] == ".":
		cnt += 1
	else:
		cnt = 0

	if cnt > 2:
		print("Yes")
		sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

tmp = ""
for i in range(n):
	if tmp == "#" and s[i] == "#":
		print("No")
		sys.exit()

if (a < b) == (c < d):
	print("Yes")
	sys.exit()

a,b = min(a,b), max(a,b)
d,c = min(c,d), max(c,d)

cnt = 0
for i in range(b-1,d-1):
	if s[i] == ".":
		cnt += 1
	else:
		cnt = 0

	if cnt > 2:
		print("Yes")
		sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

tmp = ""
for i in range(n):
	if tmp == "#" and s[i] == "#":
		print("No")
		sys.exit()

if (a < b) == (c < d):
	print("Yes")
	sys.exit()

a,b = min(a,b), max(a,b)
d,c = min(c,d), max(c,d)

if s[d-2] == ".":
	print("Yes")
	sys.exit()

if s[b-2] == "#":
	if s[b] == s[b+1] == ".":
		print("Yes")
		sys.exit()
elif s[b] == ".":
	print("Yes")
	sys.exit()

cnt = 0
for i in range(b-1,d-1):
	if s[i] == ".":
		cnt += 1
	else:
		cnt = 0

	if cnt > 2:
		print("Yes")
		sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

tmp = ""
for i in range(n):
	if tmp == "#" and s[i] == "#":
		print("No")
		sys.exit()

if (a < b) == (c < d):
	print("Yes")
	sys.exit()

a,b = min(a,b), max(a,b)
d,c = min(c,d), max(c,d)

if s[d-2] == ".":
	print("Yes")
	sys.exit()

if s[b-2] == "#":
	if s[b] == s[b+1] == ".":
		print("Yes")
		sys.exit()
elif s[b-2] == s[b] == ".":
	print("Yes")
	sys.exit()

cnt = 0
for i in range(b,d):
	if s[i] == ".":
		cnt += 1
	else:
		cnt = 0

	if cnt > 2:
		print("Yes")
		sys.exit()

print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys


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

S = {i : s for i, s in enumerate(input(), 1)}

# AとBは接触しないので個別に進めればOK
if C < D:
  while B != D:
    if S[B+1] == '.':
      B += 1
    else:
      if S[B+2] == '.':
        B += 2
      else:
        print("No")
        sys.exit()

  while A != C:
    if S[A+1] == '.':
      A += 1
    else:
      if S[A+2] == '.':
        A += 2
      else:
        print("No")
        sys.exit()
  print("Yes")
  
# AとBは途中ですれ違う必要がある
# BをAが飛び越えられる場所(3マス連続で空白になる場所)で止めておくことにする
# Aのループは普通に回してよい なぜならば、3マス連続の空白は普通に通過できるし、
# その間Bがそこにいることにすれば良いため
else:
  # AがBを追い越せる場所があるか判定
  stay_B_index = []
  continuous_empty = 0
  for i in range(B-1, D+2):
    if S[i] == '.':
      continuous_empty += 1
    else:
      continuous_empty = 0

    if continuous_empty >= 3:
      stay_B_index.append(i - 1)
  
  # 追い越せなければ終わり
  if len(stay_B_index) == 0:
    print("No")
    sys.exit()
    
  # 追い越せる場合
  else:
    stay_B = False
    while B != D:
      # そこに到達できるのか判定 (手前に岩があって到達不能な可能性がある)
      if B in stay_B_index:
        stay_B = True
      if S[B+1] == '.':
        B += 1
      else:
        if S[B+2] == '.':
          B += 2
        else:
          print("No")
          sys.exit()
    
    # Bが到達できる場合
    if stay_B:
      while A != C:
        if S[A+1] == '.':
          A += 1
        else:
          if S[A+2] == '.':
            A += 2
          else:
            print("No")
            sys.exit()
      print("Yes")
      
    # Bが空白地帯に到達できなければNo
    else:
      print("No")

Submission status: Wrong Answer

Solution code:
import sys


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

S = {i : s for i, s in enumerate(input(), 1)}

if C < D:
  while B != D:
    if S[B+1] == '.':
      B += 1
    else:
      if S[B+2] == '.':
        B += 2
      else:
        print("No")
        sys.exit()

  while A != C:
    if S[A+1] == '.':
      A += 1
    else:
      if S[A+2] == '.':
        A += 2
      else:
        print("No")
        sys.exit()
  print("Yes")
else:
  stay_B_index = []
  continuous_empty = 0
  for i in range(B-1, D+2):
    if S[i] == '.':
      continuous_empty += 1
    else:
      continuous_empty = 0

    if continuous_empty == 3:
      stay_B_index.append(i - 1)

  if len(stay_B_index) == 0:
    print("No")
    sys.exit()
  else:
    stay_B = False
    while B != D:
      if B in stay_B_index:
        stay_B = True
      if S[B+1] == '.':
        B += 1
      else:
        if S[B+2] == '.':
          B += 2
        else:
          print("No")
          sys.exit()
          
    if stay_B:
      while A != C:
        if S[A+1] == '.':
          A += 1
        else:
          if S[A+2] == '.':
            A += 2
          else:
            print("No")
            sys.exit()
      print("Yes")
    else:
      print("No")

Submission status: Wrong Answer

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

if (a > b and c > d) or (a < b and c < d):
  rock = 0
  for i in range(a-1, c):
    if l[i] == '#':
      rock += 1
      if rock == 2:
        ans = 'No'
        break
    else:
      rock = 0
  rock = 0
  for i in range(b-1, d):
    if l[i] == '#':
      rock += 1
      if rock == 2:
        ans = 'No'
        break
    else:
      rock = 0
  if ans == '':
    ans = 'Yes'
else:
  rock = 0
  for i in range(a-1, c):
    if l[i] == '#':
      rock += 1
      if rock == 2:
        ans = 'No'
        break
    else:
      rock = 0
  rock = 0
  for i in range(b-1, d):
    if l[i] == '#':
      rock += 1
      if rock == 2:
        ans = 'No'
        break
    else:
      rock = 0
  blank = 0
  for i in range(min(a, b)-1, max(c, d)):
    if l[i] == '.':
      blank += 1
      if blank == 3:
        ans = 'Yes'
        break
    else:
      blank = 0    
  if ans == '':
    ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = list(input())
pre = S[B - 2]
ans = "Yes"
is_reversed = False
cnt = 0
max_cnt = 0
if D < C:
  is_reversed = True

for i in range(A,max(C,D) -1):
  if S[i] == S[i + 1] == "#":
    ans = "No"
for i in range(B - 2,D):
  if S[i] == ".":
    cnt += 1
  elif S[i] == "#":
    cnt = 0
  max_cnt = max(max_cnt,cnt)
  pre = S[i]
if is_reversed == True and max_cnt < 3:
  ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = list(input())
pre = S[B - 2]

ans = "Yes"
is_reversed = False
cnt = 0

max_cnt = 0
if D < C:
  is_reversed = True

for i in range(A,max(C,D) -1):
  if S[i] == S[i + 1] == "#":
    ans = "No"
for i in range(B - 2,D - 1):

  if S[i] == ".":
    cnt += 1
  elif S[i] == "#":
    cnt = 0
  max_cnt = max(max_cnt,cnt)
  pre = S[i]
if is_reversed == True and max_cnt < 3:
  ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = list(input())
pre = S[B - 2]
ans = "Yes"
is_reversed = False
cnt = 0

max_cnt = 0
if D < C:
  is_reversed = True

for i in range(A,C - 3):
  if S[i] == S[i + 1] == "#":
    ans = "No"
for i in range(B,D - 3):
  if S[i] == S[i + 1] == "#":
    ans = "No"
for i in range(B - 2,D):
  if S[i] == ".":
    cnt += 1
  elif S[i] == "#":
    cnt = 0
  max_cnt = max(max_cnt,cnt)
  pre = S[i]
if is_reversed == True and max_cnt < 3:
  ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = list(input())
pre = S[B - 2]
ans = "Yes"
is_reversed = False
cnt = 0
max_cnt = 0
if D < C:
  is_reversed = True
for i in range(A,max(C,D) - 3):
  if S[i] == S[i + 1] == "#":
    ans = "No"
for i in range(B - 2,D):
  if S[i] == ".":
    cnt += 1
  elif S[i] == "#":
    cnt = 0
  max_cnt = max(max_cnt,cnt)
  pre = S[i]
if is_reversed == True and max_cnt < 3:
  ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = list(input())
pre = S[B - 2]

ans = "Yes"
is_reversed = False
cnt = 0
max_cnt = 0
if D < C:
  is_reversed = True
for i in range(B - 2,D):
  if i != B - 2 and pre == "#" and S[i] == "#":
    ans = "No"
    break
  if S[i] == ".":
    cnt += 1
  elif S[i] == "#":
    cnt = 0
  max_cnt = max(max_cnt,cnt)
  pre = S[i]
if is_reversed == True and max_cnt < 3:
  ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S_S = input()
if "##" in S_S:
  ans = "No"
S = list(S_S)
pre = S[B - 2]
ans = "Yes"
is_reversed = False
cnt = 0
max_cnt = 0
if D < C:
  is_reversed = True
for i in range(B - 2,D):
  if S[i] == ".":
    cnt += 1
  elif S[i] == "#":
    cnt = 0
  max_cnt = max(max_cnt,cnt)
  pre = S[i]
if is_reversed == True and max_cnt < 3:
  ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S_S = input()
if "##" in S_S:
  ans = "No"
S = list(S_S)
pre = S[B - 2]
ans = "Yes"
is_reached = False
is_reversed = False
cnt = 0
max_cnt = 0
if D < C:
  is_reversed = True
for i in range(B - 1,D - 1):
  if S[i] == ".":
    cnt += 1
  elif S[i] == "#":
    cnt = 0
  max_cnt = max(max_cnt,cnt)
  pre = S[i]
if is_reversed == True and max_cnt < 3:
  ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S_S = input()
if "##" in S_S:
  ans = "No"
S = list(S_S)
pre = S[max(A,B) - 2]
ans = "Yes"
is_reached = False
is_reversed = False
cnt = 0

max_cnt = 0
if A < B and D < C:
  is_reversed = True
elif A > B and D > C:
  is_reversed = True
for i in range(max(A,B) - 1,N):
  if pre == "#" and S[i] == "#":
    ans = "No"
    break
  elif S[i] == ".":
    cnt += 1
  elif S[i] == "#":
    cnt = 0
  max_cnt = max(max_cnt,cnt)
  if i == min(C,D) - 1:
    reached = True
    break
  pre = S[i]
if is_reversed == True and max_cnt < 3:
  ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = list(input())
pre = S[0]
ans = "Yes"
is_reached = False
is_reversed = False
cnt = 1
max_cnt = 0
if A < B and D < C:
  is_reversed = True
elif A > B and D > C:
  is_reversed = True
for i in range(max(A,B) - 1,N):
  if pre == "#" and S[i] == "#":
    ans = "No"
    break
  elif S[i] == ".":
    cnt += 1
  elif S[i] == "#":
    cnt = 0
  max_cnt = max(max_cnt,cnt)
  if i == A:
    reached = True
    break
  pre = S[i]
if is_reversed == True and max_cnt < 3:
  ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
# 1-indexed
S = ["$"] + list(input())

if A < B < D < C:
    flag = False
    for i in range(A+1,C+1):
        if S[i] == S[i-1] == "#":
            flag = False
            break
        if S[i-2] == S[i-1] == S[i] == ".":
            if B <= i-2 or i <= D:
                flag = True
    
    if flag:
        print("Yes")
    else:
        print("No")
elif A < B < C < D:
    flag = True
    for i in range(A+1,D+1):
        if S[i] == S[i-1] == "#":
            flag = False
            break
    
    if flag:
        print("Yes")
    else:
        print("No")
elif A < C < B < D:
    flag = True
    for i in range(A+1,C+1):
        if S[i] == S[i-1] == "#":
            flag = False
            break
    for i in range(B+1,D+1):
        if S[i] == S[i-1] == "#":
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")