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_start,b_start,a_goal,b_goal = map(int,input().split())
s = input()

no_rock_double = True
for i in range(a_start, b_goal):
    if i < n:
        if s[i] == '#' and s[i+1] == '#':
            no_rock_double = False
can_switch = False
if a_goal > b_goal:
    for i in range(a_start, b_goal-1):
        if i + 1 < n:
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
                can_switch = True
if a_goal > b_goal:
    if no_rock_double and can_switch:
        print('Yes')
    else:
        print('No')
else:
    if no_rock_double:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a_start,b_start,a_goal,b_goal = map(int,input().split())
s = input()

no_rock_double = True
for i in range(a_start, b_goal):
    if i < n:
        if s[i] == '#' and s[i+1] == '#':
            rock_double = False
can_switch = False
if a_goal > b_goal:
    for i in range(a_start, b_goal-1):
        if i + 1 < n:
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
                can_switch = True
if a_goal > b_goal:
    if no_rock_double and can_switch:
        print('Yes')
    else:
        print('No')
else:
    if no_rock_double:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, input().split())
s = input()
count1, count2 = 0, 0
status:bool = False
if c > d and a < b:
    s = s[:d-1] + '#' + s[d:]
elif d > c and b < a:
    s = s[:c-1] + '#' + s[c:]
    
for i in range(min(a-1, b-1), max(c, d)):
    if count1 == 3:
        status = True
        
    if count2 == 2:
        if status == True:
            print('Yes')
        else:
            print('No')
        sys.exit()
    elif s[i] == '#':
        count2 += 1
        count1 = 0
    elif s[i] == '.':
        count1 += 1
        count2 = 0
    
        
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, input().split())
s = input()
count1, count2 = 0, 0
status:bool = False
if c > d:
    s = s[:d-1] + '#' + s[d:]

for i in range(min(a-1, b-1), max(c, d)):
    if count1 == 3:
        status = True
        
    if count2 == 2:
        if status == True and i == c-2:
            print('Yes')
        else:
            print('No')
        sys.exit()
    elif s[i] == '#':
        count2 += 1
        count1 = 0
    elif s[i] == '.':
        count1 += 1
        count2 = 0
    
        
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, input().split())
s = input()
count1, count2 = 0, 0
status:bool = False
if c > d:
    s = s[:d-1] + '#' + s[d:]

for i in range(min(a-1, b-1), max(c, d)):
    if count1 == 3:
        status = True
        
    if count2 == 2:
        if status == True:
            print('Yes')
        else:
            print('No')
        sys.exit()
    elif s[i] == '#':
        count2 += 1
        count1 = 0
    elif s[i] == '.':
        count1 += 1
        count2 = 0
    
        
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, input().split())
s = input()
count1, count2 = 0, 0
status:bool = False
if c > d:
    s = s[:d-1] + '#' + s[d:]

for i in range(a-1, c):
    if count1 == 3:
        status = True
        
    if count2 == 2:
        if status == True and i == c-2:
            print('Yes')
        else:
            print('No')
        sys.exit()
    elif s[i] == '#':
        count2 += 1
        count1 = 0
    elif s[i] == '.':
        count1 += 1
        count2 = 0
    
        
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, input().split())
s = input()
count1, count2 = 0, 0
status:bool = False
if c > d:
    s = s[:d-1] + '#' + s[d:]

for i in range(a-1, c):
    if count1 == 3:
        status = True
        
    if count2 == 2:
        if status == True:
            print('Yes')
        else:
            print('No')
        sys.exit()
    elif s[i] == '#':
        count2 += 1
        count1 = 0
    elif s[i] == '.':
        count1 += 1
        count2 = 0
    
        
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, input().split())
s = input()
if c > d:
    s = s[:d-1] + '#' + s[d:]
count1, count2 = 0, 0
for i in range(a-1, c):
    if count1 == 3:
        print('Yes')
        sys.exit()
    elif count2 == 2:
        print('No')
        sys.exit()
    elif s[i] == '#':
        count2 += 1
        count1 = 0
    elif s[i] == '.':
        count1 += 1
        count2 = 0
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, input().split())
s = input()
if c > d:
    s = s[:d-1] + '#' + s[d:]
count = 0
for i in range(a-1, c-1):
    if count == 3:
        print ('Yes')
        sys.exit()
    elif s[i] == '#' and s[i+1] == '#':
        print('No')
        sys.exit()
    elif s[i] == '.':
        count += 1
    elif s[i] == '#':
        count = 0
print('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')
    exit()

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

if '...' in s[b-1:c]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, a, b, c, d = map(int, input().split())
s = input()
if c < d:
    print("YNeos"[sum(s[i:i + 2] == "##" for i in range(a, d - 1)) > 0::2])
else:
    if any(s[i:i + 3] == "..." for i in range(b - 1, d - 1)):
        if all(s[i:+2] != "##" for i in range(a, c - 1)):
            print("Yes")
            exit()
    print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, a, b, c, d = map(int, input().split())
s = input()
if c < d:
    print("YNeos"[sum(s[i:i + 2] == "##" for i in range(a, d - 1)) > 0::2])
else:
    if any(s[i:i + 3] == "..." for i in range(a, d - 1)):
        if all(s[i:+2] != "##" for i in range(a, c - 1)):
            print("Yes")
            exit()
    print("No")

Submission status: Wrong Answer

Solution code:
import copy
def main():
    n, a, b, c, d = map(int, input().split())
    step = list(input())

    sn = a - 1
    fn = b - 1

    sn_goal = False
    fn_goal = False
    jump = -1
    
    while True:
        if fn == d - 1:
            fn_goal = True
            break

        if step[fn + 1] == ".":
            fn += 1
        elif step[fn + 2] == ".":
            fn += 2
        else:
            break

        if d < c:
            if (step[fn - 1] == ".") and (step[fn + 1] == "."):
                    jump = copy.deepcopy(fn)

    if d < c:
        if jump == -1 or fn_goal == False:
            print("No")
            exit()

        step[jump] = "#"

    while True:
        if sn == c - 1:
            sn_goal = True
            break

        if step[sn + 1] == ".":
            sn += 1
        elif step[sn + 2] == ".":
            sn += 2
        else:
            break
    
    if sn_goal and fn_goal:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import copy
def main():
    n, a, b, c, d = map(int, input().split())
    step = list(input())

    sn = a - 1
    fn = b - 1

    sn_goal = False
    fn_goal = False
    jump = -1
    
    while True:
        if fn == d - 1:
            fn_goal = True
            break

        if step[fn + 1] == ".":
            fn += 1
        elif step[fn + 2] == ".":
            fn += 2
        else:
            break

        if d < c:
            if (fn >= 1 and step[fn - 1] == ".") and (fn < len(step) and step[fn + 1] == "."):
                    jump = copy.deepcopy(fn)

    if d < c:
        if jump == -1:
            print("No")
            exit()

        step[jump] = "#"

    while True:
        if sn == c - 1:
            sn_goal = True
            break

        if step[sn + 1] == ".":
            sn += 1
        elif step[sn + 2] == ".":
            sn += 2
        else:
            break
    
    if sn_goal and fn_goal:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import copy
def main():
    n, a, b, c, d = map(int, input().split())
    step = list(input())

    sn = a - 1
    fn = b - 1

    sn_goal = False
    fn_goal = False
    jump = -1
    
    while True:
        if fn == d - 1:
            fn_goal = True
            break

        if step[fn + 1] == ".":
            fn += 1
            if d < c:
                if (step[fn - 1] == ".") and (step[fn + 1] == "."):
                    jump = copy.deepcopy(fn)
        elif step[fn + 2] == ".":
            fn += 2
            if d < c:
                if (step[fn - 1] == ".") and (step[fn + 1] == "."):
                    jump = copy.deepcopy(fn)
        else:
            break

    if d < c:
        if jump == -1:
            print("No")
            exit()

        step[jump] = "#"

    while True:
        if sn == c - 1:
            sn_goal = True
            break

        if step[sn + 1] == ".":
            sn += 1
        elif step[sn + 2] == ".":
            sn += 2
        else:
            break
    
    if sn_goal and fn_goal:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import copy
def main():
    n, a, b, c, d = map(int, input().split())
    step = list(input())

    sn = a - 1
    fn = b - 1

    sn_goal = False
    fn_goal = False
    jump = -1
    
    while True:
        if fn == d - 1:
            fn_goal = True
            break

        if step[fn + 1] == ".":
            fn += 1
        elif step[fn + 2] == ".":
            fn += 2
        else:
            break

        if c > d:
            if step[fn - 1] == "." and step[fn + 1] == ".":
                    jump = copy.deepcopy(fn)

    if c > d:
        if jump == -1:
            print("No")
            exit()

        step[jump] = "#"

    while True:
        if sn == c - 1:
            sn_goal = True
            break

        if step[sn + 1] == ".":
            sn += 1
        elif step[sn + 2] == ".":
            sn += 2
        else:
            break
    
    if sn_goal and fn_goal:
        print("Yes")
    else:
        print("No")
        
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if C <= D:
    sunuke = S[A:C]
    funuke = S[B:D]
    if sunuke not in '##' and funuke not in '##':
        print('Yes')
    else:
        print('No')
else:
    sunuke = S[A:C]
    funuke = S[B:D]
    if funuke in '...':
        print('No')
    else:
        if sunuke not in '##':
            print('Yes')
        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
s = input()
for i in range(a,c+1):
    if s[i] == "#":
        if s[i-1] == "#":
            print("No")
            exit()
for i in range(b,d+1):
    if s[i] == "#":
        if s[i-1] == "#":
            print("No")
            exit()
if (a > b and c > d) or (a < b and c < d):
    print("Yes")
else:
    for i in range(max(a,b),min(c,d)+1-2):
        if i == b:
            if s[i-1] == "." and s[i+1] == ".":
                break
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            break
    else:
        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
s = input()
for i in range(a,c+1):
    if s[i] == "#":
        if s[i-1] == "#":
            print("No")
            exit()
for i in range(b,d+1):
    if s[i] == "#":
        if s[i-1] == "#":
            print("No")
            exit()
if (a > b and c > d) or (a < b and c < d):
    print("Yes")
else:
    for i in range(max(a,b),min(c,d)+1-2):
        if (s[i] == "." or i == b) and s[i+1] == "." and s[i+2] == ".":
            break
    else:
        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
s = input()
for i in range(a,c+1):
    if s[i] == "#":
        if s[i-1] == "#":
            print("No")
            exit()
for i in range(b,d+1):
    if s[i] == "#":
        if s[i-1] == "#":
            print("No")
            exit()
if (a > b and c > d) or (a < b and c < d):
    print("Yes")
else:
    for i in range(max(a,b),min(c,d)+1-2):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            break
    else:
        print("No")
        exit()
    print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if c<d:
    for i in range(a,d-2):
        if s[i]=="#" and s[i+1]=="#":
            print("No")
            exit()
    print("Yes")
else:
    for i in range(a,c-2):
        if s[i]=="#" and s[i+1]=="#":
            print("No")
            exit()
    i=b-1
    temp=0
    while i<=d-1:
        if s[i]==".": temp+=1
        else: temp=0
        if temp==3:
            print("Yes")
            exit()
        i+=1
    print("No")

Submission status: Wrong Answer

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

X=[0]*(N+1)
Y=[0]*(N+1)

for k in range(1,N+1):
    if S[k]=="#":
        X[k]=X[k-1]+1
    else:
        Y[k]=Y[k-1]+1

if max(X[A:max(C,D)+1])>=2:
    print("No")
else:
    if C<D:
        print("Yes")
    elif C>D and max(Y[B-1:min(N+1,D+2)])>=3:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

X=[0]*(N+1)
Y=[0]*(N+1)

for k in range(1,N+1):
    if S[k]=="#":
        X[k]=X[k-1]+1
    else:
        Y[k]=Y[k-1]+1

if max(X[A:max(C,D)+1])>=2:
    print("No")
else:
    if C<D:
        print("Yes")
    elif C>D and max(Y[B-1:D+1])>=3:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

X=[0]*(N+1)
Y=[0]*(N+1)

for k in range(1,N+1):
    if S[k]=="#":
        X[k]=X[k-1]+1
    else:
        Y[k]=Y[k-1]+1

if max(X[A:max(C,D)+1])>=2:
    print("No")
else:
    if C<D:
        print("Yes")
    elif C>D and max(Y[B:D+1])>=3:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

X=[0]*(N+1)
Y=[0]*(N+1)

for k in range(1,N+1):
    if S[k]=="#":
        X[k]=X[k-1]+1
    else:
        Y[k]=Y[k-1]+1

if max(X[A:max(C,D)+1])>=3:
    print("No")
else:
    if C<D:
        print("Yes")
    elif C>D and max(Y[B:D+1])>=3:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

overtakeFlag = False
if C > D:
    for i in range(B, D+1):
        if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
            print("Yes")
            exit()
else:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

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

massesExist = True
overtakeFlag = False if C > D else True
proceedableFlag = True

if max(A, B, C, D) >= N:
    massesExist = False

for i in range(B, D):
    if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
        overtakeFlag = True

for i in range(A, max(C, D)-1):
    if S[i]=="#" and S[i+1]=="#":
        proceedableFlag = False

if overtakeFlag and proceedableFlag and massesExist:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

massesExist = True
overtakeFlag = False if C > D else True
proceedableFlag = True

if max(A, B, C, D) > N:
    massesExist = False

for i in range(B, D):
    if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
        overtakeFlag = True

for i in range(A, max(C, D)-1):
    if S[i]=="#" and S[i+1]=="#":
        proceedableFlag = False

if overtakeFlag and proceedableFlag and massesExist:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

massesExist = True
overtakeFlag = False if C > D else True
proceedableFlag = True

if max(A, B, C, D) > N:
    massesExist = False

for i in range(B, D-1):
    if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
        overtakeFlag = True

for i in range(B, max(C, D)-1):
    if S[i]=="#" and S[i+1]=="#":
        proceedableFlag = False

if overtakeFlag and proceedableFlag and massesExist:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

massesExist = True
overtakeFlag = False if C > D else True
proceedableFlag = True

if max(A, B, C, D) > N:
    massesExist = False

for i in range(B, D-1):
    if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
        overtakeFlag = True

for i in range(A, max(C, D)-1):
    if S[i]=="#" and S[i+1]=="#":
        proceedableFlag = False

if overtakeFlag and proceedableFlag and massesExist:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

overtakeFlag = False if C > D else True
proceedableFlag = True
for i in range(B, D-1):
    if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
        overtakeFlag = True



for i in range(A, max(C, D)-1):
    if S[i]=="#" and S[i+1]=="#":
        proceedableFlag = False

if overtakeFlag and proceedableFlag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

overtakeFlag = False if C > D else True
proceedableFlag = True
for i in range(B, D-1):
    if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
        overtakeFlag = True



for i in range(A, max(C, D)-2):
    if S[i]=="#" and S[i+1]=="#":
        proceedableFlag = False

if overtakeFlag and proceedableFlag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

overtakeFlag = False if C > D else True
proceedableFlag = True
for i in range(max(B-1, 0), D-1):
    if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
        overtakeFlag = True

for i in range(A, max(C, D)-2):
    if S[i]=="#" and S[i+1]=="#":
        proceedableFlag = False

if overtakeFlag and proceedableFlag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

overtakeFlag = False if C > D else True
proceedableFlag = True
for i in range(max(B-1, 0), D-1):
    if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
        overtakeFlag = True

for i in range(A, max(C, D)-1):
    if S[i]=="#" and S[i+1]=="#":
        proceedableFlag = False

if overtakeFlag and proceedableFlag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

overtakeFlag = False if C > D else True
proceedableFlag = True
for i in range(max(B-1, 0), D-1):
    if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
        overtakeFlag = True

for i in range(A, max(C, D)-1):
    if S[i]=="#" and S[i+1]=="#":
        proceedableFlag = True

if overtakeFlag and proceedableFlag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

ans='Yes'
if '##'in S[A-1:C]:
    ans='No'
elif '##'in S[B-1:D]:
    ans='No'
elif C>D and ('...'not in S[B-2:D] and S[D]=='#'):
    ans='No'

print(ans)

Submission status: Wrong Answer

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

ans='Yes'
if '##'in S[A-1:C]:
    ans='No'
elif '##'in S[B-1:D]:
    ans='No'
elif C>D and ('...'not in S[B-2:D]):
    ans='No'

print(ans)

Submission status: Wrong Answer

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

ans='Yes'
if '##'in S[A-1:C]:
    ans='No'
elif '##'in S[B-1:D]:
    ans='No'
elif C>D and ('...'not in S[B:D]):
    ans='No'

print(ans)

Submission status: Wrong Answer

Solution code:
print('Yes')

Submission status: Wrong Answer

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

ans='Yes'
if '##'in S[A-1:C]:
    ans='No'
elif '##'in S[B-1:D]:
    ans='No'
elif C>D and ('...'not in S[B-1:D]):
    ans='No'

print(ans)

Submission status: Wrong Answer

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

def solve():
    for i in range(A, C-3):
        if S[i:i+2] == "##":
            print("No")
            return
    for i in range(B, D-3):
        if S[i:i+2] == "##":
            print("No")
            return

    if C > D:
        for i in range(B-2, D-2):
            if S[i:i+3] == "...":
                print("Yes")
                return
        else:
            print("No")
            
    else:
        print("Yes")

solve()

Submission status: Wrong Answer

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

def solve():
    for i in range(A, C-2):
        if S[i:i+2] == "##":
            print("No")
            return
    for i in range(B, D-2):
        if S[i:i+2] == "##":
            print("No")
            return

    if C > D:
        for i in range(B-2, D-2):
            if S[i:i+3] == "...":
                print("Yes")
                return
        else:
            print("No")
            
    else:
        print("Yes")

solve()

Submission status: Wrong Answer

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

def solve():
    for i in range(A, C-2):
        if S[i:i+2] == "##":
            print("No")
            return
    for i in range(B, D-2):
        if S[i:i+2] == "##":
            print("No")
            return

    if C > D:
        for i in range(B-1, D-3):
            if S[i:i+3] == "...":
                print("Yes")
                return
        else:
            print("No")
            
    else:
        print("Yes")

solve()

Submission status: Wrong Answer

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

def solve():
    for i in range(A, C-2):
        if S[i:i+2] == "##":
            print("No")
            return
    for i in range(B, D-2):
        if S[i:i+2] == "##":
            print("No")
            return

    if C > D:
        for i in range(B-1, D-2):
            if S[i:i+3] == "...":
                print("Yes")
                return
        else:
            print("No")
            
    else:
        print("Yes")

solve()

Submission status: Wrong Answer

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

def solve():
    for i in range(A, C):
        if S[i:i+2] == "##":
            print("No")
            return
    for i in range(B, D):
        if S[i:i+2] == "##":
            print("No")
            return

    if C > D:
        for i in range(B, D-2):
            if S[i] == S[i+1] == S[i+2] == ".":
                print("Yes")
                return
        else:
            print("No")
            
    else:
        print("Yes")

solve()

Submission status: Wrong Answer

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

def solve():
    al = 0
    ar = N-1
    bl = 0
    br = N-1
    for i in range(A-1, 0, -1):
        if S[i] == S[i-1] == "#":
            al = i+1
    for i in range(A, N-1):
        if S[i] == S[i+1] == "#":
            ar = i-1
    for i in range(B-1, 0, -1):
        if S[i] == S[i-1] == "#":
            bl = i+1
    for i in range(B, N-1):
        if S[i] == S[i+1] == "#":
            br = i-1
    
    if C-1 < al or C-1 > ar or D-1 < bl or D-1 > br:
        print("No")
        return
    
    if C > D:
        for i in range(bl, ar-2):
            if S[i] == S[i+1] == S[i+2] == ".":
                print("Yes")
                return
        else:
            print("No")
            
    else:
        print("Yes")

solve()

Submission status: Wrong Answer

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

def solve():
    al = 0
    ar = N-1
    bl = 0
    br = N-1
    for i in range(A-1, 0, -1):
        if S[i] == S[i-1] == "#":
            al = i+1
    for i in range(A, N-1):
        if S[i] == S[i+1] == "#":
            ar = i-1
    for i in range(B-1, 0, -1):
        if S[i] == S[i-1] == "#":
            bl = i+1
    for i in range(B, N-1):
        if S[i] == S[i+1] == "#":
            br = i-1
    
    if C-1 < al or C-1 > ar or D-1 < bl or D-1 > br:
        print("No")
        return
    
    if C > D:
        for i in range(max(al, bl), min(ar, br)-2):
            if S[i] == S[i+1] == S[i+2] == ".":
                print("Yes")
                return
        else:
            print("No")
            
    else:
        print("Yes")

solve()

Submission status: Wrong Answer

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

if c < d and (S[a-1:d+1].count("##") == 0):
    print("Yes")
    exit()

if c > d and (S[a-1:d+1].count("...") >= 1) and (S[a-1:d+1].count("##") == 0):
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

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

if c < d and (S[a-1:d+1].count("##") == 0):
    print("Yes")
    exit()

if c > d and (S[b-1:d+1].count("...") >= 1) and (S[a-1:d+1].count("##") == 0):
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

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

if c < d and S[a:d].count("##") == 0:
    print("Yes")
    exit()

if c > d and S[b:d].count("...") >= 1 and S[a:d].count("##") == 0:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

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

if c < d and S[a:d].count("##") == 0:
    print("Yes")
    exit()

if c > d and S[b:d].count("...") >= 1 and S[a:d].count("##") == 0:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

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

T = ""
for i in range(n):
    if i == a - 1:
        T += "A"
    elif i == b - 1:
        T += "B"
    else:
        T += S[i]
# print(T)

cnt = 0
rok = 0
if c < d:
    for i in range(a, d):
        if T[i] == "#":
            rok += 1

        else:
            rok = 0

        if rok >= 2:
            print("No")
            exit()
    print("Yes")

else:
    for i in range(a, d):
        if T[i] == "#":
            cnt = 0
            rok += 1

        elif T[i] == ".":
            cnt += 1
            rok = 0

        if cnt >= 3:
            print("Yes")
            exit()

        if rok >= 2:
            print("No")
            exit()
    print("No")

Submission status: Wrong Answer

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

T = ""
for i in range(n):
    if i == a - 1:
        T += "A"
    elif i == b - 1:
        T += "B"
    else:
        T += S[i]
# print(T)

cnt = 0
rok = 0
if c < d:
    for i in range(a, d):
        if T[i] == "#":
            rok += 1

        else:
            rok = 0

        if rok >= 2:
            print("No")
            exit()
    print("Yes")

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

        elif T[i] == ".":
            cnt += 1
            rok = 0

        if cnt >= 3:
            print("Yes")
            exit()

        if rok >= 2:
            print("No")
            exit()
    print("No")

Submission status: Wrong Answer

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

T = ""
for i in range(n):
    if i == a - 1:
        T += "A"
    elif i == b - 1:
        T += "B"
    else:
        T += S[i]
# print(T)

cnt = 0
rok = 0
if c < d:
    for i in range(a, d):
        if T[i] == "#":
            rok += 1

        else:
            rok = 0

        if rok >= 2:
            print("No")
            exit()
    print("Yes")

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

        elif T[i] == ".":
            cnt += 1
        rok = 0

        if cnt >= 3:
            print("Yes")
            exit()

        if rok >= 2:
            print("No")
            exit()
    print("No")