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

if('##' in s[a-1:d]):
    print('No')
    exit()
if(c < d):
    print('Yes')
else:
    if('...' in s[b-2:d]):
        print('Yes')
    else:
        print('No?')

Submission status: Wrong Answer

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

if('##' in s[a-1:d]):
    print('No')
    exit()
if(c < d):
    print('Yes')
else:
    if('...' 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()


if('##' in s[a:d]):
    print('No')
    exit()
if(c < d):
    print('Yes')
else:
    if('...' in s[b:d-1]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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


if('##' in s[a:c] or '##' in s[b:d]):
    print('No')
    exit()
if(c < d):
    print('Yes')
else:
    if('...' in s[b:d-1]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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


if('##' in s[a:c] or '##' in s[b:d]):
    print('No')
    exit()
if(c < d):
    print('Yes')
else:
    if('...' in s[b:d]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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


if('##' in s[a:c] or '##' in s[b:d]):
    print('No')
    exit()
if(c < d):
    print('Yes')
else:
    if('...' in s[b:c]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

s[a-1] = 'A'
s[b-1] = 'B'
s = ''.join(s)

if('##' in s[a:c] or '##' in s[b:d]):
    print('No')
    exit()
if(c < d):
    print('Yes')
else:
    if('...' in s[b:c] or '.B.' in s[b-1:c] or 'AB.' in s):
        s = list(s)
        s[a-1] = '.'
        s[c-1] = 'A'
        s = ''.join(s)
        if('#A' in s[b:d] or 'A#' in s[b:d]):
            print('No')
        else:
            print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

s[a-1] = 'A'
s[b-1] = 'B'
s = ''.join(s)

if('##' in s[a:c] or '##' in s[b:d]):
    print('No')
    exit()
if(c < d):
    print('Yes')
else:
    if('...' in s[b-1:c] or '.B.' in s[b-1:c] or 'AB.' in s):
        s = list(s)
        s[a-1] = '.'
        s[c-1] = 'A'
        s = ''.join(s)
        if('#A' in s[b:d] or 'A#' in s[b:d]):
            print('No')
        else:
            print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

if S[A-1:C].find('##') != -1 or S[B-1:D].find('##') != -1:
    print('No')
    exit()

ans = 'Yes'
if C > D and S[B-2:D+2].find('...') == -1:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

if S[A-1:C-1].find('##') != -1 or S[B-1:D-1].find('##') != -1:
    print('No')
    exit()

ans = 'Yes'
if C > D and S[B-2:D-1].find('...') == -1:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

if any(A<=i<=C or B<=i<=D for i in range(N-1) if S[i:i+2] == '##'):
    print('No')
    exit()

ans = 'Yes'
if C > D and all(S[i:i+3] != '...' for i in range(B-1, D)):
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

if any(A<=i<=C and B<=i<=D for i in range(N-1) if S[i:i+2] == '##'):
    print('No')
    exit()

ans = 'Yes'
if C > D and all(S[i:i+3] != '...' for i in range(B-1, D)):
    ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    #入力
    N, A, B, C, D = (int(_) for _ in input().split())
    A, B, C, D = A-1, B-1, C-1, D-1
    S = input()

    sa, sb = S[A:C+1], S[B:D+1]
    can1 = can2 = True
    for i in range(len(sa)-1):
        if sa[i] == '#' and sa[i+1] == '#': can1 = False
    for i in range(len(sb)-1):
        if sb[i] == '#' and sb[i+1] == '#': can2 = False
    can = can1 and can2

    if can and D < C:
        sc = S[B-1:D+2]
        can3 = False
        for i in range(len(sc)-2):
            if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.': can3 = True
        can = can and can3

    print('Yes' if can else 'No')
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    #入力
    N, A, B, C, D = (int(_) for _ in input().split())
    S = input()

    sa, sb = S[A:C+1], S[B:D+1]
    can1 = can2 = True
    for i in range(len(sa)-1):
        if sa[i] == '#' and sa[i+1] == '#': can1 = False
    for i in range(len(sb)-1):
        if sb[i] == '#' and sb[i+1] == '#': can2 = False
    can = can1 and can2

    if can and D < C:
        sc = S[B-1:D]
        can3 = False
        for i in range(len(sc)-2):
            if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.': can3 = True
        can = can and can3

    print('Yes' if can else 'No')
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n , a , b , c , d = map(int,input().split())
s = input()
if s[a:c+1].count("##") != 0 or s[b:d+1].count("##") != 0:
    print("No")
    exit()
if c > d:
    if s[b-2:d+3].count("...") == 0:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n , a , b , c , d = map(int,input().split())
s = input()
if s[a:c+1].count("##") != 0 or s[b:d+1].count("##") != 0:
    print("No")
    exit()
if c > d:
    if s[b-2:d+2].count("...") == 0:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n , a , b , c , d = map(int,input().split())
s = input()
if s[a:c+1].count("##") != 0 or s[b:d+1].count("##") != 0:
    print("No")
    exit()
if c > d:
    if s[b:d+1].count("...") == 0:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n , a , b , c , d = map(int,input().split())
s = input()
if s[a:c+1].count("##") != 0 or s[b:d+1].count("##") != 0:
    print("No")
    exit()
if c > d:
    if s.count("...") == 0:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
a-=1;b-=1;c-=1;d-=1 
from collections import deque 

queueA=deque([a])
queueB=deque([b])
S=input()
JinA=JinB=[0]*n 
if c<b or c<d:
    for i in range(a,d):
        if S[i]=="#" and S[i+1]=="#":
            print("No")
            exit() 
    else:
        print("Yes")
        exit()
    
else:
    for i in range(min(a,c),max(a,c)):
        if S[i]=="#" and S[i+1]=="#":
            print("No")
            exit() 
    for i in range(min(b,d),max(b,d)):
        if S[i]=="#" and S[i+1]=="#":
            print("No")
            exit() 
    for i in range(n-2):
        if S[i]==S[i+1]==S[i+2]==".":
            print("Yes")
            exit()
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
a-=1;b-=1;c-=1;d-=1 
from collections import deque 

queueA=deque([a])
queueB=deque([b])
S=input()
JinA=JinB=[0]*n 
if c<b or c<d:
    for i in range(a,d):
        if S[i]=="#" and S[i+1]=="#":
            print("No")
            exit() 
    else:
        print("Yes")
        exit()
    
else:
    for i in range(n-2):
        if S[i]==S[i+1]==S[i+2]==".":
            print("Yes")
            exit()
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
a-=1;b-=1;c-=1;d-=1 
from collections import deque 

queueA=deque([a])
queueB=deque([b])
S=input()
JinA=JinB=[0]*n 
if c<b or c<d:
    for i in range(a,d):
        if S[i]=="#" and S[i+1]=="#":
            print("No")
            exit() 
    else:
        print("Yes")
        exit()
    
else:
    for i in range(n-2):
        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()

if "##" in s[a:max(c,d)]:print("No")
elif c>d and "..." not in s[b-1:d+1]:print("No")
else:print("Yes")

Submission status: Wrong Answer

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

if "##" in s[a:max(c,d)]:print("No")
elif c>d and "..." not in s[b+1:d+1]:print("No")
else:print("Yes")

Submission status: Wrong Answer

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

if "##" in s[a:max(c,d)]:print("No")
elif c>d and "..." not in s[b-1:c+1]:print("No")
else:print("Yes")

Submission status: Wrong Answer

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

if S.count("##")!=0:print("No");exit()
if c>d:
    if S.count("...")!=0 or S[b+1]!="#":
        print("Yes")
    else:print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

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

if S.count("##")!=0:print("No");exit()
if c>d:
    if S.count("...")!=0:print("Yes")
    else:print("No")
    exit()
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(len(s)-1):
        if i<d and s[i]=="#" and s[i+1]=="#":
            print("No")
            break
    else:
        print('Yes')

else:
    maxi=10**7
    for i in range(len(s)-1):
        if i>a and s[i]=="#" and s[i+1]=="#":
            maxi=i
            break
    
    for i in range(b,min(maxi-2,len(s)-2)):
        if s[i]=="." and s[i]==s[i+1]==s[i+2]:
            print("Yes")
            break
    else:
        print("No")

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(len(s)-1):
        if i<d and s[i]=="#" and s[i+1]=="#":
            print("No")
            break
    else:
        print('Yes')

else:
    maxi=10**7
    for i in range(len(s)-1):
        if i<d and s[i]=="#" and s[i+1]=="#":
            maxi=i
            break
    
    for i in range(min(maxi-2,len(s)-2)):
        if s[i]=="." and s[i]==s[i+1]==s[i+2]:
            print("Yes")
            break
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = list(input())
able = [0]*n
for j in range(n):
    if s[j]=='#':
        able[j] = -1
        
if d<c:
    flag3 =  False
    for i in range(b,d):
        if s[i]=='.':
            if s[i-1]=='.':
                if s[i+1]=='.':
                    flag3 = True
                    
    if not flag3:
        print('No')
    else: 
        flag =True
        for i in range(b-1,d-1):
            if s[i]=="#" and s[i+1]=="#":
                flag = False

        for i in range(a-1,c-1):
            if s[i]=="#" and s[i+1]=="#":
                flag = False

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

else:
    flag =True
    for i in range(b-1,d-1):
        if s[i]=="#" and s[i+1]=="#":
            flag = False
        
    for i in range(a-1,c-1):
        if s[i]=="#" and s[i+1]=="#":
            flag = False

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = list(input())
able = [0]*n

for j in range(n):
    if s[j]=='#':
        able[j] = -1
        
        
                
if d<c:
    flag3 =  False
    for i in range(b,d):
        if s[i]=='.':
            if s[i-1]=='.':
                if s[i+1]=='.':
                    flag3 = True
                    
    if not flag3:
        print('No')
    else: 
        smx = max(a,b)-1
        gmx = max(c,d)-1
        able[smx] = 1
        for i in range(smx,gmx+1):
            if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
                able[i] = 1

        smn = min(a,b)-1
        gmn = min(c,d)-1
        able[smn] = 1
        for i in range(smn,gmn+1):
            if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
                able[i] = 1

        if able[gmx]==1 and able[gmn]==1:
            print('Yes')
        else:
            print('No')
else:
    smx = max(a,b)-1
    gmx = max(c,d)-1
    able[smx] = 1
    for i in range(smx,gmx+1):
        if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
            able[i] = 1
            
    smn = min(a,b)-1
    gmn = min(c,d)-1
    able[smn] = 1
    for i in range(smn,gmn+1):
        if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
            able[i] = 1

    if able[gmx]==1 and able[gmn]==1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = list(input())
flag3 =  False
able = [0]*n
for i in range(max(a,b),min(c,d)-2):
    if s[i]=='.':
        if s[i+1]=='.':
            if s[i+2]=='.':
                flag3 = True
            else:
                if i+3<min(c,d) and s[i+3]=='.':
                    flag3 = True
        else:
            if i+3<min(c,d) and s[i+2]=='.' and s[i+3]=='.':
                flag3 = True
                
for j in range(n):
    if s[j]=='#':
        able[j] = -1
        
        
                
if (a<b and d<c) or (b<a and c<d):
    if not flag3:
        print('No')
    else: 
        smx = max(a,b)-1
        gmx = max(c,d)-1
        able[smx] = 1
        for i in range(smx,gmx+1):
            if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
                able[i] = 1

        smn = min(a,b)-1
        gmn = min(c,d)-1
        able[smn] = 1
        for i in range(smn,gmn+1):
            if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
                able[i] = 1

        if able[gmx]==1 and able[gmn]==1:
            print('Yes')
        else:
            print('No')
else:
    smx = max(a,b)-1
    gmx = max(c,d)-1
    able[smx] = 1
    for i in range(smx,gmx+1):
        if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
            able[i] = 1
            
    smn = min(a,b)-1
    gmn = min(c,d)-1
    able[smn] = 1
    for i in range(smn,gmn+1):
        if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
            able[i] = 1

    if able[gmx]==1 and able[gmn]==1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = list(input())
flag3 =  False
able = [0]*n
for i in range(1,min(c,d)):
    if s[i]=='.':
        if s[i-1]=='.':
            if s[i+1]=='.':
                flag3 = True
            else:
                if i+2<min(c,d) and s[i+2]=='.':
                    flag3 = True

for j in range(n):
    if s[j]=='#':
        able[j] = -1
        
        
                
if (a<b and d<c) or (b<a and c<d):
    if not flag3:
        print('No')
    else: 
        smx = max(a,b)-1
        gmx = max(c,d)-1
        able[smx] = 1
        for i in range(smx,gmx+1):
            if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
                able[i] = 1

        smn = min(a,b)-1
        gmn = min(c,d)-1
        able[smn] = 1
        for i in range(smn,gmn+1):
            if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
                able[i] = 1

        if able[gmx]==1 and able[gmn]==1:
            print('Yes')
        else:
            print('No')
else:
    smx = max(a,b)-1
    gmx = max(c,d)-1
    able[smx] = 1
    for i in range(smx,gmx+1):
        if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
            able[i] = 1
            
    smn = min(a,b)-1
    gmn = min(c,d)-1
    able[smn] = 1
    for i in range(smn,gmn+1):
        if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
            able[i] = 1

    if able[gmx]==1 and able[gmn]==1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = list(input())
flag3 =  False
able = [0]*n
for i in range(1,min(c,d)):
    if s[i]=='.':
        if s[i-1]=='.':
            if s[i+1]=='.':
                flag3 = True

for j in range(n):
    if s[j]=='#':
        able[j] = -1
        
        
                
if (a<b and d<c) or (b<a and c<d):
    if not flag3:
        print('No')
    else: 
        smx = max(a,b)-1
        gmx = max(c,d)-1
        able[smx] = 1
        for i in range(smx,gmx+1):
            if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
                able[i] = 1

        smn = min(a,b)-1
        gmn = min(c,d)-1
        able[smn] = 1
        for i in range(smn,gmn+1):
            if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
                able[i] = 1

        if able[gmx]==1 and able[gmn]==1:
            print('Yes')
        else:
            print('No')
else:
    smx = max(a,b)-1
    gmx = max(c,d)-1
    able[smx] = 1
    for i in range(smx,gmx+1):
        if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
            able[i] = 1
            
    smn = min(a,b)-1
    gmn = min(c,d)-1
    able[smn] = 1
    for i in range(smn,gmn+1):
        if (able[i-1]==1 or able[i-2]==1) and s[i]!="#":
            able[i] = 1

    if able[gmx]==1 and able[gmn]==1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

def solve(E, x, y, G):
    if y != -1:
        E[y-1] = '#'
    dp = [0]*N
    dp[x-1] = 1
    for i in range(2, N):
        if dp[i-2] or dp[i-1]:
            if E[i] == '.':
                dp[i] = 1
    # print(dp)
    return dp[G-1]

if C < D:
    p = solve(S, B, -1, D)
    q = solve(S, A, -1, C)
else:
    bla = 0
    idx = -1
    for i in range(B-1, N):
        if S[i] == '.':
            bla += 1
        else:
            bla = 0
        if bla == 3:
            idx = i
            break
    # print(idx)
    if idx == -1:
        print('No')
        exit()
    else:
        if D - 1 <= idx - 2:
            print('No')
            exit()

    p = solve(S, A, -1, C)
    q = solve(S, B, -1, D)
    # print(p, q)

if p and q:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

def solve(E, x, y, G):
    if y != -1:
        E[y-1] = '#'
    dp = [0]*N
    dp[x-1] = 1
    for i in range(2, N):
        if dp[i-2] or dp[i-1]:
            if E[i] == '.':
                dp[i] = 1
    # print(dp)
    return dp[G-1]

if C < D:
    p = solve(S, B, -1, D)
    q = solve(S, A, -1, C)
else:
    bla = 0
    idx = -1
    for i in range(B-1, N):
        if S[i] == '.':
            bla += 1
        else:
            bla = 0
        if bla == 3:
            idx = i
            break
    # print(idx)
    if idx == -1:
        print('No')
        exit()
    else:
        if D <= idx - 2:
            print('No')
            exit()

    p = solve(S, A, -1, C)
    q = solve(S, B, -1, D)
    # print(p, q)

if p and q:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

def solve(E, x, y, G):
    if y != -1:
        E[y-1] = '#'
    dp = [0]*N
    dp[x-1] = 1
    for i in range(2, N):
        if dp[i-2] or dp[i-1]:
            if E[i] == '.':
                dp[i] = 1
    # print(dp)
    return dp[G-1]

if C < D:
    p = solve(S, B, -1, D)
    q = solve(S, A, -1, C)
else:
    bla = 0
    idx = -1
    for i in range(B-1, N):
        if S[i] == '.':
            bla += 1
        else:
            bla = 0
        if bla == 3:
            idx = i
            break
    # print(idx)
    if idx == -1:
        print('No')
        exit()
    else:
        if D == idx - 2:
            print('No')
            exit()

    p = solve(S, A, -1, C)
    q = solve(S, B, -1, D)
    # print(p, q)

if p and q:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

def solve(E, x, y, G):
    if y != -1:
        E[y-1] = '#'
    dp = [0]*N
    dp[x-1] = 1
    for i in range(2, N):
        if dp[i-2] or dp[i-1]:
            if E[i] == '.':
                dp[i] = 1
    # print(dp)
    return dp[G-1]

if C < D:
    p = solve(S, B, -1, D)
    q = solve(S, A, -1, C)
else:
    bla = 0
    idx = -1
    for i in range(B-1, N):
        if S[i] == '.':
            bla += 1
        else:
            bla = 0
        if bla == 3:
            idx = i
            break
    # print(idx)
    if idx == -1:
        print('No')
        exit()
    else:
        if D == idx - 2:
            print('No')
            exit()
    p = solve(S, A, -1, C)
    q = solve(S, B, -1, D)
    print(p, q)

if p and q:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

def solve(E, x, y, G):
    if y != -1:
        E[y-1] = '#'
    dp = [0]*N
    dp[x-1] = 1
    for i in range(2, N):
        if dp[i-2] or dp[i-1]:
            if E[i] == '.':
                dp[i] = 1
    # print(dp)
    return dp[G-1]

if C < D:
    p = solve(S, B, -1, D)
    q = solve(S, A, -1, C)
else:
    bla = 0
    idx = -1
    for i in range(B-1, D):
        # print(S[i])
        if S[i] == '.':
            bla += 1
        else:
            bla = 0
        if bla == 3:
            idx = i-2
            break
    # print(idx)
    if idx == -1:
        print('No')
        exit()
    p = solve(S, A, -1, C)
    q = solve(S, B, -1, D)
    # print(p, q)

if p and q:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

def solve(E, x, y, G):
    if y != -1:
        E[y-1] = '#'
    dp = [0]*N
    dp[x-1] = 1
    for i in range(2, N):
        if dp[i-2] or dp[i-1]:
            if E[i] == '.':
                dp[i] = 1

    return dp[G-1]

if C < D:
    p = solve(S, B, -1, D)
    q = solve(S, A, -1, C)
else:
    p = solve(S, A, B, C)
    q = solve(S, B, -1, D)

if p and q:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if c<d:
    if s[min(a,b)-1:d+1].count("##")==0:
        print("Yes")
    else:
        print("No")
else:
    if s[min(a,b)-1:d+1].count("##")==0:
        if s[max(a,b)-1:d+1].count("...")==0:
            print("No")
        else:

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

Submission status: Wrong Answer

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

if c<d:
    if s[min(a,b)-1:c+1].count("##")==0:
        print("Yes")
    else:
        print("No")
else:
    if s[min(a,b)-1:d+1].count("##")==0:
        if s[min(a,b)-1:d+1].count("...")==0:
            print("No")
        else:

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

Submission status: Wrong Answer

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

if c<d:
    if s[min(a,b)-1:c+1].count("##")==0:
        print("Yes")
    else:
        print("No")
else:
    if s[min(a,b)-1:d+1].count("##")==0:
        if s[max(a,b)-1:d+1].count("...")==0:
            print("No")
        else:

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

Submission status: Wrong Answer

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

if c<d:
    if s[min(a,b):c+1].count("##")==0:
        print("Yes")
    else:
        print("No")
else:
    if s[min(a,b):d+1].count("##")==0:
        if s[max(a,b):d+1].count("...")==0:
            print("No")
        else:

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

Submission status: Wrong Answer

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

if c<d:
    if s[0:c].count("##")==0:
        print("Yes")
    else:
        print("No")
else:
    if s[0:d].count("##")==0:
        if s[0:d].count("...")==0:
            print("No")
        else:

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

Submission status: Wrong Answer

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

if c<d:
    if s[0:c+1].count("##")==0:
        print("Yes")
    else:
        print("No")
else:
    if s[0:d+1].count("##")==0:
        if s[0:d+1].count("...")==0:
            print("No")
        else:

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

Submission status: Wrong Answer

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

if c<d:
    if s[0:c].count("##")==0:
        print("Yes")
    else:
        print("No")
else:
    if s[0:d].count("##")==0:
        if s[0:c].count("...")==0:
            print("No")
        else:

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

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    absolute = set()
    cnt_rock = 0
    for i in range(a, d):
        if s[i] == "#":
            if s[i + 1] == "#":
                print("No")
                exit()

            if b <= i:
                cnt_rock += 1
                if i - 1 != b - 1:
                    absolute.add(i - 1)
                if i + 1 != d - 1:
                    absolute.add(i + 1)

    if c < d:
        print("Yes")
    else:
        dist_f = d - b - 1
        dist_f -= cnt_rock + len(absolute)
        if dist_f == 0:
            print("No")
        else:
            print("Yes")


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    absolute = set()
    cnt_rock = 0
    for i in range(a, n):
        if s[i] == "#":
            if s[i + 1] == "#":
                print("No")
                exit()

            if b <= i:
                cnt_rock += 1
                if i - 1 != b - 1:
                    absolute.add(i - 1)
                if i + 1 != d - 1:
                    absolute.add(i + 1)

    if c < d:
        print("Yes")
    else:
        dist_f = d - b - 1
        dist_f -= cnt_rock + len(absolute)
        if dist_f == 0:
            print("No")
        else:
            print("Yes")


if __name__ == '__main__':
    resolve()

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

# 2個以上の岩があればNG
if "##" in s[a:max(c,d)]:
    print("No")
    exit()

# AがBを抜けるかどうか
if d < c and not "..." in s[b-1:d]:
    print("No")
    exit()

print("Yes")

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

# 2個以上の岩があればNG
if "##" in s[a:max(c,d)]:
    print("No")
    exit()

# AがBを抜けるかどうか
if d < c and not "..." in s[b:c]:
    print("No")
    exit()

print("Yes")

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

# 2個以上の岩があればNG
if "##" in s[a:max(c,d)]:
    print("No")
    exit()

# AがBを抜けるかどうか
if d < c and not "..." in s[a:c]:
    print("No")
    exit()

print("Yes")

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

# 2個以上の岩があればNG
if "##" in s[a:]:
    print("No")
    exit()

# AがBを抜けるかどうか
if d < c and not "..." in s[a:]:
    print("No")
    exit()

print("Yes")

Submission status: Wrong Answer

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

if "##" in s[a:]:
    print("No")
    exit()

if d < c and not "..." in s[a:]:
    print("No")
    exit()

print("Yes")

Submission status: Wrong Answer

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

if "##" in s[a:]:
    print("No")
    exit()

if d < c and not "..." in s[b:]:
    print("No")
    exit()

print("Yes")

Submission status: Wrong Answer

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

if "##" in s:
    print("No")
    exit()

if d < c and not "..." in s:
    print("No")
    exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = '.'+input()
i=a
f = True
while i<c:
    if s[i+1]=='.':
        i += 1
    elif i<c-1 and s[i+2]=='.':
        i += 2
    else:
        f = False
        break
i = b
ok = False
while i<d:
    if s[i-1:i+2]=='...':
        ok = True
    if s[i+1]=='.':
        i += 1
    elif i<d-1 and s[i+2]=='.':
        i += 2
    else:
        f = False
        break
if d<c and not ok:f=False
print('Yes' if f else 'No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = '.'+input()
i=a
f = True
while i<c:
    if s[i+1]=='.':
        i += 1
    elif i<c-1 and s[i+2]=='.':
        i += 2
    else:
        f = False
        break
i = b
ok = False
while i<d:
    if s[i-1:i+2]=='...':
        ok = True
    if s[i+1]=='.':
        i += 1
    elif i<d-1 and s[i+2]=='.':
        i += 2
    else:
        f = False
        break
if d<c and not ok:f=False
print('Yes' if f else 'No')

Submission status: Wrong Answer

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

i=a
f = True
while i<c:
    if s[i+1]=='.':
        i += 1
    elif i<c-1 and s[i+2]=='.':
        i += 2
    else:
        f = False
        break
i = b
ok = False
while i<d:
    if s[i-1]=='.' and s[i+1]=='.':
        ok = True
    if s[i+1]=='.':
        i += 1
    elif i<d-1 and s[i+2]=='.':
        i += 2
    else:
        f = False
        break
if d<c and not ok:f=False
print('Yes' if f else 'No')