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())
a-=1
b-=1
c-=1
d-=1

temp=str(input())
maxim=max(a,b)
if temp[maxim:].count("...")!=0 or temp[maxim+1]==temp[maxim+2]=="." or temp[maxim+1]==temp[maxim-1]==".":
    flag=1
else:
    flag=0
    
s=list(temp)
s[a]="A"
s[b]="B"
s[c]="C"
s[d]="D"

ans=1

for i in range(n-1):
    if s[i]==s[i+1]=="#":
        ans=0
        

if c<d and ans=1:
    ans=1
elif c>d and ans=1:
    if flag==1:
        ans=1
    elif s[d-1]=="#" or s[d+1]=="#":
        ans=0
    else:
        ans=1
                
if ans==1:
    print("Yes")
else:
    print("No")

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

temp=str(input())
maxim=max(a,b)
minim=min(a,b)
if temp[maxim:].count("...")!=0 or temp[maxim+1]==temp[maxim+2]=="." or temp[maxim+1]==temp[maxim-1]==".":
    flag=1
else:
    flag=0
    
s=list(temp)
s[a]="A"
s[b]="B"
s[c]="C"
s[d]="D"

mac=max(c,d)
ans=1

for i in range(minim,mac):
    if s[i]==s[i+1]=="#":
        ans=0


elif c<d and ans==1:
    ans=1
elif c>d and ans==1:
    if flag==1:
        ans=1
    elif d<=len(s)-1:
        ans=1
    elif s[d-1]=="#" or s[d+1]=="#":
        ans=0
    else:
        ans=1
                
if ans==1:
    print("Yes")
else:
    print("No")

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

temp=str(input())
maxim=max(a,b)
minim=min(a,b)
if temp[maxim:].count("...")!=0 or temp[maxim+1]==temp[maxim+2]=="." or temp[maxim+1]==temp[maxim-1]==".":
    flag=1
else:
    flag=0
    
s=list(temp)
s[a]="A"
s[b]="B"
s[c]="C"
s[d]="D"

mac=max(c,d)
ans=1

for i in range(minim,mac):
    if s[i]==s[i+1]=="#":
        ans=0


elif c<d and ans==1:
    ans=1
elif c>d and ans==1:
    if flag==1:
        ans=1
    elif d==len(s)-1:
        ans=1
    elif s[d-1]=="#" or s[d+1]=="#":
        ans=0
    else:
        ans=1
                
if ans==1:
    print("Yes")
else:
    print("No")

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

temp=str(input())
maxim=max(a,b)
minim=min(a,b)
if temp[maxim:d+2].count("...")!=0 or temp[maxim+1]==temp[maxim+2]=="." or temp[maxim+1]==temp[maxim-1]==".":
    flag=1
else:
    flag=0
    
s=list(temp)
s[a]="A"
s[b]="B"
s[c]="C"
s[d]="D"

mac=max(c,d)
ans=1

for i in range(minim,mac):
    if s[i]==s[i+1]=="#":
        ans=0

if c<d and ans==1:
    ans=1
elif c>d and ans==1:
    if flag==1:
        ans=1
    elif s[d-1]=="#" or s[d+1]=="#":
        ans=0
    else:
        ans=1
                
if ans==1:
    print("Yes")
else:
    print("No")

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted