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

a -= 1
b -= 1
c -= 1
d -= 1

flg1 = S[a:c+1].count("##")
flg2 = S[b:d+1].count("##")
flg3 = S[b-1:d+1].count("...")

if c < d :
    if flg1 + flg2 == 0 :
        ans = "Yes"
    else :
        ans = "No"
else :
    if (flg1 + flg2 == 0) and flg3 :
        ans = "Yes"
    else :
        ans = "No"

print(ans)

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

flg1 = S[a:c+1].count("##")
flg2 = S[b:d+1].count("##")
flg3 = S[b:d+1].count("...")

if c < d :
    if flg1 + flg2 == 0 :
        ans = "Yes"
    else :
        ans = "No"
else :
    if (flg1 + flg2 == 0) and flg3 :
        ans = "Yes"
    else :
        ans = "No"

print(ans)

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

flg1 = S[a:c+1].count("##")
flg2 = S[b:d+1].count("##")
flg3 = S[a:d+1].count("...")

if c < d :
    if flg1 + flg2 == 0 :
        ans = "Yes"
    else :
        ans = "No"
else :
    if (flg1 + flg2 == 0) and flg3 :
        ans = "Yes"
    else :
        ans = "No"

print(ans)

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

flg1 = S[a:c+1].count("##")
flg2 = S[b:d+1].count("##")
flg3 = S[a:c+1].count("...")

if c < d :
    if flg1 + flg2 == 0 :
        ans = "Yes"
    else :
        ans = "No"
else :
    if (flg1 + flg2 == 0) and flg3 :
        ans = "Yes"
    else :
        ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
s = input()
a, b, c, d = A - 1, B - 1, C - 1, D - 1
# No
# case1:素直に操作した場合にA,BがC,Dへいけない(##が間にある)
# case2:C>DかつAB～CD間に...がない(ABの入替が行えない)
if c < d:
    pattern = 1
elif c > d:
    pattern = 2
if pattern == 1:
    ans = 'Yes'
    for i in range(a, c):
        tmp = s[i:i + 2]
        if tmp == '##':
            ans = 'No'
            break
    for i in range(b, d):
        tmp = s[i:i + 2]
        if tmp == '##':
            ans = 'No'
            break
if pattern == 2:
    for i in range(b, d):
        if 1 <= i + 1 <= len(s):
            tmp = s[i - 1:i + 2]
            if tmp == '...':
                ans = 'Yes'
                break
    else:
        ans = 'No'
print(ans)

Submission status: Wrong Answer

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

def solveSimple(s, a, b, c, d):     
    if '##' in s[b-1:d]:
        return False 
    if '##' in s[a-1:c]:
        return False
    return True

# simple 
if c < d:
    ans = solveSimple(s, a, b, c, d)
    
# solveDifficult
else:
    ans = solveSimple(s, a, b, c, d) and '...' in s[b-1:d]

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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
s = input()
a, b, c, d = A - 1, B - 1, C - 1, D - 1
if c < d:
    pattern = 1
    ans = 'No'
elif c > d:
    pattern = 2
    ans = 'Yes'
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
s = input()
a, b, c, d = A - 1, B - 1, C - 1, D - 1
if c < d:
    pattern = 1
elif c > d:
    pattern = 2
if pattern == 1:
    ans = 'Yes'
    for i in range(a, c):
        tmp = s[i:i + 2]
        if tmp == '##':
            ans = 'No'
            break
    for i in range(b, d):
        tmp = s[i:i + 2]
        if tmp == '##':
            ans = 'No'
            break
if pattern == 2:
    for i in range(b, d - 1):
        if i + 2 <= len(s):
            tmp = s[i:i + 3]
            if tmp == '...':
                ans = 'Yes'
                break
    else:
        ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
s = input()
a, b, c, d = A - 1, B - 1, C - 1, D - 1
if c < d:
    pattern = 1
elif c > d:
    pattern = 2
if pattern == 1:
    ans = 'Yes'
    for i in range(a, c):
        tmp = s[i:i + 2]
        if tmp == '##':
            ans = 'No'
            break
    for i in range(b, d):
        tmp = s[i:i + 2]
        if tmp == '##':
            ans = 'No'
            break
if pattern == 2:
    for i in range(b, d):
        if i + 2 <= len(s):
            tmp = s[i:i + 3]
            if tmp == '...':
                ans = 'Yes'
                break
    else:
        ans = 'No'
print(ans)

Submission status: Wrong Answer

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

if c < d:
    x = a + 1
    while x < d:
        if s[x] == '#':
            if s[x+1] == '#':
                print('No')
                exit()
            else:
                x += 2
        else:
            x += 1
    print('Yes')
else:
    x = a + 1
    check = 0
    while x < c:
        if s[x] == '#':
            if s[x+1] == '#':
                print('No')
                exit()
            else:
                x += 2
        else:
            if x >= b and check == 0:
                if s[x-1] == s[x] and s[x] == s[x+1]:
                    check = 1
            x += 1
    if check == 1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n, a, b, c, d = map(int, input().split())
s = input()
if '##' not in s[a:c-1] or '##' not in s[b:d-1]:
    ans = 'Yes'
    if c > d:
        if '...' in s[b-2:d+1]:
            ans = 'Yes'
        else:
            ans = 'No'
else:
    ans = 'No' 
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

BLOCK=[0]*N
OPEN=[0]*N

for i in range(1,N):
    if S[i]=="#" and S[i-1]=="#":
        BLOCK[i]=1

for i in range(2,N):
    if S[i]==S[i-1]==S[i-2]==".":
        OPEN[i]=1

RIGHT_A=N-1
for i in range(A,N):
    if BLOCK[i]==1:
        RIGHT_A=i
        break

RIGHT_B=N-1
for i in range(B,N):
    if BLOCK[i]==1:
        RIGHT_B=i
        break

if C<=RIGHT_A+1 and D<=RIGHT_B+1:
    if RIGHT_A==RIGHT_B:
        for j in range(B+1,min(min(C,D)+2,N)):
            if OPEN[j]==1:
                print("Yes")
                sys.exit()

        else:
            if C<D:
                print("Yes")
            else:
                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()

A, B, C, D = A - 1, B - 1, C - 1, D - 1
if (A < C < B < D) or (A < B < C < D):
    if '##' in S[A: C + 1]:
        print('No')
        exit()

    if '##' in S[B: D + 1]:
        print('No')
        exit()
    print('Yes')


if A < B < D < C:
    if '##' in S[A: C + 1]:
        print('No')
        exit()

    if '##' in S[B: D + 1]:
        print('No')
        exit()

    if '...' in S[B - 1: D + 1]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

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

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

    for i in range(B, D):
        if S[i] == '#' and S[i + 1] == '#':
            print('No')
            exit()

    for i in range(B + 1, D):
        if S[i] == '.' and S[i + 1] == '.' and 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()

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

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

    for i in range(B + 1, D + 1):
        if S[i] == '#' and S[i + 1] == '#':
            print('No')
            exit()

    for i in range(B, D):
        if S[i] == '.' and S[i + 1] == '.' and 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()

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

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

    for i in range(B + 1, D):
        if S[i] == '#' and S[i + 1] == '#':
            print('No')
            exit()

    for i in range(B, D):
        if S[i] == '.' and S[i + 1] == '.' and 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()

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

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

    for i in range(B, D):
        if S[i] == '#' and S[i + 1] == '#':
            print('No')
            exit()

    for i in range(B, D):
        if S[i] == '.' and S[i + 1] == '.' and 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()

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

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

    for i in range(B, D):
        if S[i] == '#' and S[i + 1] == '#':
            print('No')
            exit()

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

Submission status: Wrong Answer

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

flag = True
flag2 = False
for i in range(D):
    if i+1 < N:
        if S[i] == '#' and S[i+1] == '#':
            flag = False
for i in range(C):
    if i+1 < N:
        if S[i] == '#' and S[i+1] == '#':
            flag = False

if C < D:
    if flag:
        print('Yes')
    else:
        print('No')
else:
    for i in range(D-B):
        if i != 0 and i + 1 < (D-B):
            if S[B+i] == '.' and S[B+i-1] == '.' and S[B+i+1] == '.':
                flag2 = True
    if flag and flag2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [0] + [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = list(cumsum) 
 
flag = True
flag_oinuki = False
for i in range(A,(len(cumsum) - 2)):
    if ((cumsum[i+2] - cumsum[i]) == 2) and A <= i <= (max(C,D)-1):
        flag = False
        break
for j in range(A,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3] and (j + 2 <= D):
        flag_oinuki = True
 
if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
argN, argA, argB, argC, argD = list(map(int,input().split()))
argS = input()

if argD < argC:
  flgOIKOSI = True
else:
  flgOIKOSI = False
  
if "##" in argS[argA - 1:argC - 1]:
  print("No")
elif "##" in argS[argB - 1:argD - 1]:
  print("No")
elif flgOIKOSI == False:
  print("Yes")
else:
  aryS = list(argS[max(0,argB - 2):min(argD,argN - 1)].split("#"))
  if len(max(aryS)) > 2:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
argN, argA, argB, argC, argD = list(map(int,input().split()))
argS = input()

if argD < argC:
  flgOIKOSI = True
else:
  flgOIKOSI = False
  
if "##" in argS[argA - 1:argC - 1]:
  print("No")
elif "##" in argS[argB - 1:argD - 1]:
  print("No")
elif flgOIKOSI == False:
  print("Yes")
else:
  aryS = list(argS[max(0,argB - 2):argD].split("#"))
  if len(max(aryS)) > 2:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

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

for i in range(len(S)):
    if S[i:i+2]=="##":
        result = "No"
        break

if result == "":
    if C < D:
        result ="Yes"
    else: # D < C
        if S[B-2] == "." and S[B] == ".":
            result = "Yes"
        else:
            for i in range(B-2,D-2):
                if S[i:i+4] == "#...":
                    result = "Yes"

if result == "":
    result = "No"

print(result)

Submission status: Wrong Answer

Solution code:
argN, argA, argB, argC, argD = list(map(int,input().split()))
argS = input()

if argD < argC:
  flgOIKOSI = True
else:
  flgOIKOSI = False
  
if "##" in argS[argA - 1:argC]:
  print("No")
elif "##" in argS[argB - 1:argD]:
  print("No")
elif flgOIKOSI == False:
  print("Yes")
else:
  aryS = list(argS[argB - 1:argD - 1].split("#"))
  if len(max(aryS)) > 2:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,s=open(0);n,a,b,c,d=map(int,n.split());print('YNeos'[id(d<c)%3*'#'in s[a:d]::2])

Submission status: Wrong Answer

Solution code:
n,s=open(0);n,a,b,c,d=map(int,n.split());print('YNeos'[id(d<c)%3*'##'in s[a:d]::2])

Submission status: Wrong Answer

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

if "##" in S[A:C-1] or "##" in S[B:D-1]:
    print("No")
    exit()
elif C>D and "..." not in S[B-2:D]:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n,s=open(0);n,a,*_,d=map(int,n.split());print('YNeos'['#'*(id('祈り')%2)in s[a:d]::2])

Submission status: Wrong Answer

Solution code:
def check(start,end,road):
    s = road[start-1:end-1]
    if '##' in s:
        return False
    else:
        return True
 
def check2(start,end,road):
    s = road[start-1:end-1]
    if '...' in s:
        return True
    else:
        return False
 
if __name__ == '__main__':
    n,a,b, c,d = map(int, input().split())
    s = input()
    if check(a,c,s) and  check(b,d,s):
        if c < d:
            print('Yes')
        else:
          if check2(b,d,s):
               print('Yes')
          else:
               print('No')
    else:
       print('No')

Submission status: Wrong Answer

Solution code:
def check(start,end,road):
    s = road[start-1:end-1]
    if '##' in s:
        return False
    else:
        return True
 
def check2(start,end,road):
    s = road[start-1:end-1]
    if '...' in s:
        return True
    else:
        return False
 
if __name__ == '__main__':
    n,a,b, c,d = map(int, input().split())
    s = input()
    if check(a,c,s) and  check(b,d,s):
        if c < d:
            print('Yes')
        else:
          if check2(a,d,s):
               print('Yes')
          else:
               print('No')
    else:
       print('No')

Submission status: Wrong Answer

Solution code:
figure=input()
math=input()
flg=False
 
figure=figure.split(' ')
if figure[3]>figure[4]:
  flg=True
  
for i in range(max(int(figure[3]),int(figure[4]))-1):
  if math[i]=='#' and math[i+1]=='#':
    if i<int(figure[3]):
    	print('No')
    	exit()
    
  if flg and i>=int(figure[2])-2 and i<int(figure[4])-1 and math[i]=='.' and math[i+1]=='.' and math[i+2]=='.':
    flg=False

if not flg:
	print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
figure=input()
math=input()
flg=False
 
figure=figure.split(' ')
if figure[3]>figure[4]:
  flg=True
  
for i in range(max(int(figure[3]),int(figure[4]))-1):
  if math[i]=='#' and math[i+1]=='#':
    if i<int(figure[3])-1:
    	print('No')
    	exit()
    
  if flg and i>=int(figure[2]) and i<int(figure[4])-1 and math[i]=='.' and math[i+1]=='.' and math[i+2]=='.':
    flg=False

if not flg:
	print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def check(start,end,road):
    s = road[start-1:end-1]
    if '##' in s:
        return False
    else:
        return True
 
def check2(start,end,road):
    s = road[start-1:end-1]
    if '...' in s:
        return True
    else:
        return False
 
if __name__ == '__main__':
    n,a,b, c,d = map(int, input().split())
    s = input()
    if c < d:
        if check(a,c,s) and  check(b,d,s):
            print('Yes')
        else:
            print('No')
    else:
        if check2(a,d,s):
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
def check(start,end,road):
    s = road[start-1:end-1]
    if '##' in s:
        return False
    else:
        return True
 
def check2(start,end,road):
    s = road[start-1:end-1]
    if '...' in s:
        return True
    else:
        return False
 
if __name__ == '__main__':
    n,a,b, c,d = map(int, input().split())
    s = input()
    if c < d:
        if check(a,c,s) and  check(b,d,s):
            print('Yes')
        else:
            print('No')
    else:
        if check2(a,d,s):
            if check(a,c,s) and  check(b,d,s):
                print('Yes')
            else:
                print('No')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
def check(start,end,road):
    s = road[start-1:end-1]
    if '##' in s:
        return False
    else:
        return True
 
def check2(start,end,road):
    s = road[start-1:end-1]
    if '...' in s:
        return True
    else:
        return False
 
if __name__ == '__main__':
    n,a,b, c,d = map(int, input().split())
    s = input()
    if c < d:
        if check(a,c,s) and  check(b,d,s):
            print('Yes')
        else:
            print('No')
    else:
        if check2(b,d,s):
            if check(a,c,s) and  check(b,d,s):
                print('Yes')
            else:
                print('No')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
def check(start,end,road):
    s = road[start-1:end-1]
    if '##' in s:
        return False
    else:
        return True
 
def check2(start,end,road):
    s = road[start-1:end-1]
    if '...' in s:
        return True
    else:
        return False
 
if __name__ == '__main__':
    n,a,b, c,d = map(int, input().split())
    s = input()
    if c < d:
        if check(a,c,s) and  check(b,d,s):
            print('Yes')
        else:
            print('No')
    else:
        if check2(a,c,s):
            if check(a,c,s) and  check(b,d,s):
                print('Yes')
            else:
                print('No')
        else:
            print('No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
figure=input()
math=input()
flg=False
 
figure=figure.split(' ')
if figure[3]>figure[4]:
  flg=True
  
for i in range(max(int(figure[3]),int(figure[4]))-1):
  if math[i]=='#' and math[i+1]=='#':
    if i<int(figure[3]):
    	print('No')
    	exit()
    
  if flg and i>=int(figure[2])-1 and i<int(figure[4])-1 and math[i]=='.' and math[i+1]=='.' and math[i+2]=='.':
    flg=False

if not flg:
	print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

if C<D:
    if "##" not in S[A:C-1] or "##" in S[B:D-1]:
        print("Yes")
    else:
        print("No")
elif C>D:
    if "##" not in S and "..." 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())
S=input()

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

Submission status: Wrong Answer

Solution code:
figure=input()
math=input()
flg=False
 
figure=figure.split(' ')
if figure[3]>figure[4]:
  flg=True
  
for i in range(max(int(figure[3]),int(figure[4]))-1):
  if math[i]=='#' and math[i+1]=='#':
    if i>int(figure[3]):
    	print('No')
    	exit()
    
  if flg and i>=int(figure[2])-1 and i<int(figure[4])-1 and math[i]=='.' and math[i+1]=='.' and math[i+2]=='.':
    flg=False

if not flg:
	print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
figure=input()
math=input()
flg=False
 
figure=figure.split(' ')
if figure[3]>figure[4]:
  flg=True
  
for i in range(max(int(figure[3])-1,int(figure[4]))-1):
  if math[i]=='#' and math[i+1]=='#':
    print('No')
    exit()
    
  if flg and i>=int(figure[2])-1 and i<int(figure[4])-1 and math[i]=='.' and math[i+1]=='.' and math[i+2]=='.':
    flg=False

if not flg:
	print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n,s=open(0);n,a,b,c,d=map(int,n.split());print('YNeos'['##'*('...'*(d<c)in s[b:d+1])in s[a:d]::2])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n,s=open(0);n,a,b,c,d=map(int,n.split());print('YNeos'['##'*('...'*(d<c)in s[b-2:d+1])in s[a:]::2])

Submission status: Wrong Answer

Solution code:
n,s=open(0);*_,b,c,d=map(int,n.split());print('YNeos'['##'*('...'*(d<c)in s[b-2:d+1])in s[:d]::2])

Submission status: Wrong Answer

Solution code:
n,s=open(0);*_,b,c,d=map(int,n.split());print('YNeos'['##'*('...'*(d<c)in s[b-2:d+1])in s::2])

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
count1 = 0
count2 = 0
if C>D:
    for i in range(B-1,C):
        if S[B-2] == '.' and S[B] =='.':
            count1 = 3
            break
        if S[i] == ".":
            count1 += 1
            if count1 ==3:
                break
        else:
            count1 = 0
    for i in range(A-1,C):
        if S[i] == '#':
            count2 +=1
            if count2 == 2:
                break
        else:
            count2 =0
    if count1 == 3 and count2 !=2:
        print("Yes")
    else:
        print("No")
else:
    for i in range(A-1,D):
        if S[i] == "#":
            count2 += 1
            if count2 == 2:
                break
        else:
            count2 = 0
    if count2 != 2:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

N, A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = input().strip().translate(str.maketrans({'#': '1', '.': '0'}))
ss = [int(c) for c in S]

ans = 'Yes'

# 場合分けして解く
if D > C:
    # 連続して岩があるとき（＝解けない）
    for i in range(D - A + 1):
        if ss[i] == 1 and ss[i+1] == 1:
            ans = 'No'

elif D < C:

    # 連続して岩があるとき（＝解けない）
    for i in range(C - A + 1):
        if ss[i] == 1 and ss[i+1] == 1:
            ans = 'No'

    # 3マス連続する空きマスがあれば順番をいれかえられる
    if ans == 'Yes':
        ans = 'No'
        for i in range(D - B + 1):
            i = i + B - 1
            if ss[i-1] == 0 and ss[i] == 0 and ss[i+1] == 0:
                ans = 'Yes'
else:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split());s=input();print('YNeos'[not'...'in s[b-2:d+1]or'##'in s[a:d]::2])

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split());s=input();t=s[b-2:d+1];print('YNeos'['##'*(not'...'*(d<c)in t)in s[a:c]+t::2])

Submission status: Wrong Answer

Solution code:
figure=input()
math=input()
flg=False
 
figure=figure.split(' ')
if figure[3]>figure[4]:
  flg=True
  
for i in range(max(int(figure[3]),int(figure[4]))-1):
  if math[i]=='#' and math[i+1]=='#':
    print('No')
    exit()
    
  if flg and i>=int(figure[2])-1 and i<int(figure[4])-1 and math[i]=='.' and math[i+1]=='.' and math[i+2]=='.':
    flg=False

if not flg:
	print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
figure=input()
math=input()
flg=False
 
figure=figure.split(' ')
if figure[3]>figure[4]:
  flg=True
  
for i in range(max(int(figure[3]),int(figure[4]))):
  if math[i]=='#' and math[i+1]=='#':
    print('No')
    exit()
    
  if flg and i>=int(figure[2])-1 and i<int(figure[4])-1 and math[i]=='.' and math[i+1]=='.' and math[i+2]=='.':
    flg=False

if not flg:
	print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split());s=input();print('YNeos'[not'...'*(d<c)in s[b-2:d]or'##'in s[a:c]+s[b:d]::2])

Submission status: Wrong Answer

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

for i in range(max(C,D)):
    if S[i:i+2]=="##":
        print("No")
        break

if result == "":
    if C < D:
        result ="Yes"
    else: # D < C
        if S[B-2] == "." and S[B] == ".":
            result = "Yes"
        else:
            for i in range(B-2,D-1):
                if S[i:i+3] == "...":
                    result = "Yes"

if result == "":
    result = "No"

print(result)

Submission status: Wrong Answer

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

def check_serial(mark, number, start, end):
    ans = False
    i = start
    while i < end:
        for j in range(number):
            if j+i > end:
                break
            if s[i+j] != mark:
                i += j 
                break
            elif j == number-1:
                ans = True
        if ans:
            break
        i += 1
    return ans

# print(check_serial('.', 3, 0, n-1))
ans = True
ans = not check_serial('#', 2, a, c-1) 
if c > d:
    ans = check_serial('.', 3, b-1, d) and ans
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
figure=input()
math=input()
flg=False
 
figure=figure.split(' ')
if figure[3]>figure[4]:
  flg=True
  
for i in range(len(math)-1):
  if math[i]=='#' and math[i+1]=='#':
    print('No')
    exit()
    
  if flg and i>=int(figure[2])-1 and i<int(figure[4])-1 and math[i]=='.' and math[i+1]=='.' and math[i+2]=='.':
    flg=False

if not flg:
	print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, input().split())
s = input()
index = [(n+1) for n, v in enumerate(s) if s[n:n+3] == "..."]

if "##" in s[A-1:]:
    print("No")

else:
    if C < D:
        print("Yes")

    if C > D:
        if len(index)>=1:
            for i in index:
                if B <= i+1 <= D:
                    print("Yes")
                    exit()
            print("No")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

N, A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = input().strip().translate(str.maketrans({'#': '1', '.': '0'}))
ss = [int(c) for c in S]

ans = 'Yes'

# 場合分けして解く
if ss[C-1] == 1:
    ans = 'No'

elif ss[D-1] == 1:
    ans = 'No'

elif D > C:
    # 連続して岩があるとき（＝解けない）
    for i in range(D - 1):
        if ss[i] == 1 and ss[i+1] == 1:
            ans = 'No'

elif D < C:

    # 連続して岩があるとき（＝解けない）
    for i in range(C - 1):
        if ss[i] == 1 and ss[i+1] == 1:
            ans = 'No'

    # 3マス連続する空きマスがあれば順番をいれかえられる
    if ans == 'Yes':
        ans = 'No'
        for i in range(D - B):
            i = i + B - 1
            if ss[i-1] == 0 and ss[i] == 0 and ss[i+1] == 0:
                ans = 'Yes'
else:
    ans = 'No'

print(ans)