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=list(input())
S.insert(0,"#")
S.append("#")
N+=2
A+=1
B+=1
C+=1
D+=1

L=[0]*N
c=0
d=0
for i in range(N):
    if(S[i]=="#"):
        d+=-1
        c=0
        L[i]=d
    else:
        c+=1
        d=0
        L[i]=c


if((min(L[A-1:C-1])<-1)):
    print("No")
    exit()
if((min(L[B-1:D-1])<-1)):
    print("No")
    exit()

if(C<D):
    print("Yes")
    exit()
else:
    if(max(L[B:D-1])>2):
        print("Yes")
        exit()
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
S.insert(0,"#")
S.append("#")
N+=2
A+=1
B+=1
C+=1
D+=1

L=[0]*N
c=0
d=0
for i in range(N):
    if(S[i]=="#"):
        d+=-1
        c=0
        L[i]=d
    else:
        c+=1
        d=0
        L[i]=c


if((min(L[A-1:C-1])<-1)):
    print("No")
    exit()
if((min(L[B-1:D-1])<-1)):
    print("No")
    exit()

if(C<D):
    print("Yes")
    exit()
else:
    if(max(L[B-1:D-1])>2):
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
S.insert(0,"#")
S.append("#")
N+=2
A+=1
B+=1
C+=1
D+=1

L=[0]*N
c=0
d=0
for i in range(N):
    if(S[i]=="#"):
        d+=-1
        c=0
        L[i]=d
    else:
        c+=1
        d=0
        L[i]=c


if((min(L[A-1:C-1])<-1)):
    print("No")
    exit()
if((min(L[B-1:D-1])<-1)):
    print("No")
    exit()

if(C<D):
    print("Yes")
    exit()
else:
    if(max(L[B-1:min(C-1,D-1)])>2):
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
S.insert(0,"#")
S.append("#")
N+=2
A+=1
B+=1
C+=1
D+=1

L=[0]*N
c=0
d=0
for i in range(N):
    if(S[i]=="#"):
        d+=-1
        c=0
        L[i]=d
    else:
        c+=1
        d=0
        L[i]=c


if((min(L[A-1:C-1])<-1)):
    print("No")
    exit()
if((min(L[B-1:D-1])<-1)):
    print("No")
    exit()

for i in range(0,A-1):
    L[i]=0
for i in range(C-1,N):
    L[i]=0   
    
if(C<D):
    print("Yes")
    exit()
else:
    if(max(L[B-1:C-1])>2):
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
S.insert(0,"#")
S.append("#")
N+=2
A+=1
B+=1
C+=1
D+=1

L=[0]*N
c=0
d=0
for i in range(N):
    if(S[i]=="#"):
        d+=-1
        c=0
        L[i]=d
    else:
        c+=1
        d=0
        L[i]=c

for i in range(0,A-1):
    L[i]=0
for i in range(C-1,N):
    L[i]=0   

if((min(L[A-1:C-1])<-1)):
    print("No")
    exit()
if((min(L[B-1:D-1])<-1)):
    print("No")
    exit()


if(C<D):
    print("Yes")
    exit()
else:
    if(max(L[B-1:C-1])>2):
        print("No")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
S.insert(0,"#")
S.append("#")
N=N+2
A+=1
B+=1
C+=1
D+=1

L=[0]*N
c=0
d=0
for i in range(N):
    if(S[i]=="#"):
        d+=-1
        c=0
        L[i]=d
    else:
        c+=1
        d=0
        L[i]=c

for i in range(0,A-1):
    L[i]=0
for i in range(C-1,N):
    L[i]=0   

if((min(L[A-1:C-1])<-1)):
    print("No")
    exit()
if((min(L[B-1:D-1])<-1)):
    print("No")
    exit()


if(C<D):
    print("Yes")
    exit()
else:
    if(max(L[B-1:C-1])>2):
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
S.insert(0,"#")
S.append("#")
N=N+2
A+=1
B+=1
C+=1
D+=1

L=[0]*N
c=0
d=0
for i in range(N):
    if(S[i]=="#"):
        d+=-1
        c=0
        L[i]=d
    else:
        c+=1
        d=0
        L[i]=c

for i in range(0,A-1):
    L[i]=0
for i in range(C-1,N):
    L[i]=0   

if((min(L[A-1:C-1])<-1)|(min(L[B-1:D-1])<-1)):
    print("No")
    exit()

if(C<D):
    print("Yes")
    exit()
else:
    if(max(L[B-1:N])>2):
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
S.insert(0,"#")
S.append("#")
N=N+2
A+=1
B+=1
C+=1
D+=1

L=[0]*N
c=0
d=0
for i in range(N):
    if(S[i]=="#"):
        d+=-1
        c=0
        L[i]=d
    else:
        c+=1
        d=0
        L[i]=c

c=0
if(min(L[0:(A-1)])<-1):
    for i in range(A-1,-1,-1):
        if(L[i]<-1):c=1
        if(c==1):L[i]=0

c=0
if(min(L[B-1:N])<-1):
    for i in range(B-1,N):
        if(L[i]<-1):c=1
        if(c==1):L[i]=0       

if((min(L[A-1:C-1])<-1)|(min(L[B-1:D-1])<-1)):
    print("No")
    exit()

if(C<D):
    print("Yes")
    exit()
else:
    if(max(L[B-1:N])>2):
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
S.insert(0,"#")
S.append("#")
N=N+2
A+=1
B+=1
C+=1
D+=1

L=[0]*N
c=0
d=0
for i in range(N):
    if(S[i]=="#"):
        d+=-1
        c=0
        L[i]=d
    else:
        c+=1
        d=0
        L[i]=c

c=0
if(min(L[0:(A-1)])<-1):
    for i in range(A-1,-1,-1):
        if(L[i]<-1):c=1
        if(c==1):L[i]=0

c=0
if(min(L[B-1:N])<-1):
    for i in range(B-1,N):
        if(L[i]<-1):c=1
        if(c==1):L[i]=0       

if((min(L[A-1:C-1])<-1)|(min(L[B-1:D-1])<-1)):
    print("No")
    exit()

if(C<D):
    print("Yes")
    exit()
else:
    if(max(L)>2):
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
#a-kenkenlace
n,a,b,c,d=map(int,input().split())
s=input()
s="X"+s+"X"
#i伴目からj番目までに置いて000となることがありうるかということを分析する関数
def judge1(a,b):
    flag=False
    counterx=0
    countero=0
    for i in range(a-1,b):
        if s[i]=="." and s[i-1]=="." and s[i+1]==".":
            flag=True
            break
    return flag
def judge2(a,b):
    flag=True
    for i in range(a-1,b-1):
        if s[i]=="#" and s[i+1]=="#":
            flag=False
            break
    return flag
if c<d:
    if judge2(a,c) and judge2(b,d):
        print("Yes")
    else:
        print("No")
elif d<c:
    if judge1(b,d) and judge2(a,c):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
#a-kenkenlace
n,a,b,c,d=map(int,input().split())
s=input()
#i伴目からj番目までに置いて000となることがありうるかということを分析する関数
def judge1(a,b):
    flag=False
    counterx=0
    countero=0

    for i in range(a-1,b):
        if s[i]=="#":
            counterx+=1
            countero=0
        if s[i]==".":
            countero+=1
            counterx=0
        if countero==3:
            flag=True
            break
    return flag
def judge2(a,b):
    flag=True
    for i in range(a-1,b-1):
        if s[i]=="#" and s[i+1]=="#":
            flag=False
            break
    return flag


if c<d:
    if judge2(a,c) and judge2(b,d):
        print("Yes")
    else:
        print("No")
elif d<c:
    if judge1(b,d) and judge2(a,c):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
#a-kenkenlace
n,a,b,c,d=map(int,input().split())
s=input()
#i伴目からj番目までに置いて000となることがありうるかということを分析する関数
def judge1(a,b):
    flag=False
    counterx=0
    countero=0

    for i in range(a-1,b):
        if s[i]=="#":
            counterx+=1
            countero=0
        if s[i]==".":
            countero+=1
            counterx=0
        if countero==3:
            flag=True
            break
    return flag
def judge2(a,b):
    flag=True
    for i in range(a-1,b-1):
        if s[i]=="#" and s[i+1]=="#":
            flag=False
            break
    return flag


if c<d:
    if judge2(a,d):
        print("Yes")
    else:
        print("No")
elif d<c:
    if judge1(b,d) and judge2(a,c):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
p = 0
t = 0
for i in range(max(C, D) - 1):
  if S[i:i+2] == '##':
    p = 1
for j in range(B-1, min(C, D) - 2):  
  if S[j:j+3] == '...':
    t = 1
if S[B] == '.' and S[B-2] == '.':
  t = 1
if (C < D and p == 0) or (C > D and p == 0 and t == 1):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
A = A - 1
B = B - 1
C = C - 1
D = D - 1
S = input()
if "##" in S[A:C+1] or "##" in S[B:D+1]:
    print("No")
    exit()

if  D < C and (S[D-1] == "#" or S[D+1] == "#"):
    if "..." in S[B-2:D+1]:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
A = A - 1
B = B - 1
C = C - 1
D = D - 1
S = input()
if "##" in S[A:C+1] or "##" in S[B:D+1]:
    print("No")
    exit()

if  D < C and (S[D-1] == "#" or S[D+1] == "#"):
    if "..." in S[B:D+1]:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
A = A - 1
B = B - 1
C = C - 1
D = D - 1
S = input()
if C+1 <= N and D+1 <= N and ("##" in S[A:C+1] or "##" in S[B:D+1]):
    print("No")
    exit()

if D+1<=N-1 and D < C and (S[D-1] == "#" or S[D+1] == "#"):
    if "..." in S[B:D+1]:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
A = A - 1
B = B - 1
C = C - 1
D = D - 1
S = input()
if "##" in S:
    print("No")
    exit()

if D+1<=N-1 and D < C and (S[D-1] == "#" or S[D+1] == "#"):
    if "..." in S[B:D+1]:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
A = A - 1
B = B - 1
C = C - 1
D = D - 1
S = input()
if "##" in S:
    print("No")
    exit()

if D+1<=N-1 and D < C and (S[D-1] == "#" or S[D+1] == "#"):
    if "..." in S:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
A = A - 1
B = B - 1
C = C - 1
D = D - 1
S = input()
if "##" in S:
    print("No")
    exit()
if D+1<=N-1 and (S[D-1] == "#" or S[D+1] == "#"):
    if "..." in S:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = str(input())
if "##" in s[min(a,b):max(c,d)]:
    ans = "No"
else:
    if c < d:
        ans = "Yes"
    else:
        if "..." in s[b+1:d-1]:
            ans = "Yes"
        else:
            ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = str(input())
print(s[min(a,b)+1:max(c,d)-1])
if "##" in s[min(a,b):max(c,d)]:
    ans = "No"
else:
    if c < d:
        ans = "Yes"
    else:
        if "..." in s[b+1:d-1]:
            ans = "Yes"
        else:
            ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = str(input())
if "##" in s[min(a,b):max(c,d)]:
    ans = "No"
else:
    if c < d:
        ans = "Yes"
    else:
        if "..." in s[b:d]:
            ans = "Yes"
        else:
            ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = str(input())
if "##" in s:
    ans = "No"
else:
    if c < d:
        ans = "Yes"
    else:
        if "..." in s:
            ans = "Yes"
        else:
            ans = "No"
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b,c,d = map(int,input().split()) 
    s=list(input())
    for i in range(max(c,d)-a-1):
        if s[a+i-1]=="#" and s[a+i]=="#":
            print("No")
            return
    if c<d:
        print("Yes")
        return
    else:
        for i in range(d-b):
            if s[b+i-2]==s[b+i-1] and s[b+i-1] == s[b+i] and s[b+i]==".":
                print("Yes")
                return
        print("No")
main()

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b,c,d = map(int,input().split()) 
    s=list(input())
    for i in range(max(c,d)-a-1):
        if s[a+i-1]=="#" and s[a+i]=="#":
            print("No")
            return
    if c<d:
        print("Yes")
        return
    else:
        for i in range(c-b):
            if s[b+i-2]==s[b+i-1] and s[b+i-1] == s[b+i] and s[b+i]==".":
                print("Yes")
                return
        print("No")
main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b,c,d = map(int,input().split()) 
    s=list(input())
    for i in range(max(c,d)-a-1):
        if s[a+i-1]=="#" and s[a+i]=="#":
            print("No")
            return
    if c<d:
        print("Yes")
        return
    else:
        for i in range(c-b-2):
            if s[b+i]==s[b+i+1] and s[b+i]==".":
                print("Yes")
                return
        if s[b]=="." and s[b-2]==".":
            print("Yes")
            return
        if s[d]=="." and s[d-2]==".":
            print("Yes")
            return
        print("No")
main()

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b,c,d = map(int,input().split()) 
    s=list(input())
    for i in range(max(c,d)-a-1):
        if s[a+i-1]=="#" and s[a+i]=="#":
            print("No")
            return
    if c<d:
        print("Yes")
        return
    else:
        for i in range(c-b-2):
            if s[b+i]==s[b+i+1] and s[b+i]==".":
                print("Yes")
                return
        if s[b]=="." and s[b-2]==".":
            print("Yes")
            return
        print("No")
main()

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = list(input())
t = False
if c < d:
    for i in range(a-1,d-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            break
    else:
        print('Yes')
else:
    for i in range(a-1,c-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            break
    for i in range(b-1,d-1):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            t = True
    if t:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = list(input())
t = False
if c < d:
    for i in range(a-1,d-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            break
    else:
        print('Yes')
else:
    for i in range(a-1,c-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            break
        if i == c-2 or i < b-1 or i > d-1:
            continue
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
            t = True
    if t:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = list(input())
t = False
if c < d:
    for i in range(a-1,d-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            break
    else:
        print('Yes')
else:
    for i in range(a-1,c-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            break
        if i == c-2:
            continue
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' and i+2 <= b-1 and i >= d-1:
            t = True
    if t:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = list(input())
t = False
if c < d:
    for i in range(a-1,d-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            break
    else:
        print('Yes')
else:
    for i in range(a-1,c-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            break
        if i == c-2 or i > d-1 or i < b-1:
            continue
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' and i+2 != b-1 and i != d-1:
            t = True
    if t:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = list(input())
t = False
if c < d:
    for i in range(a-1,d-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            break
    else:
        print('Yes')
else:
    for i in range(a-1,c-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            break
        if i == c-2 or i > d-1:
            continue
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' and i+2 != b-1 and i != d-1:
            t = True
    if t:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = list(input())
t = False
if c < d:
    for i in range(a-1,d-1):
        if s[i] == '.' and s[i+1] == '.' :
            print('No')
            break
    else:
        print('Yes')
else:
    for i in range(a-1,c-1):
        if s[i] == '#' and s[i+1] == '#':
            print('No')
            break
        if i == c-2 or i > d-1:
            continue
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' and i+2 != b-1 and i != d-1:
            t = True
    if t:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = list(input())
t = False
if c < d:
    for i in range(a-1,d-1):
        if s[i] == '#' and s[i+1] == '#' :
            print('No')
            break
    else:
        print('Yes')
else:
    for i in range(a-1,c-1):
        if s[i] == '#' and s[i+1] == '#' :
            print('No')
            break
        if i == c-2:
            continue
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' and i+2 != b-1 and i != d-1:
            t = True
    if t:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = list(input())
t = False
if c < d:
    for i in range(a-1,d-1):
        if s[i] == '#' and s[i+1] == '#' :
            print('No')
            break
    else:
        print('Yes')
else:
    for i in range(a-1,c-1):
        if s[i] == '#' and s[i+1] == '#' :
            print('No')
            break
        if i == c-2:
            continue
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' and i+2 != b-1:
            t = True
    if t:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = list(input())
t = False
flag = False
if c < d:
    for i in range(d-1):
        if s[i] == '#' and s[i+1] == '#' :
            print('No')
            break
    else:
        print('Yes')
else:
    for i in range(c-1):
        if s[i] == '#' and s[i+1] == '#' :
            print('No')
            break
        if i == c-2:
            continue
        if i == a-1 or i == b-1:
            s[i] = '#'
            flag = True
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
            t = True
        if flag:
            s[i] = '.'
            flag = False
    if t:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = list(input())
t = False
flag = False
if c < d:
    for i in range(d-1):
        if s[i] == '#' and s[i+1] == '#' :
            print('No')
            break
    else:
        print('Yes')
else:
    for i in range(c-1):
        if s[i] == '#' and s[i+1] == '#' :
            print('No')
            break
        if i == c-2:
            continue
        if i == a-1 or i == b-1:
            s[i] = '#'
            flag = True
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
            t = True
        if flag:
            s[i] = '.'
    if t:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,a,b,c,d = inpl()
s = input()
t = False
if c < d:
    for i in range(d-1):
        if s[i] == '#' and s[i+1] == '#' :
            print('No')
            break
    else:
        print('Yes')
elif c > d:
    for i in range(c-1):
        if s[i] == '#' and s[i+1] == '#' :
            print('No')
            break
        if i == c-2:
            continue
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
            t = True
    if t:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
n,a,b,c,d = map(int, input().split( ))
a-=1
b-=1
s = input()+"##"

while b<c and (s[b-1]=="#" or s[b+1]=="#"):
    if s[b+1]!="#":
        b+=1
    else:
        if s[b+2]=="#":
            print("No")
            sys.exit()
        else:
            b+=2

for i in range(b,d):
    if s[i:i+2]=="##":
        print("No")
        sys.exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import re
n,a,b,c,d=map(int,input().split())
s=input()
if re.search('##',s):
    print('No')
if c > d:
    if re.search('#\.\.\.#', s[b:d+1]):
        print('Yes')
    else:
        print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
flag=True
for i in range(len(s)-1):
    if s[i]=="#" and s[i+1]=="#":
        flag=False
        break

if c<d:
    if flag:
        print("Yes")
    else:
        print("No")
elif c>d:
    flag=False
    for i in range(b,d-1):
        if s[i-1]=="." and s[i]=="." and s[i+1]==".":
            flag=True
            break
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
flag=True
for i in range(len(s)-1):
    if s[i]=="#" and s[i+1]=="#":
        flag=False
        break

if c<d:
    if flag:
        print("Yes")
    else:
        print("No")
elif c>d:
    flag=False
    for i in range(b-1,d-2):
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            flag=True
            break
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
flag=True
for i in range(len(s)-1):
    if s[i]=="#" and s[i+1]=="#":
        flag=False
        break

if c<d:
    if flag:
        print("Yes")
    else:
        print("No")
elif c>d:
    flag=False
    for i in range(len(s)-2):
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            flag=True
            break
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

while funuke < D:
    if S[funuke + 1] == '.':
        funuke += 1
    else:
        if S[funuke + 2] == '.':
            funuke += 2
        else:
            print('No')
            exit()
while sunuke < C:
    if S[sunuke + 1] == '.':
        sunuke += 1
    else:
        if S[sunuke + 2] == '.':
            sunuke += 2
        else:
            print('No')
            exit()

if C < D:
    print('Yes')
else:
    for i in range(B, D):
        if S[i:i + 3] == '...':
            print('Yes')
            exit()
    else:
        print('No')

Submission status: Wrong Answer

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

while funuke < D:
    if S[funuke + 1] == '.':
        funuke += 1
    else:
        if S[funuke + 2] == '.':
            funuke += 2
        else:
            print('No')
            exit()
while sunuke < C:
    if S[sunuke + 1] == '.':
        sunuke += 1
    else:
        if S[sunuke + 2] == '.':
            sunuke += 2
        else:
            print('No')
            exit()

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