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 sys
n,a,b,c,d=map(int,input().split())
s=input()
if '##' in s[a:c]:
    print('No')
    sys.exit()
if '##' in s[b:d]:
    print('No')
    sys.exit()
if d<c:
    if s[b-2]==s[b]=='.':
        print('Yes')
        sys.exit()
    elif '...' in s[b-1:c]:
        print('Yes')
        sys.exit()
    else:
        print('No')
        sys.exit()

print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n , a0 , b0 , c0 , d0 = map(int,input().split())
s = input()

# a < b に変換する
if a0 > b0 : # 入れ替える
    a = b0
    b = a0
    c = d0
    d = c0
else : # 入れ替えない
    a = a0
    b = b0
    c = c0
    d = d0

right = max(c,d)
left = min(a,b)
middle = max(a,b)

for i in range(n-1) :
    if s[i] == '#' and s[i+1] == '#' : # 岩が2個連続である場合
        if i <= right - 2 and i >= left - 1 :
            print('No')
            break
else :
    if c < d :
        print('Yes')
    else :
        for i in range(n-2) :
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' : # 入れ替え可能
                if i + 1 == b - 1 :
                    print('Yes')
                    break
                if i <= d - 1 and i >= b - 1 :
                    print('Yes')
                    break
        else :
            print('No')

Submission status: Wrong Answer

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

if "##" in s[A-1:C]+" "+s[B-1:D]:
  print("No")
  quit()
st,e=0,0
for spl in s.split("##"):
  e += len(spl)
  if st <A<max(C,D)<=e:
    break
  st+= len(spl)

if "..." in s[st:e]:
  print("Yes")
elif D<C:
  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 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=list(input())

i=0
j=0
gg=0
nnt=0
if c<d:
    i=a-1
    while i!=d:
        if s[i]=="#":
            j=j+1
        else:
            j=0
        if j==2:
            nnt=1
            break
        i=i+1

else:
    i=a-1
    nnt=1
    while i!=d-1:

        if s[i]==".":
            gg=gg+1
        else:
            gg=0
        if gg==3:
            if i>b:
                if i<c:
                    nnt=0



        if s[i]=="#":
            j=j+1
        else:
            j=0
        if j==2:
            nnt=1
            break

        i=i+1
if nnt==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

print(S)
iwa_cnt = 0
kusa_cnt = 0
result ='No'
for s in S[A-1:]:
    #print(s)
    #print(iwa_cnt)
    #print(kusa_cnt)
    if s =='#':
        iwa_cnt +=1
        kusa_cnt = 0
    else:
        kusa_cnt +=1
        iwa_cnt =0
    if iwa_cnt == 2:
        result ='No'
        break
    if kusa_cnt == 2 and C < D:
        result = 'Yes'
    if kusa_cnt == 3:
        result = 'Yes'
print(result)

Submission status: Wrong Answer

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

flag = True

# c < dならbを先にゴールさせれば良い
s_bd = s[b:d-1]
for i in range(len(s_bd)-1):
    if s_bd[i:i+2] == "##":
        flag = False
        break
s_ac = s[a:c-1]
for i in range(len(s_ac)-1):
    if s_ac[i:i+2] == "##":
        flag = False
        break

if c > d:
    # ゴールの左が#
    if s[d-2] == "#":
        s_bd = s[b-1:d]
        has_ddd = False
        for i in range(len(s_bd)-2):
            if s_bd[i:i+3] == "...":
                has_ddd = True
        if has_ddd == False:
            flag = False

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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
cou1 = 0
ans1 = 0
cou2 = 0
ans2 = 0
S = S[A: max(C, D)-1]
for i in S:
    if i == "#":
        cou1 += 1
        ans2 = max(ans2, cou2)
        cou2 = 0
    else:
        cou2 += 1
        ans1 = max(ans1, cou1)
        cou1 = 0
if D > C:
    ans2 = 4
if ans1 < 2 and ans2 >= 3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
right = max(C,D)
r = min(C,D)-1

if '##' in S[A-1:C] or '##' in S[B-1:D]:
  print('No')
else:
  if C < D:
  	print('Yes')
  else:
    if '...' in S[B-1:right]:
      print('Yes')
    else:
      #print(S[A-1:right])
      if len(S[A-1:right])<=6:
        print('Yes')
      else:
        print('No')

Submission status: Wrong Answer

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

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

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:
n,a,b,c,d = map(int, input().split())
s=input()

    
ans="Yes"
for i in range(a,max(c,d)-1):
  if s[i-1]=="#" and s[i]=="#":
    ans="No"

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

Submission status: Wrong Answer

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

if "##" in S[A-1:]:
  ans = "No"
elif 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:
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 B<C and C<D:#パターンその2
    for i in range(A-1,D-2):
        if S[i]=='#' and S[i+1]=='#':
            print('No')
            exit()
    print('Yes')
    exit()
elif C<B and B<D:#パターンその1
    for i in range(A-1,C-2):
        if S[i] == '#' and S[i + 1] == '#':
            print('No')
            exit()
    for p in range(B-1,D-2):
        if S[p] == '#' and S[p + 1] == '#':
            print('No')
            exit()
    print('Yes')
    exit()
elif D<C:#パターンその3
    for j in range(A-1,C-2):
        if S[j]=='#' and S[j+1]=='#':
            print('No')
            exit()
    if any(S[k-1]=='.' and S[k]=='.' and S[k+1]=='.' for k in range(B-1,D-1)):
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


def inpl():
    return list(map(int, input().split()))


N, A, B, C, D = inpl()
S = "#" + input() + "#"
section = [-1 for i in range(N + 2)]
ischange = defaultdict(lambda: False)
interval = defaultdict(lambda: [-1, -1])
sec_num = 0

flag = True
for i, s in enumerate(zip(S, S[1:])):
    if s == ("#", "#"):
        sec_num += 1
        section[i] = -1
        section[i + 1] = -1
        flag = True
    else:
        section[i] = sec_num
        section[i + 1] = sec_num
        if flag is True:
            interval[sec_num][0] = sec_num
            flag = False
        else:
            interval[sec_num][1] = sec_num + 1
    if i < N and S[i] + S[i + 1] + S[i + 2] == "...":
        ischange[sec_num] = True

if section[A] != section[C] or section[B] != section[D]:
    print("No")
    exit()
elif section[A] != section[B]:
    print("Yes")
    exit()
elif max(A, C) <= min(B, D) or max(B, D) <= min(A, C):
    print("Yes")
    exit()
elif ischange[section[A]] is True:
    print("Yes")
    exit()

# ややこしいのだけ残る
if A > B:
    tmpA = A
    tmpC = C
    A = B
    C = D
    B = tmpA
    D = tmpC

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = [int(x) for x in input().split()]
S = input()
S_ = list(S)
cross = False
minS = A
maxS = B
minG = C
maxG = D

if C < D:
    if A > B:
        maxS = A
        minS = B
        cross = True
else:
    minG = D
    maxG = C
    if A < B:
        cross = True

wall = S.find("##")
even = S.rfind("...")

if cross == False:
    if wall == -1:
        print("Yes")
    elif wall < minS or maxG < wall:
        print("Yes")
    else:
        print("No")
else:
    if even == -1:
        print("No")
    elif even + 1 < maxS:
        print("No")
    elif minS <= wall and wall <= maxG:
        print("No")
    else:
        print("Yes")

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[maxG - 1] == "#" or S[maxG + 1] == "#":
        if "..." not in S[maxS - 1: min(maxG, minG)]:
            print("No")
            exit()

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

print("Yes")

Submission status: Wrong Answer

Solution code:
# A問題
N, A, B, C, D = map(int, input().split())
S = input()
flag = False
S = S[A-1:]

if C < D:   # AがBを飛び越えない時
    if S.count("##") > 0:
        flag = False
    else:
        flag = True
else:   # AがBを飛び越えるとき
    if S.count("##") > 0:   
        flag = False
    else:
        if S.count("...") > 0:
            if S[B] == "#":
                flag = False
            else:
                flag = True
        else:
            if S[D] == "#" or S[D-2] == "#":
                flag = False
            else:
                flag = True
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if "##" in s[b:d+1]:
	# print('b-dで岩２つ')
	ans = 'No'
else:
	if "##" in s[a:c+1]:
		# print('a-cで岩２つ')
		ans = 'No'
	else:#邪魔な岩は無し
		if c>d: #ふぬけを飛び越える必要がある場合
			#ふぬけ君を飛び超えるために3マス以上連続で空いてる場所を探してあげる
			if "..." in s[b-1:d+1]:
				# print('空きマス３つある')
				ans = 'Yes'
			else:#飛び越えるスペースが無かった
				# print(s[b:])
				# print('空きマス３つない・・・')
				ans = 'No'
		else:#ふぬけ、すぬけの順に動かせばいい場合、岩はもう見た
			# print('ふぬけ→すぬけ　OK')
			ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
x = input().split()
s = input()
n = int(x[0])
a = int(x[1])
b = int(x[2])
c = int(x[3])
d = int(x[4])
ten_idx = []
kome_idx = []


if a in kome_idx or b in kome_idx or c in kome_idx or d in kome_idx:
  print('NO')
  
for i, char in enumerate(s):
  if char == '.':
    ten_idx.append(i)
  elif char == '#':
    kome_idx.append(i)

for i in kome_idx:
  if i + 1 in kome_idx:
    print('NO')
    
if c < d:
  print('YES')
if d < c:
  flag = False
  for i in ten_idx:
    if i+1 in ten_idx and i+2 in ten_idx:
      flag = True
      continue
  if flag :
    print('YES')
  if not flag:
    print('NO')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
#ぬかさないケース
if c<b:
  if s[a:c].find("##")==-1 and s[b:d].find("##")==-1:
    print("Yes")
  else:
    print("No")
elif s[a:d].find("##")==-1:
  if c<d:
    print("Yes")
  else:
    if s[b-1:d+2].find("...")==-1:
      print("No")
    else:
      print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
import math

n, a, b, c, d = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for m in range(m)]
#light = [int(i) for i in input().split()]
s = input()
list = list(s)

#print(n, m)
#print(table)
#print(light)

flag = 1



#A-C B-Dまでの間に岩が2個並んでいたらアウト

for i in range(a-1, c-1) :
    if ( list[i] == '#') :
        if ( list[i+1] == "#") :
            flag = 0

for i in range(b-1, d-1) :
    if ( list[i] == "#") :
        if ( list[i+1] == "#") :
            flag = 0

# D < C　のとき、A-Cまでの間に、3個以上空白がなければアウト

if (d < c) :
    flag = 0
    for i in range(a-1, d-2) :
        if (list[i] == '.' and list[i+1] == '.' and list[i+2] == '.') :
            flag = 1

if (flag == 1) :
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

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

# 3マス空きがあるか
white = []
for i in range(N - 2):
    if S[i] == "." == S[i + 1] == S[i + 2]:
        white.append(i + 1)
if C > D:
    # Aからスタート
    i = A - 1
    T = S.copy()
    T[B - 1] = "#"
    while C - 1 != i:
        if T[i + 1] == ".":
            i += 1
        elif T[i + 2] == ".":
            i += 2
        elif i + 1 == B - 1 or i + 2 == B - 1:
            es = False
            for w in white:
                if w <= D:
                    es = True
            if es:
                i = B - 1
            else:
                break
        else:
            break
    if i == C - 1:
        print("Yes")
        exit()
else:
    i = B - 1
    T = S.copy()
    T[A - 1] = "#"
    while D - 1 != i:
        if T[i + 1] == ".":
            i += 1
        elif T[i + 2] == ".":
            i += 2
        elif i + 1 == A - 1 or i + 2 == A - 1:
            es = False
            for w in white:
                if w <= C:
                    es = True
            if es:
                i = A - 1
            else:
                break
        else:
            break
    if i == D - 1:
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

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

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

S = str(input())

moziretu = S  # 保持しておく

# Bの人から動かす
zenhann = True
hoge = S[B+1]
for i in range(B+2, D):
    if hoge == S[i] and hoge == '#':
        zenhann = False
        break
    else:
        hoge = S[i]

if zenhann:
    str_list = list(S)
    str_list[D] = '#'
    S = "".join(str_list)

    hoge = S[A+1]
    for i in range(A+2, C):
        if hoge == S[i] and hoge == '#':
            zenhann = False
            break
        else:
            hoge = S[i]

kouhann = True
# Aの人から動かす
str_list = list(moziretu)
str_list[B] = '#'
moziretu = "".join(str_list)

fuga = moziretu[A+1]
for i in range(A+2, C):
    if fuga == moziretu[i] and fuga == '#':
        kouhann = False
        break
    else:
        fuga = S[i]
if kouhann:
    str_list = list(moziretu)
    str_list[C] = '#'
    moziretu = "".join(str_list)

    fuga = moziretu[B+1]
    for i in range(B+2, D):
        if fuga == moziretu[i] and fuga == '#':
            kouhann = False
            break
        else:
            fuga = moziretu[i]

if zenhann or kouhann:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

def syori1(sunuke,hunuke):
    while hunuke<D:
        if hunuke+1 == N:
            return "YES"
        if S[hunuke+1] == ".":
            hunuke += 2
        elif S[hunuke] == ".":
            hunuke += 1
        else:
            return "NO"
    
    while sunuke<C:
        if sunuke + 1 == N:
            return "YES"
        if S[sunuke+1] == ".":
            sunuke += 2
        elif S[sunuke] == ".":
            sunuke += 1
        else:
            return "NO"
    
    return "YES"

def canover():
    for i in range(min(C,D)-2):
        if S[i] == "." and S[i+1] == "." and S[i+2]==".":
            return True
        else:
            pass
    return False

if C > D:
    if canover():
        print(syori1(sunuke,hunuke))
    else:
        print("NO")
else:
    print(syori1(sunuke,hunuke))

Submission status: Wrong Answer

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


ans = "Yes"
f = 0
if C>D:
    f = 1


if f == 0:
    now = S[A-1]
    count = 0
    for i in range(A-1,C):
        if S[i]=='#':
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break
  
    count = 0
    for i in range(B-1,D):
        if S[i]=='#':
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break
       


if f == 1:
    now = S[A-1]
    count = 0
    count_space = 0
    space_flag = False

    for i in range(B-2,D):
        if S[i]=='#':
            count_space = 0
        else:
            count_space += 1
        if count_space == 3:
            space_flag = True

    if not space_flag:
        ans = "No"
    
    for i in range(A-1,C):
        if S[i]=='#':
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break

    
    
    count = 0
    for i in range(B-1,D):
        if S[i]=='#':
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break

print(ans)

Submission status: Wrong Answer

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

S = input()

s1 = []
s2 = []
for i in range(N):
    if i == C-1:
        s1.append('#')
        s2.append(S[i])
        continue
    if i == D-1:
        s2.append('#')
        s1.append(S[i])
        continue
    s1.append(S[i])
    s2.append(S[i])

flag1 = False
flag2 = False

for i in range(1,N):
    if s1[i] == '#' and s1[i-1] == '#':
        flag1 = True
    if s2[i] == '#' and s2[i-1] == '#':
        flag2 = True

if flag1 == True and flag2 == True:
    print('No')
else:
    flag3 = True
    for i in range(2,N):
        if s2[i] == '.' and s2[i-1] == '.' and s2[i-2] == '.':
            flag3 = False
    if flag3 == True and D < C:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
flag=0
span=0
buf=-5
if(c<d):
    for i in range(a-1,d):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
else:
    for i in range(a-1,c):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
        elif s[i]=='#':
            buf=max([span,buf])
            span=0
        elif b-2<i<d+1:
            span+=1
    if buf<=2:
        flag=1
        #print(buf)
print('No' if flag==1 else 'Yes')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
c1 = [0] * N
c2 = [0] * N
cnt1 = 0
cnt2 = 0
for i in range(N):
    if S[i] == '.':
        c2[i] = cnt2
        cnt2 = 0
        cnt1 += 1
    else:
        c1[i] = cnt1
        cnt1 = 0
        cnt2 += 1
res = [0] * N
index2 = []
index1 = []
for i in range(N):
    if c2[i] >= 2:
        index2.append(i)
    if c1[i] >= 3:
        index1.append(i)
flag = True
for i in index2:
    if A < i - c2[i] + 1 < C or B < i - c2[i] + 1 < D:
        flag = False
    if C < i + 1 < A or D < i + 1 < B:
        flag = False

if len(index1) == 0:
    if A < B and C > D:
        flag = False
    if A > B and C < D:
        flag = False

if flag:
    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 = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum)

flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if cumsum[i+2] - cumsum[i] == 2:
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3]:
        flag_oinuki = True

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

for idx, masu in enumerate(s):
    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:
N,A,B,C,D=map(int,input().split())
S=input()

# stoneCnt=S.count("#")

# if stoneCnt == 0:
# 	print("Yes")
# 	exit(0)


curStoneLen=0

# 先にBがいけるか考える
# いけなければOUT
for b in range(B-1,D):
	if S[b] == ".":
		curStoneLen = 0
	else:
		curStoneLen += 1

	if 2 == curStoneLen:
		print("No")
		exit(0)



maxAtoDSeqSpaceLen=0
curSeqSpaceLen=0


curStoneLen=0

for a in range(A-1,C):
	if S[a] == ".":
		curStoneLen = 0
		curSeqSpaceLen += 1
	else:
		curStoneLen += 1
		curSeqSpaceLen = 0

	maxAtoDSeqSpaceLen=max(maxAtoDSeqSpaceLen,curSeqSpaceLen)

	if 2 == curStoneLen:
		print("No")
		exit(0)

# print(maxAtoDSeqSpaceLen)

if D < C and maxAtoDSeqSpaceLen < 3:
	# AはDまでにBをかわさないといけないのに、かわすスペースが無い
	print("No")
	exit(0)	
else:
	# その他の場合は、Bを無視して良い
	pass


print("Yes")

Submission status: Wrong Answer

Solution code:
def count_renzoku_char(s, char):
    max_len = 0
    current_len = 0
    for c in s:
        if c == char:
            current_len += 1
        else:
            if max_len < current_len:
                max_len = current_len
            current_len = 0

    return max_len

if __name__ == "__main__":
    N, A, B, C, D = [int(x) for x in input().split()]
    S = input()

    def main():
        if C < D:
            raw_sharp = count_renzoku_char(S[B+1: D], '#')
            if raw_sharp >= 2:
                print('No')
                return

            raw_sharp = count_renzoku_char(S[A+1: C], '#')
            if raw_sharp >= 2:
                print('No')
                return
            else:
                print('Yes')
                return
        else:
            raw_sharp = count_renzoku_char(S[A+1: C], '#')
            if raw_sharp >= 2:
                print('No')
                return

            raw_space = count_renzoku_char(S[B+1: D], '.')
            if raw_space >= 3:
                print('Yes')
                return
            else:
                print('No')
                return

    main()

Submission status: Wrong Answer

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

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] != '#':
                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:
import numpy as np

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

s = S
if not "##" in S[B:D]:
    S = S[:D-1] + "#" + S[D:]
    if not "##" in S[A:C]:
        ans = "Yes"
    else:
        ans = "No"
else:
    ans = "No"

S = s
if ans is "No":
    S = S[:B-1] + "#" + S[B:]
    if not "##" in S[A:C]:
        S = S[:C-1] + "#" + S[C:]
        if not "##" in S[B:D]:
            ans = "Yes"
        else:
            ans = "No"
    else:
        ans = "No"

    if ans is "No":
        S = s
        if "..." in S[B:min([C, D])]:
            if not "##" in S[A:C]:
                S = S[:C-1] + "#" + S[C:]
                if not "##" in S[B:D]:
                    ans = "Yes"
                else:
                    ans = "No"
            else:
                ans = "No"        
print(ans)

Submission status: Wrong Answer

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

s_range = s[min(a, b) - 1:max(c, d)]
if '##' in s_range:
    print('No')
    exit()
if not((a > b and c > d) or (a < b and c < d)):
    if '...' not in s_range:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def reads():
  return [int(x) for x in input().split()]

N, A, B, C, D = reads()
# index変換
A -= 1; B -= 1
S = input()
if (C<D):
    if ("##" in S[A:D]):
        print("No")
    else:
        print("Yes")
else:
    if ("##" not in S[A:C]) and ("..." in S[A:C]):
        print("Yes")
    else:
        print("No")