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: Runtime Error

Solution code:
N,A,B,C,D = map(int, input().split())
S = input()
S.split()
answer = 1
a = 1
distance = []
distance_2 = []
for n in range(A-1,max(C-1,D-1)):
  a += 1
  if S[n] == "#":
    distance.append(a)
    a = 0
if 1 in distance:
  answer = 0
if D < C and answer == 1:
  a = 1
  for n in range(B-2,D+2):
    a += 1
    if S[n] == "#":
      distance_2.append(a)
      a = 0
  if max(distance_2) < 4:
    answer = 0
if answer == 1:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
import sys

move_store = [[2,2], [1,2], [2,1], [1,1], [0,1],[0,2],[1,0],[2,0]]


def check(A, B, C, D, N, move_a, move_b):
  new_A = A + move_a
  new_B = B + move_b
  if new_A>N or new_B>N or new_A>C or new_B>D or new_A==new_B:
    return False
  else:
    return True


def answer(N, A, B, C, D, S):
  move_a, move_b = None, None
  for ma, mb in move_store:
    if check(A, B, C, D, N, ma, mb):
      move_a, move_b = ma, mb

  if any([move_a is None, move_b is None]):
    print('No')
    return
  
  A += move_a
  B += move_b
  print(A, B)
  if A==C and B==D:
    print('Yes')
    return
  answer(N, A, B, C, D, S)

    
_input = sys.stdin.readline
N, A, B, C, D = (int(n) for n in _input().split())
S = sys.stdin.readline().strip()
answer(N, A, B, C, D, S)

Submission status: Runtime Error

Solution code:
nTmp = input().split()
nabcd = list(map(int, nTmp))
n = nabcd[0]
a = nabcd[1]  # すぬけ君の初期位置
b = nabcd[2]  # 腑抜け君の初期位置
c = nabcd[3]
d = nabcd[4]

s = list(input().strip())

ichi = {}
ichi["A"] = a
ichi["B"] = b

s[a-1] = "A"
s[b-1] = "B"

dest = {}
dest["A"] = c
dest["B"] = d
# print(s)

# みぎにいる方とそうでない方
if (a > b):
    migini_iru_hito = "A"
    hidari_no_hito = "B"
elif (a < b):
    migini_iru_hito = "B"
    hidari_no_hito = "A"

while(1):
    # for i in range(2):
    # す抜けか腑抜けを選ぶ
    # 1マス右か，2マス右に移動できる
    # 岩や人がいたらだめ

    if s[ichi[migini_iru_hito]] == ".":
        s[ichi[migini_iru_hito] - 1] = "."
        s[ichi[migini_iru_hito]] = migini_iru_hito
        ichi[migini_iru_hito] = ichi[migini_iru_hito]+1

    elif s[ichi[migini_iru_hito]+1] == ".":
        s[ichi[migini_iru_hito] - 1] = "."
        s[ichi[migini_iru_hito]+1] = migini_iru_hito
        ichi[migini_iru_hito] = ichi[migini_iru_hito]+2

    else:
        print("No")
        exit(1)

    # print(ichi)
    # print(dest)
    # print(s)

    # 最終的にCにす抜け，Dに腑抜けが，いるようにしたい
    if ichi[migini_iru_hito] == dest[migini_iru_hito]:
        # 一個めクリア
        break

# TODO==================================================================================

while(1):
    # for i in range(2):
    # す抜けか腑抜けを選ぶ
    # 1マス右か，2マス右に移動できる
    # 岩や人がいたらだめ

    if s[ichi[hidari_no_hito]] == ".":
        s[ichi[hidari_no_hito] - 1] = "."
        s[ichi[hidari_no_hito]] = hidari_no_hito
        ichi[hidari_no_hito] = ichi[hidari_no_hito]+1

    elif s[ichi[hidari_no_hito]+1] == ".":
        s[ichi[hidari_no_hito] - 1] = "."
        s[ichi[hidari_no_hito]+1] = hidari_no_hito
        ichi[hidari_no_hito] = ichi[hidari_no_hito]+2

    else:
        print("No")
        exit(1)

    # print(ichi)
    # print(dest)
    # print(s)

    # 最終的にCにす抜け，Dに腑抜けが，いるようにしたい
    if ichi[hidari_no_hito] == dest[hidari_no_hito]:
        print("Yes")
        break

Submission status: Runtime Error

Solution code:
import sys

n, a, b, c, d = map(int, input().split())
s = [ s for s in input()]
a = a-1
b = b-1
s[a] = "a"
s[b] = "b"

result = True
cnt = 0

if c > d and a < b:
    while True:
        if b+1 < n and (s[b+1] != "a" and s[b+1] != "#"):
            s[b+1] = "b"
            s[b] = "."
            b += 1
        elif b+2 < n and (s[b+2] != "a" and s[b+2] != "#"):
            s[b+2] = "b"
            s[b] = "."
            b += 2
        else:
            cnt = 1
        if s[b-1] == "." and s[b+1] == ".":
            break
        if cnt == 1:
            result = False
            break
    while a < b:
        if a+2 < n and (s[a+2] != "b" and s[a+2] != "#"):
            s[a+2] = "a"
            s[a] = "."
            a += 2
        elif a+1 < n and (s[a+1] != "b" and s[a+1] != "#"):
            s[a+1] = "a"
            s[a] = "."
            a += 1
if not result:
    print("NO")
    sys.exit(0)

while True:
    if a != c-1:
        if a+2 < n and (s[a+2] != "b" and s[a+2] != "#"):
            s[a+2] = "a"
            s[a] = "."
            a += 2
        elif a+1 < n and (s[a+1] != "b" and s[a+1] != "#"):
            s[a+1] = "a"
            s[a] = "."
            a += 1
        else:
            cnt += 1
    if b != d-1:
        if b+2 < n and (s[b+2] != "a" and s[b+2] != "#"):
            s[b+2] = "b"
            s[b] = "."
            b += 2
        elif b+1 < n and (s[b+1] != "a" and s[b+1] != "#"):
            s[b+1] = "b"
            s[b] = "."
            b += 1
        else:
            cnt += 1
    if cnt == 2:
        result = False
        break
    if a == c-1 and b == d-1:
        break
if result:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

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)

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

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: Runtime Error

Solution code:
def check(list,a,b,e,d):
    if a==b:
        return False
    if e==d:
        return False
    if list[d]=='#' or list[e]=='#':
        return False
    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
    print(check1)
    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
    print(check1)
    while i<max(e,d):
        if list[i]=='#':
            c+=1
        if list[i]=='.':
            c=0
        if c>=2:
            check1+=1
        i+=1
    print(check1)
    print(count,'c')
    if check1>0:
        return False
    else:
        if d>e:
            return True
        elif d==e:
           return False
        else:
            if count>=1:
                print('a')
                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: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun  2 21:00:38 2019

@author: hisaki
"""

#at coder 2019年6月2日日曜日　A問題
import sys
N, A, B, C, D = map(int, input().split())
S = input()
A_start = A -1
B_start = B -1
A_goal = C -1
B_goal = D -1

A_pos = A_start
B_pos = B_start

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

def func(A_pos, B_pos):
    global N
    global A_goal
    global B_goal
    
    if A_pos == A_goal and B_pos == B_goal:
        print ("Yes")
        sys.exit()
    
    if A_pos != N-1 and S[ A_pos + 1 ] != '#' and A_pos + 1 != B_pos:#操作A
        func(A_pos+1,B_pos)
    if A_pos != N-1 and A_pos != N-2 and S[ A_pos + 2 ] != '#' and A_pos + 2 != B_pos:#操作A
        func(A_pos+2,B_pos)
    if B_pos != N-1 and S[ B_pos + 1 ] != '#' and B_pos + 1 != A_pos:#操作A
        func(A_pos,B_pos+1)
    if B_pos != N-1 and B_pos != N-2 and S[ B_pos + 2 ] != '#' and B_pos + 2 != A_pos:#操作A
        func(A_pos,B_pos+2)
    
    return

func(A_pos,B_pos)
print ("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
num_list = input().split()
S = input()
# num_list = [int(x) for x in num_list]
# print(num_list)

N = num_list[0] # 列
A = num_list[1] # すぬけ 1
B = num_list[2] # ふぬけ 3
C = num_list[3] # すぬけ 6
D = num_list[4] # ふぬけ 7

"""
A = 1
B = 3
C = 7
D = 6
N = 7
"""
# print(S)
l_s = list(S)
cnt = 1
for i in range(0, len(l_s)):
    if l_s[i] == ".":
        l_s[i] = cnt
    cnt += 1
# print(l_s)

ans = 0
while True:
    if A + 1 != B and A + 1 != '#':
        A += 1
    if A + 2 != B and A + 2 != '#':
        A += 2  
    if B + 1 != A and B + 1 != '#':
        B += 1
    if B + 2 != A and B + 2 != '#':
        B += 2
    if (A == C) and (B == D):
       ans+=1
       break
    if A > N or B > N:
        break

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

Submission status: Runtime Error

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

if C<D:
  if B<C:
    d=0
    if "##" in S[A-1:D]:
      d=1
    print("Yes" if d==0 else "No")
  else:
    d=0
    if "##" in S[A-1:C]:
      d=1
    if "##" in S[B-1:D]:
      d=1
    print("Yes" if d==0 else "No") 
else:
  d=0
  d=4/0
  if "##" in S[A-1:C]:
    d=1
  if "..." not in S[B-1:D]:
    d=1
  print("Yes" if d==0 else "No")

Submission status: Runtime Error

Solution code:
from sys import stdin
N, A, B, C, D = (int(i) for i in input().rstrip().split())
S = stdin.readline().rstrip()
A -= 1
B -= 1
C -= 1
D -= 1
swap_able = False
for itr in range(len(S)):
    if itr < (len(S) - 1) and S[itr] == '#' and S[itr+1] == '#':
        print('No')
        exit()
    if itr < (len(S) - 2) and S[itr] == '.' and S[itr+1] == '.' and S[itr+2] == '.':
        swap_able = True

if A > B and S[C-1] == '#' and swap_able == False:
    print('No')
elif A > B and C != N and S[C+1] == '#' and swap_able == False:
    print('No')
elif A < B and S[D-1] == '#' and swap_able == False:
    print('No')
elif A < B and D != N and S[D+1] == '#' and swap_able == False:
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

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

new_D = [S_new[1: D], '#', S_new[D + 1: N]]
_ = ''.join(new_D)

import re
regex = r'##+'
matchobj = re.match(regex, _)
regex_dot = r'..+'
match_dot = re.match(regex_dot, _[D:])
if matchobj is not None and match_dot is None:
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

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+1):
        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: Runtime Error

Solution code:
N, A, B, C, D = input()
print(N)
S = input()
print(S)

if A + 1 != B and S[A + 1] != '#':
    A = A + 1
elif A + 2 != B and S[A + 2 ] != '#':
    print('No')

Submission status: Runtime Error

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) :
        if (list[i] == '.' and list[i+1] == '.' and list[i+2] == '.') :
            flag = 1

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

Submission status: Runtime Error

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[d+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+1):
        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: Runtime Error

Solution code:
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:
        index = S[b-1:d+2].find('...')
        S[index+1]='#'
        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)
        S[index+1]='.'
        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: Runtime Error

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

result = "Yes"
onon = True

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


print(result)

Submission status: Runtime Error

Solution code:
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")

Submission status: Runtime Error

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

import sys
if B > C:
    isi = 0
    cnt = 0
    for j in range(A-1,C):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    cnt = 0
    for j in range(B-1,D):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    if isi <= 1:
        print('Yes')
    else:
        print('No')
    sys.exit()


aki = 0
isi = 0
cnt = 0
for j in range(min(A,B)-1,max(C,D)):
    i = S[j]
    if i == '.':
        cnt = 0
    elif i == '#':
        cnt += 1
        isi = max(isi,cnt)
        
cnt = 0
for j in range(B-2,max(D+1,N)):
    i = S[j]
    if i == '#':
        cnt = 0
    elif i == '.':
        cnt += 1
        aki = max(aki,cnt)
        

if C > D:
    if aki >= 3 and isi <= 1:
        print('Yes')
    else:
        print('No')
else:
    if isi <= 1:
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
new_D = [S_new[1: D], '#', S_new[D + 1: N]]
_ = ''.join(new_D)

import re
regex = r'##+'
matchobj = re.match(regex, _)
regex_dot = r'..+'
match_dot = re.match(regex_dot, _[D:])
if matchobj is not None and match_dot is None:
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
n,a,b,c,d = map(int,input().split())
s = input().rstrip()
renzoku_iwa = [0 for i in range(n)]
renzoku_blank = [0 for i in range(n)]
old1 = ""
old2 = ""
for i,tmp in enumerate(s):
	if old1 == tmp:
		if old1 == "." and old2 == ".":
			renzoku_blank[i] = 1
		elif old1 == "#":
			renzoku_iwa[i] = 1
	old2 = old1
	old1 = tmp

if sum(renzoku_iwa[a-1:c]) == 0 and sum(renzoku_iwa[b-1:d]) == 0:
	if c < d:
		print("Yes")
	else:
		if sum(renzoku_blank[b:d])>=1:
			1/0
			print("Yes")
		else:
			print("No")
else:
	print("No")

Submission status: Runtime Error

Solution code:
N, A, B, C, D = input()
S = input()

if A + 1 != B and S[A + 1] != '#':
    A = A + 1
elif A + 2 != B and S[A + 2 ] != '#':
    print('No')

Submission status: Runtime Error

Solution code:
N, A, B, C, D = map(int, input().split())
 
S = input()
 
S = S + '#'
 
def continuous_rock_search(S, C, D):
    target = max(C, D)
    for i in range(target - 1):
        if S[i] == '#' and S[i+1] == '#':
            return True
    return False
  
def validation_funuke_move(S, B, D):
    '''
    ふぬけ君が両隣に岩がなくなるまで移動したとき、Dより向こうにはイカないことを確認する。
    True/False and ふぬけの移動後の位置
    '''
    funuke_position = B
    while (B <= D):
        if (S[B-2] == '#' or S[B] == '#'):
            if S[B] == '.' :
                B = B + 1
            else:
                B = B + 2
        elif (S[B-2] == '.' and S[B] == '.'):
            return True, B
    
    return False, -1
  
def KenKenRace(S, A, B, C, D):
    if continuous_rock_search(S):
        return False
    
    if C < D:
        return True
    
    if D < C:
        valid , _ = validation_funuke_move(S, B, D)
        if valid:
            return True
        else:
            return False
          
if KenKenRace(S, A, B, C, D):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
N, A, B, C, D = input()
S = input()

if A + 1 != B and S[A + 1] != '#':
  A = A + 1
elif A + 2 != B and S[A + 2 ] != '#':
    print('No')

Submission status: Runtime Error

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
s=list(s)
s.append('#')
s.append('#')
out=0
if c<d:
    for i in range(a-1,c):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    if out>0:print('No')
    else:print('Yes')
        
elif c>d:
    for i in range(a-1,c):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
            #print('Yes')
            ct+=1
        
    if(out>0 or ct==0):print('No')
    else:print('Yes')

Submission status: Runtime Error

Solution code:
N,A,B,C,D = map(int, raw_input().split())
S = raw_input()
i = 1
flagskip = 0
flagskip2 = 0
flagerror = 0
flags = 0
flagstop = 0
flagstop2 = 0
for c in S:
	if(flagstop2 == 1):
		if(c =='#'):
			flagstop += 1
		flagstop2 = 0
	if(i <= A):
		i += 1
		continue
	elif(i == B or (i == D and D < C)):
		if(flags == 1):
			flagstop += 1
		else:
			flagstop2 = 1
	if(c == '#'):
		if(flags == 1):
			flagerror = 1
			break
		flags = 1
		flagskip2 = 0
	else:
		if(flagskip2 == 1):
			flagskip = 1
		elif(flags == 0 and flagskip == 0 and i > B-1 and i < D+1):
			flagskip2 = 1
		flags = 0
	if(i = max(C,D)):
		break
	i += 1
if(flagstop == 2 and flagskip == 0):
	flagerror = 1
if(flagerror == 0):
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

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

if(max([len(item) for item in s.split('.')])>1 || c<b):
	print('No')
elif(c<d):
	print('Yes')
else:
	if(max([len(item) for item in s.split('#')])>2):
		print('Yes')
	else:
		print('No')

Submission status: Runtime Error

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

import sys
if B > C:
    isi = 0
    cnt = 0
    for j in range(A-1,C):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    cnt = 0
    for j in range(B-1,D):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    if isi <= 1:
        print('Yes')
    else:
        print('No')
    sys.exit()


aki = 0
isi = 0
cnt = 0
for j in range(min(A,B)-1,max(C,D)):
    i = S[j]
    if i == '.':
        cnt = 0
    elif i == '#':
        cnt += 1
        isi = max(isi,cnt)
        
cnt = 0
for j in range(B-2,D+1):
    i = S[j]
    if i == '#':
        cnt = 0
    elif i == '.':
        cnt += 1
        aki = max(aki,cnt)
        

if C > D:
    if aki >= 3 and isi <= 1:
        print('Yes')
    else:
        print('No')
else:
    if isi <= 1:
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
n,a,b,c,d = map(int,input().split())
s = input().rstrip()
renzoku_iwa = [0 for i in range(n)]
renzoku_blank = [0 for i in range(n)]
old1 = ""
old2 = ""
for i,tmp in enumerate(s):
	if old1 == tmp:
		if old1 == "." and old2 == ".":
			renzoku_blank[i] = 1
		elif old1 == "#":
			renzoku_iwa[i] = 1
	old2 = old1
	old1 = tmp

if sum(renzoku_iwa[a-1:c]) == 0 and sum(renzoku_iwa[b-1:d]) == 0:
	if c < d:
		print("Yes")
	else:
		1/0
		if sum(renzoku_blank[b:d])>=1:
			print("Yes")
		else:
			print("No")
else:
	print("No")
print(renzoku_iwa)
print(renzoku_blank)

Submission status: Runtime Error

Solution code:
def available(start, end, S, step=None):
    if step is not None:    #   追い越し処理
        S = S[:step] + "#" + S[step+1:]
    for i in range(start-1, end-1):
        if S[i] == "#" and S[i+1] == "#":
            return False
    return True, S
    
def overtake(start, end, S):
    for i in range(start-1, end-1):
        if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
            step = i
            return True, step
    return False, None

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

if D > C:   #   追い越しが不要な時
    judge1, S = available(A, C, S)
    judge2, S = available(B, D, S)
    if judge1 and judge2:
        print("Yes")
    else:
        print("No")
else:   #   追い越しが必要な時
    overtakable, step = overtake(B, D, S)
    if overtakable:   #   追い越しが可能な時
        judge1, S = available(B, D, S, step=step)
        judge2, S = available(A, C, S)
        if judge1 and judge2:
            print("Yes")
        else:
            print("No")
    else:   #   追い越しができない時
        print("No")

Submission status: Runtime Error

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)<end:
    break
  st+= len(spl)

if "..." in s[st:e]:
  print("YES")
elif D<C:
  print("NO")
else:
  print("YES")

Submission status: Runtime Error

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

flag = 0

if D > C:
    for i in range(D-B-2):
        if S[B+i] == '#' and S[B+i+1] == '#':
            print('No')
            flag = 1
            break
    if flag == 0:
        for j in range(C-A-2):
            if S[A+j] == '#' and S[A+j+1] == '#':
                print('No')
                flag = 1
                break        
        if flag == 0:
            print('Yes')
else:
    count = 0
    for i in range(D-B+3):
        if S[B-2+j] == '.':
            count += 1
        else:
            count = 0
        if count == 3:
            flag = 1
            break
    if flag == 0:
        print('No')
    else:
        for j in range(C-A-2):
            if S[A+j] == '#' and S[A+j+1] == '#':
                print('No')
                flag = 0
                break        
        if flag == 1:
            print('Yes')

Submission status: Runtime Error

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
if C<D and B<C:
    for i in range(A-1,D-2):
        if S[i]=='#' and S[i+1]=='#':
            print('No')
            exit()
    print('Yes')
    exit()
elif C<D and B>C:
    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 C>D:
    for j in range(A-1,D-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()
        
elif 
print('No')

Submission status: Runtime Error

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

def judge(start,goal):
    for i in range(start,goal-1):
        if s[i] == "#" and s[i+1] == "#":
            return 0
    return 1

def full_judge (start,obst,obfin,goal):
    if s[obst-2] = "." and s[obst] == "." :
        return 1
    for i in range(start-1,goal-2):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            return 1
    return 0


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

Submission status: Runtime Error

Solution code:
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.find("...")

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")
    if minS <= wall and wall <= maxG:
        print("No")
    else:
        print("Yes")

Submission status: Runtime Error

Solution code:
n,a,b,c,d=(int(i) for i in input().split())
s=input()
r="Yes"
for i in(a,d):
  if s[i]=="#":
    if s[i+1]=="#":
      r="No"
      break
if r=="Yes" and c>d:
  r="No"
  for i in range(d-b+1):
    if s[i+b-2]==".":
      if s[i+b-1]==".":
        if s[i+b]==".":
          r="Yes"
          break
print(r)