Problem: 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.

Submission attempts (in order):
N,A,B,C,D = map(int,input().split())
S = list(input())

import sys
if B > C:
    isi = 0
    cnt = 0
    for j in range(A-1,C):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    cnt = 0
    for j in range(B-1,D):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    if isi <= 1:
        print('Yes')
    else:
        print('No')
    sys.exit()


aki = 0
isi = 0
cnt = 0
for j in range(min(A,B)-1,max(C,D)):
    i = S[j]
    if i == '.':
        cnt = 0
    elif i == '#':
        cnt += 1
        isi = max(isi,cnt)
        
cnt = 0
for j in range(B-2,D+1):
    i = S[j]
    if i == '#':
        cnt = 0
    elif i == '.':
        cnt += 1
        aki = max(aki,cnt)
        

if C > D:
    if aki >= 3 and isi <= 1:
        print('Yes')
    else:
        print('No')
else:
    if isi <= 1:
        print('Yes')
    else:
        print('No')
        
        
        


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

import sys
if B > C:
    isi = 0
    cnt = 0
    for j in range(A-1,C):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    cnt = 0
    for j in range(B-1,D):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    if isi <= 1:
        print('Yes')
    else:
        print('No')
    sys.exit()


aki = 0
isi = 0
cnt = 0
for j in range(min(A,B)-1,max(C,D)):
    i = S[j]
    if i == '.':
        cnt = 0
    elif i == '#':
        cnt += 1
        isi = max(isi,cnt)
        
cnt = 0
for j in range(B-2,max(D+1,N)):
    i = S[j]
    if i == '#':
        cnt = 0
    elif i == '.':
        cnt += 1
        aki = max(aki,cnt)
        

if C > D:
    if aki >= 3 and isi <= 1:
        print('Yes')
    else:
        print('No')
else:
    if isi <= 1:
        print('Yes')
    else:
        print('No')
        
        
        


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

import sys
if B > C:
    isi = 0
    cnt = 0
    for j in range(A-1,C):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    cnt = 0
    for j in range(B-1,D):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    if isi <= 1:
        print('Yes')
    else:
        print('No')
    sys.exit()


aki = 0
isi = 0
cnt = 0
for j in range(min(A,B)-1,max(C,D)):
    i = S[j]
    if i == '.':
        cnt = 0
    elif i == '#':
        cnt += 1
        isi = max(isi,cnt)
        
cnt = 0
for j in range(B-2,min(D+1,N)):
    i = S[j]
    if i == '#':
        cnt = 0
    elif i == '.':
        cnt += 1
        aki = max(aki,cnt)
        

if C > D:
    if aki >= 3 and isi <= 1:
        print('Yes')
    else:
        print('No')
else:
    if isi <= 1:
        print('Yes')
    else:
        print('No')
        
        
        


Verdicts: Runtime Error

Runtime Error

Accepted