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:
import copy
n,a,b,c,d=map(int, input().split())
S='.'+input()
dpa=[0]*(n+1)
dpb=[0]*(n+1)
seta=[c]
setb=[d]
if d<c:
    if S[b-1:d+2].find('...')>0:
        T=copy.copy(S)
        T.replace('...', '.#.', 1)
        while seta:
            i = seta.pop()
            if i>0 and T[i-1]=='.' and dpa[i-1]==0:
                dpa[i-1]=1
                seta.append(i-1)
            if i>1 and T[i-2]=='.' and dpa[i-2]==0:
                dpa[i-2]=1
                seta.append(i-2)
        while setb:
            i = setb.pop()
            if i>0 and S[i-1]=='.' and dpb[i-1]==0:
                dpb[i-1]=1
                setb.append(i-1)
            if i>1 and S[i-2]=='.' and dpb[i-2]==0:
                dpb[i-2]=1
                setb.append(i-2)
else:
    while setb:
        i = setb.pop()
        if i>0 and S[i-1]=='.' and dpb[i-1]==0:
            dpb[i-1]=1
            setb.append(i-1)
        if i>1 and S[i-2]=='.' and dpb[i-2]==0:
            dpb[i-2]=1
            setb.append(i-2)
    while seta:
        i = seta.pop()
        if i>0 and S[i-1]=='.' and dpa[i-1]==0:
            dpa[i-1]=1
            seta.append(i-1)
        if i>1 and S[i-2]=='.' and dpa[i-2]==0:
            dpa[i-2]=1
            seta.append(i-2)
if dpa[a]==1 and dpb[b]==1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if s[a:c+1].count("##") > 0 or s[b:d+1].count("##") > 0:
    print("No")
elif c < d:
    print("Yes")
else:
    if s[b:].count("...") > 0 or s[b:b+2] == ".." or s[b-2] == "." and s[b] == ".":
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
# import re
import sys
# print(S[min(A,B):max(C,D)-1], S[min(A,B):max(C,D)-1].count("##"))
# print(S[B:D-1], S[B:D-1].count("..."))
# print(S[A:C-1], S[A:C-1].count("..."))

if S[A:max(C,D)-1].count("##"):
    print("No")
    sys.exit()
if C > D:
    if not S[B:D-1].count("..."):
        if not S[D-2] == "." and S[D] == ".":
            print("No")
            sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
#aとbが反転してるかどうが
if (a > b and c > d) or (a < b and c < d):rev = False
else:rev = True
#石が二つ連続していないかどうが
ren = True
for i in range(min(a,b)-1,max(c,d)):
    if max(c,d) - 1 <= i:pass
    elif s[i] == '#' and s[i+1] == '#':
        ren = False
#石と石の間が３以上空いているかどうが
enp = False
for i in range(max(a,b)-2,min(c,d)):
    if i >= n - 2:continue
    if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
        enp = True

if rev:
    if enp and ren:
        print('Yes')
    else:
        print('No')
else:
    if ren:
        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 S.find("##") > D - 1 or S.find("##") == -1:
        print("Yes")
    else:
        print("No")
else:
    if S.find("...") < D - 1 and S.find("...") != -1:
        if S.find("##") > C - 1 or S.find("##") == -1:
            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()+"*"
ruiwa=[0 for i in range(n+1)]
ruidot=[0 for i in range(n+1)]

wa=0
for i in range(n+1):
  if s[i]=="#":
    wa+=1
    ruiwa[i]=wa
  else:
    wa=0
    
wa=0
for i in range(n+1):
  if s[i]==".":
    wa+=1
    ruidot[i]=wa
  else:
    wa=0
    
ans=""

for i in range(a,n):
  if ruiwa[i]>1:
    ans="No"
    break

for i in range(b,n):
  if ruiwa[i]>1:
    ans="No"
    break

if ans=="":
  if s[d-1]=="#" or s[d+1]=="#":
    if a<b:
      for i in range(b,d):
        if ruidot[i]==3:
          ans="Yes"
          break
      if ans=="":
        ans="No"
  if s[c-1]=="#" or s[c+1]=="#":
    if b<a:
      for i in range(a,c):
        if ruidot[i]==3:
          ans="Yes"
          break
      if ans=="":
        ans="No"          
if ans=="":
  ans="Yes"
  
print(ans)

Submission status: Wrong Answer

Solution code:

import sys
sys.setrecursionlimit(100000000)

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

A -= 1
B -= 1
C -= 1
D -= 1

for i in range(len(s)):
    if i == len(s) - 1:
        continue
    else:
        if s[i] == '#' and s[i+1] == '#':
            print("No")
            exit()

if D < C:
    tmp = 0
    for i in range(len(s)):
        if i == len(s) - 2 or i == len(s) - 1:
            continue
        else:
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' and i + 2 < D:
                tmp = 1
    if tmp != 1:
        print("No")
        exit()



def check(s, start, goal, ans):
    if start == goal:
        return 1
    if s[start] == '#':
        return 0
    if start + 1 <= N - 1:
        ans += check(s, start + 1, goal, ans)
    if start + 2 <= N - 1:
        ans += check(s, start + 2, goal, ans)
    return ans

ans = 0
if not check(s, B, D, ans):
    print("No")
    exit()
#s[D] = '#'
if not check(s, A, C, ans):
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import re

n,a,b,c,d = input().split()
li = input()

pat1 = '##'
pat2 = '\.\.\.'

sm = int(c) if int(c) < int(d) else int(d)
lg = int(c) if int(c) > int(d) else int(d)

sh = li[:sm]
lo = li[:lg]

ret = ''

if re.match(pat1, lo):
    ret = 'No'
else:
    if c > d:
        if re.match(pat2, sh):
            ret = 'Yes'
        else:
            ret = 'No'
    else:
        ret = 'Yes'
    

print(ret)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, a, b, c, d = map(int, input().split())
s = input()

for idx, masu in enumerate(s):
    if idx < a:
        continue
    if masu == '.':
        start = idx
        break

# construct rle
rle = list()
last_masu = s[start]
cnt = 0
for masu in s[start:]:
    if masu == last_masu:
        cnt += 1
    else:
        rle.append(cnt)
        last_masu = masu
        cnt = 1
rle.append(cnt)

for idx in range(1, len(rle), 2):
    if rle[idx] > 1:
        print('No')
        exit()

if c > d:
    is_reverse = True
else:
    is_reverse = False

if is_reverse:
    flag = False
    for idx in range(0, len(rle), 2):
        if rle[idx] > 2:
            flag = True
            break
    if flag:
        print('Yes')
    else:
        print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    if C < D:
        flag_d = False
        for i in range(A+1, D-1):
            if S[i:i+2] == '##':
                flag_d = True
                break

        #flag_c = False
        #for i in range(B+1, D-2):
        #    if S[i:i+3] == '...':
        #        flag_c = True
        #        break

        if flag_d:
            print(NO)
        else:
            print(YES)


    elif D < C:
        flag_d = False
        for i in range(A+1, C-1):
            if S[i:i+2] == '##':
                flag_d = True
                break

        flag_c = False
        for i in range(A+1, D-2):
            if S[i:i+3] == '...':
                flag_c = True
                break

        if flag_d:
            print(NO)
        else:
            if flag_c:
                print(YES)
            elif S[D-2] != '#' and S[D] != '#':
                print(YES)
            else:
                print(NO)


    else:
        raise NotImplementedError





    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#coding:utf-8

N, A, B, C, D = map(int, input().split())
# リストにする
S = list(input())
fl = True

if C < D:
    # Bから見る
    for i in range(B-1, D-1):
        if S[i+1] == '#':
            if S[i+2] == '#':
                fl = False
                break
    S[D-1] = '#'
    # print(S)
    for j in range(A-1, C-1):
        if S[j+1] == '#':
            if S[j+2] == '#':
                fl = False
                break

if C > D:
    # Aから見る
    S[B-1] = '#'
    for j in range(A-1, C-1):
        if S[j+1] == '#':
            if S[j+2] == '#':
                fl = False
                break
    S[C-1] = '#'
    # print(S)
    for i in range(B-1, D-1):
        if S[i+1] == '#':
            if S[i+2] == '#':
                fl = False
                break



if fl:
    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:
    minS = A
    minG = C
    maxS = B
    maxG = D
else:
    maxS = A
    maxG = C
    minS = B
    minG = D

if "##" in S[minS : max(maxG, minG)]:
    print("No")
    exit()

# スタートが左側でゴールが右
if minS < maxS and minG == max(maxG, minG):
    # 途中で飛び越え必須
    if "..." not in S[minS: max(maxG, minG)]:
        print("No")
        exit()
    # OKでも、maxSが岩の前後の場合注意
    elif S[maxS - 1] == "#" or S[maxS + 1] == "#":
        # その場合maxS以降に3空きがあればOK
        if "..." not in S[maxS: max(maxG, minG)]:
            print("No")
            exit()
    # 左ゴールの前後も岩だとダメ
    elif S[min(minG, maxG) - 1] == "#" or S[min(minG, maxG) + 1] == "#":
        if "..." not in S[maxS - 1: min(maxG, minG)]:
            print("No")
            exit()

# スタート左、ゴールも左 -> 右側に先にゴールしてもらう
# スタート右、ゴールは左 -> スタートが左側でゴールが右

print("Yes")

Submission status: Wrong Answer

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

S = input()

def AA(mojiretu):
    if '##' in mojiretu:
     print("No")
    else:
     print("Yes")

Scp = S
if C < D:
    Scp = Scp[:D-1]+"#" + Scp[D:]
    AA(Scp[:C])
       
else:
    if "..." in Scp[B-1:]:
      AA(Scp)
    else:
      Scp = Scp[:D-1]+"#" + Scp[D:]
      AA(Scp)

Submission status: Wrong Answer

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

flag = True
isSharp = False
for i in range(A, max(C, D)):
    if S[i] == '#':
        if isSharp is False:
            isSharp = True
        else:
            flag = False
            break
    else:
        isSharp = False

if D < C:
    cnt = 0
    isCons = False
    for i in range(B-1, D+1):
        if S[i] == '.':
            cnt += 1
            if cnt == 3:
                isCons = True
                break
        else:
            cnt = 0
    if isCons is False:
        flag = False

if flag is True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def valid_check(n, a, b, c, d, s):
    if not two_rocks(s[b:d]):
        return 0
    # if not two_rocks()
    if c < d:
        return two_rocks(s[a:c])
    else:
        return three_spaces(s[a:d+2]) and two_rocks(s[a:c])
        # if three_spaces(s[a:c+1]) and two_rocks(s[a:c]):
        #     return 1
        # else:




        # for possibility in enumerate_possibilities(b, d, s):
        #     if two_rocks(possibility[a:c]):
        #         return 1
        # return 0

def three_spaces(s):
    for i in range(len(s)-2):
        if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
            return 1
    return 0

# def enumerate_possibilities(b, d, s):
#     possibilities = []
#     for i in range(d-b+1):
#         if s[b+i]=='.':
#             tmp = s.copy()
#             tmp[b+i] = '#'
#             possibilities.append(tmp)
#     return possibilities


def two_rocks(s):
    for i in range(len(s)-1):
        if s[i]=='#' and s[i+1]=='#':
            return 0
    return 1

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


if valid_check(n, a, b, c, d, s):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def check(list,a,b,e,d):
    i,z,count,counter,c=a,True,0,0,0
    check1=0
    while i<b:
        if list[i]=='#':
            c+=1
        if list[i]=='.':
            c=0
        if c>=2:
            check1+=1
        i+=1
   
    if check1>0:
        return False
    c=0
    i=max(a,b)
    while i<min(e,d):
        if list[i]=='#':
            counter=0
            c+=1
        if list[i]=='.':
            counter+=1
            c=0
        if counter>=3:
            count+=1
        if c>=2:
            check1+=1
        i+=1
    if check1>0:
        return False
    c=0
    
    while i<max(e,d):
        if list[i]=='#':
            c+=1
        if list[i]=='.':
            c=0
        if c>=2:
            check1+=1
        i+=1
   
    if check1>0:
        return False
    else:
        if d>e:
            return True
        elif d==e:
           return False
        else:
            if count>=1:
                
                return True
m=list(map(int,input().strip().split()))
l=list(input())
if check(l,m[1],m[2],m[3],m[4]):
    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:max([C, D])]:
	print("No")
	exit()

if D < C:
	if not "..." in S[A - 1:D + 1]:
		print("No")
		exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
 
import sys
import re
 
_,a,b,c,d = [ int(x)-1 for x in sys.stdin.readline().split() ]
m = sys.stdin.readline().strip()
#
loc= []
for match in re.finditer( "##",m ): loc.append( match.start() )
if c>d:
    if m[b-1:b+2]!="..." and m[b+1:d-1].find("..")<0:
        print( "No" )
        exit()
#
# check b->d
flag= False
ii= b+1
jj= d-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
if flag:
    print( "No" )
    exit()
#
# check a->c
ii= a+1
jj= c-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
#
if flag:
    print( "No" )
    exit()
#
print( "Yes" )

Submission status: Wrong Answer

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

for k in range(min(A,B)-1,max(C,D)-2):
    if S[k] == S[k+1] == "#":
        print("No")
        exit(0)

if C < D:
    print("Yes")
    exit(0)
for k in range(N-2):
    if S[k] == S[k+1] == S[k+2] == ".":
        if k+2 <= D and k+3 <= C:
            print("Yes")
            exit(0)
print("No")
exit(0)

Submission status: Wrong Answer

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

if '##' in s:
    print('No')
elif c < d:
    print('Yes')
elif s.find('...',-1) < d:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

flag3 = 0
flagno = 0

if c > d:

    for i in range(a,c):

        if s[i:i+2] == "##":
            flagno += 1
            break

    if flagno == 0:

        for i in range(b,d-2):
        
            if s[i-2:i+1] == "...":
                flag3 += 1
                break
    
    if flagno == 0 and flag3 > 0:
        print("Yes")

    else:
        print("No")

else:

    for i in range(a,n):

        if s[i:i+2] == "##":
            flagno += 1
            break
    
    if flagno == 0:
        print("Yes")

    else:
        print("No")

Submission status: Wrong Answer

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

ans = "Yes"
rock = list(filter(lambda i: s[i] == s[i + 1] == '#', range(n - 1)))
if 0 < len(rock) and max(a, b) - 1 <= rock[0] and rock[-1] <= min(c, d) - 1:
    ans = "No"
if b < c < d and not any(map(lambda i: b < i + 1 < min(c, d), list(filter(lambda i: s[i - 1] == s[i] == s[i + 1] == '.', range(1, n - 1))))):
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

def scan(a_, c_, f='#'):
  mae = '#'
  for i, l in enumerate(s, 1):
    if a_ > i:
      continue
    if c_ == i:
      return True
    if mae == l == f:
      return True if f=='.' else False
    mae = l

if d > c and scan(a, c) and scan(b, d):
    print('Yes')
elif d < c and scan(a, c) and scan(b, d) and scan(b, d, '.'):
    print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

l = min(A,B)
R = max(C,D)
if (A-B)*(C-D) > 0:
    if S[l:R].find("##") >= 0:
        print("No")
    else:
        print("Yes")
    exit()
else:
    r = min(C,D)
    if S[l:R].find("##") == -1 and S[l:r+2].find("...") >= 0:
        print("Yes")
    else:
        print("No")
    exit()

Submission status: Wrong Answer

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

start = min(a,b)
stop = max(c,d)
ans=0

if a<b and c<d:
    for i in range(start, stop):
        if s[i] == "#" and s[i+1] == "#":
            ans = "NO"
            break
    if ans == 0:
        ans = "YES"

elif b<a  and d<c:
    for i in range(start-1, stop):
        if s[i] == "#" and s[i+1] == "#":
            ans = "NO"
            break
    if ans == 0:
        ans = "YES"

elif a<b and d<c:
    judge = 0

    for i in range(start-1, stop):
        if b-1 <=i <= d-2:
            if s[i]=="." and s[i+1]=="." and s[i+2]==".":
                judge = 1
        if s[i] == "#" and s[i+1] == "#":
            ans = "NO"
            break

    if ans == 0:
        if s[b-2]=="." and s[b]==".":
            ans = "YES"
        elif judge == 1:
            ans = "YES"
        elif judge == 0:
            ans = "NO"

elif b<a and c<d:
    judge = 0

    for i in range(start, stop):
        if a-1 <=i <= c-2:
            if s[i]=="." and s[i+1]=="." and s[i+2]==".":
                judge = 1
        if s[i] == "#" and s[i+1] == "#":
            ans = "NO"
            break

    if ans == 0:
        if s[a-2]=="." and s[a]==".":
            ans = "YES"
        elif judge == 1:
            ans = "YES"
        elif judge == 0:
            ans = "NO"
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: int, B: int, C: int, D: int, S: str): 
    if(C < D):
        if(S[A-1:C].count('##') == 0 and S[B-1:D].count('##') == 0):
            print(YES)
    elif(C > D):
            if(S[B-1:D].count('...') == 0):
                print(NO)
            else:
                # st = list(S[B-1:D])
                st = list(S)
                st[B-1] = '#'
                # print(''.join(st[B-1:D]))
                if(''.join(st[B-1:D]).count('...') == 0):
                    print(NO)
                else:
                    print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin

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


    sunuke = S[A-1:C]
    funuke = S[B-1:D]
    if C < D:
        if '##' in sunuke or '##' in funuke:
            ans = 'No'
        else:
            ans = 'Yes'
    else:
        if '...' not in funuke or '##' in sunuke or '##' in funuke:
            ans = 'No'
        else:
            ans = 'Yes'
    print(ans)

input = lambda: stdin.readline()
main()

Submission status: Wrong Answer

Solution code:
from copy import deepcopy

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


def start_funuke():
    s = deepcopy(S)
    funuke = s[B - 1 : D]
    for i in range(1, len(funuke)):
        if funuke[i] == "#" and funuke[i - 1] == "#":
            return False
    s[D - 1] = "#"
    sunuke = s[A - 1 : C]
    for i in range(1, len(sunuke)):
        if sunuke[i] == "#" and sunuke[i - 1] == "#":
            return False
    return True


def start_sunuke():
    s = deepcopy(S)
    funuke = s[B - 1 : D]
    f = True
    for i in range(2, len(funuke)):
        if funuke[i] == "." and funuke[i - 1] == "." and funuke[i - 2] == ".":
            f = False
    if f:
        return False
    sunuke = s[A - 1 : C]
    for i in range(1, len(sunuke)):
        if sunuke[i] == "#" and sunuke[i - 1] == "#":
            return False
    s[C - 1] = "#"
    funuke = s[B - 1 : D]
    for i in range(1, len(funuke)):
        if funuke[i] == "#" and funuke[i - 1] == "#":
            return False
    return True


f1 = start_funuke()
f2 = start_sunuke()
if f1 or f2:
    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:
    ans = 'Yes'
else:
    if s[B-2:D].count('...')>0:
        
        ans = 'Yes'
    else:
        ans = 'No'
if s[A:C-2].count('##')!=0 or s[B:D-2].count('##')!=0:
    ans = 'No'
print(ans)

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()
nS = S[B-1:max(C,D)+1]
AB = S[A-1:B]

if C<D:
    if nS.find("##") != -1 or AB.find("##") != -1:
        print("No")
    else:
        print("Yes")

elif AB.find("##") != -1:
    print("No")
elif nS.find("...") == -1 or nS.find("##") != -1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
def main():
    inp = input()
    st = inp.split()
    n = int(st[0])
    a = int(st[1])
    b = int(st[2])
    c = int(st[3])
    d = int(st[4])
    inp = input()
    # 2 rocks
    rock_count = 0
    for i in range(a, b):
        if inp[i] == '#':
            rock_count += 1
        elif inp[i] == '.':
            rock_count = 0
        if rock_count == 2:
            print("No")
            return
    if inp[b] == "#" and (inp[b-1] == "#" or inp[b+1] == "#"):
        print("No")
        return

    max_cd = c if c > d else d
    continuous_count = 0
    nothing_count = 0
    nothing_3 = False
    if inp[b-1] == '.':
        nothing_count += 1
    for i in range(b, max_cd):
        if inp[i] == '#':
            continuous_count += 1
            nothing_count = 0
        elif inp[i] == '.':
            continuous_count = 0
            nothing_count += 1
        if continuous_count == 2:
            print("No")
            return
        if nothing_count == 3 and i < d + 1:
            nothing_3 = True

    # c < d
    if c < d or nothing_3:
        print("Yes")
    else:
        if (inp[d-1] == '.' and inp[d-2] == '.') and (inp[d] == '.' or inp[d-3] == '.'):
            print("Yes")
        else:
            print("No")
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b,c,d =  [int(x) for x in input().split()]
    stage = input().rstrip()

    if '##' in stage:
        print('No') 
    elif d < c and not '...' in stage[b-1:d]:
        print('No')
    else:
        print('Yes')

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

# print(s[2])
if d < c:
    ans = "No"
    for j in range(b-1, d-1, 1):
        # print(s[j],s[j+1],s[j+2])
        if s[j] == "." and s[j+1] == "." and s[j+2] == ".":
            ans = "Yes"
else:
    ans = "Yes"
for i in range(a, d-1, 1):
    if s[i] == "#" and s[i+1] == "#":
        ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
import random
n,a,b,c,d=map(int,input().split())
s=list(input())
if c<d:
  f=0
  for i in range(b,d-1):
    if s[i]=='#' and s[i+1]=='#':
      f==1
      break
  if f==0:
    for i in range(a,c-1):
      if s[i]=='#' and s[i+1]=='#':
        f=1
  if f==1:print('No')
  else:print('Yes')
else:
  f=0
  for i in range(b,d-1):
    if s[i]=='#' and s[i+1]=='#':
      f=1
      break
  if f==1:
    print('No')
  else:
    for i in range(a,c-1):
      if s[i]=='#' and s[i+1]=='#':
        f=1
        break
    if f==1:
      print('No')
    else:
      if s[d-2]=='#' or s[d]=='#':
        ct=0
        for i in range(b,d-2):
          if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
            ct=1
            break
        if ct!=0:
          print('Yes')
        else:
          if s[b-2]=='#' or s[b]=='#':
            print('No')
          else:
            if (random.randint(1,100))%2==0:print('No')
            else:print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
import copy

def solve(n, a, b, c, d, s):
    if c < d:
        if b < c:
            width = [(a-1, d-1)]
        else:
            width = [(a-1, c-1), (b-1, d-1)]

        for left, right in width:
            for i in range(left, right):
                if s[i] == "#" and s[i+1] == "#":
                    return "No"
                else:
                    return "Yes"
    else:
        for i in range(a-1, c-1):
            if s[i] == "#" and s[i+1] == "#":
                return "No"
            # until: d - 1, d, d + 1
            elif i < d - 1 and s[i] == "." and s[i+1] == "." and  s[i+2] == "." :
                return "Yes"
        return "No"


if __name__ == '__main__':

    n, a, b, c, d = map(int, sys.stdin.readline().strip().split(" "))
    s = sys.stdin.readline().strip()
    print solve(n, a, b, c, d, s)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,a,b,c,d = na()
s = ns()

a-=1
b-=1
c-=1
d-=1
fla = 0
flb = 0
dou = True
tri = False if d < c else True

for i in range(a+1,max(c,d)+1):
    if c < i and i < b:
        continue
    if s[i] == '.':
        fla = 0
        flb += 1
    else:
        fla += 1
        flb = 0
    if fla >= 2:
        dou = False
    if flb >= 3 and i > b+1 and i <= d+1:
        tri = True

if dou and tri:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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


for i in range(N-1):
    if S[i] == "#" and S[i+1] == "#":
        print("No")
        exit()

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


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

print("No")

Submission status: Wrong Answer

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

if B<C and C<D:
    f = True
    for i in range(A,D-1):
        if S[i-1]=="#" and S[i]=="#":
            f = False
            break
elif B<D and D<C:
    f = False
    if A<2:
        A = 2
    for i in range(A,D+1):
        if S[i-2]=="." and S[i-1]=="." and S[i]==".":
            f = True
            break
else:
    f = True
    for i in range(B,D-1):
        if S[i-1]=="#" and S[i]=="#":
            f = False
            break
    if f:
        for i in range(A,C-1):
            if S[i-1]=="#" and S[i]=="#":
                f = False
                break
if f:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = (int(i) for i in input().split())  
s = str(input())

m = max([c, d])
if n>m:
    n = m
    s = s[:n]
    
if '##' in s:
    print('No')
else:
    if c-1==d and s[d-2] == '#':
        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 = input()
ans = False

if '#' not in s:
    print('Yes')
if '##' in s and  a < s.index('##') < c:
    print('No')
if '##' in s and  b < s.index('##') < d:
    print('No')
#if a < b and c > d:
# elif '#.#' in s and a < s.index('#.#') and s.index('#.#') < c and a < b and c > d:
#     print('No')
# elif '#.#' in s and b < s.index('#.#') and s.index('#.#') < d:
#     print('No')
# elif '#..#' in s and a < b and c > d:
#     print('No')
# elif '#..#' in s and a > b and c < d:
#     print('No')
elif '...' in s:
    print('Yes')
elif c < d:
    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 or "##" in s[a:d-1]:
    print("No")
elif c < d:
    print("Yes")
else:
    if "..." in s[b-2:d] and "##" not in s[a:c-1]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, a, b, c, d = map(int, input().split())
s = input()
grid = []
for rock in s:
    grid.append(rock == '#')

if grid[c-1] or grid[d-1]:
    print('No')

max_none_count = 0
max_rock_count = 0
none_count = 0
rock_count = 0

for i in range(a - 1, max(c, d)):
    if grid[i] or (i == d - 1 and max_none_count <= 2 and c > d):
        none_count = 0
        rock_count += 1
    else:
        if i >= b - 2:
            none_count += 1
        rock_count = 0

    max_none_count = max(max_none_count, none_count)
    max_rock_count = max(max_rock_count, rock_count)

if max_rock_count >= 2:
    print('No')
else:
    if c < d:
        print('Yes')

    if c > d:
        if max_none_count >= 3:
            print('Yes')
        else:
            print('No')