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:
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,A,B,C,D = I()
maze = list(s())
if maze[0] == maze[1] == '#':
    print('No')
    exit()
Flag = 0
supt = 0
hupt = 0
for i in range(N-2):
    if maze[i+1] == maze[i+2] == '#':
        print('No')
        exit()
    if maze[i] == maze[i+1] == maze[i+2] == '.':
        Flag = 1
        hupt = i+1
        break
if C > D:
    if Flag == 0:
        print('No')
        exit()
    if B-1 <= hupt <= C-1
        print('Yes')
    else:
        print('No')
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n, a, b, c, d = map(int, input().split())
    s = input()
    for i in range(a, max(c,d)):
        if s[i-1:i+1] = "##":
            print("No")
            exit()
    if c > d:
        print("Yes")
        break
    for i in range(b-1, d):
        if s[i-1:i+2] == "...":
            print("Yes")
            exit()
    print("No")
    return 0

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, a, b, c, d = MAP()
s = input()

flag = 0
for i in range(min(a,b)+1,max(c,d)):
        if (a < i < c or b < i < d) and s[i] == s[i-1] == '#':
                print("No")
                exit()       
        elif max(a,b) <= i <= min(c,d) and s[i-1] == s[i] == s[i+1] == '.':
                flag = 1

if c > d and flag == 0:
        print("No")
else:
        print("Yes")

Submission status: Runtime Error

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

# 岩が2個並ぶ
before = s[0]
for ss in s[1:]:
    if ss == before and ss == '#':
        print('No')
        exit()
    before = ss

# 追い越す場合
if c > d:
    # new_s = s[:d+1]
    # for i in range(b - 1, len(new_s) - 2):
    #     ss = new_s[i:i + 3]
    #     # print(ss)
    #     if len(set(ss)) == 1 and ss[0] == '.':
    #         print('Yes')
    #         exit()
    ok = False
    for i in range(b, d + 1):
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            ok = True
            break
    if not ok:
        print('No')
        exit()

# 追い越さない
print('Yes')

Submission status: Runtime Error

Solution code:
def main():
    N,A,B,C,D = map(int, input().split())
    S = '#' + input()
    cross = False
    sameDire = False

    if not((A - C < 0) ^ (B - D < 0)):
        sameDire = True

    l = min(A,C)
    r = max(A,C)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < D and D < r:
        cross = True
    if sameDire and  l < D and D < r and  l < B and B < r:
        cross = True

    l = min(B,D)
    r = max(B,D)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < C and C < r:
        cross = True
    if sameDire and  l < C and C < r and  l < A and A < r:
        cross = True

    if cross:
        # ...のチェック範囲
        for i in range(A,N):
            if(S[i]=='#' and S[i+1]=='#'):
                r = i
                break
        else:
            #最後が#かは細かく見る必要はない
            r = N
        for i in reversed(range(1,N)):
            if(S[i]=='#' and S[i-1]=='#'):
                l = i+1
                break
        else:
            #最初が#かは細かく見る必要はない
            l = 0
        for '...' in S[l:r+1]:
            print('Yes')
            return
        print('No')
    else:
        print('Yes')



if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

def kenken(index,l):
    if l > index+1:
        if s[index+1] == ".":
            index += 1
        else:
            if s[index+2] == ".":
                index += 2
            else:
                pirnt("No")
                exit()
    else:
        print("No")
        exit()
    return index

#飛び越さなくていいとき
if c < d:
    index = b
    while index < d:
        index = kenken(index,l)
    index = a
    while index < c:
        index = kenken(index,l)
    print("Yes")
    exit()

#まずはDにたどり着けるか
index = b
while index < d:
    index = kenken(index,l)

#3連続であいている升があるかも調べる
c = 0
for i in range(b+1,d+1):
    if s[i] == ".":
        c += 1
    else:
        c = 0
    if c == 3:
        break
else:
    print("No")
    exit()

#dからｃにたどり着けるか
index = d
while index < c:
    index = kenken(index,l)
print("Yes")

Submission status: Runtime Error

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

def kenken(index,l):
    if s[index+1] == ".":
        index += 1
    elif l > index+2:
        if s[index+2] == ".":
            index += 2
        else:
            pirnt("No")
            exit()
    else:
        print("No")
        exit()
    return index

#飛び越さなくていいとき
if c < d:
    index = b
    while index < d:
        index = kenken(index,l)
    index = a
    while index < c:
        index = kenken(index,l)
    print("Yes")
    exit()

#まずはDにたどり着けるか
index = b
while index < d:
    index = kenken(index,l)

#3連続であいている升があるかも調べる
c = 0
for i in range(b+1,d+1):
    if s[i] == ".":
        c += 1
    else:
        c = 0
    if c == 3:
        break
else:
    print("No")
    exit()

#dからｃにたどり着けるか
index = d
while index < c:
    index = kenken(index,l)
print("Yes")

Submission status: Runtime Error

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

def kenken(index,l):
    if s[index+1] == ".":
        index += 1
    elif l > index+2:
        if s[index+2] == ".":
            index += 2
        else:
            pirnt("No")
            exit()
    else:
        print("No")
        exit()
    return index

#飛び越さなくていいとき
if c < d:
    index = b
    while index < d:
        index = kenken(index,l)
    index = a
    while index < c:
        index = kenken(index,l)
    print("Yes")
    exit()

#まずはDにたどり着けるか
index = b
while index < d:
    index = kenken(index,l)

#3連続であいている升があるかも調べる
for i in range(b,d+1):
    if s[i] == ".":
        c += 1
    else:
        c = 0
    if c == 3:
        break
else:
    print("No")
    exit()

#dからｃにたどり着けるか
index = d
while index < c:
    index = kenken(index,l)
print("Yes")

Submission status: Runtime Error

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=list(s)
cnts=0
cnti=0
space=0
iwa=0
temp=0
next=0
if c<d:
  for i in range(a-1,max(c,d)):
    if s[i]==".":
      cnts=cnts+1
      space=max(space,cnts)
      cnti=0
    else:
      cnti=cnti+1
      iwa=max(iwa,cnti)
      cnts=0
  if iwa>1:
    print("No")
  else:
    print("Yes")
else:
  for i in range(a-1,max(c,d)):
    if i==d:
      temp=space
      if s[i-1]=="." and s[i+1]==".":
        next=1
    if s[i]==".":
      cnts=cnts+1
      space=max(space,cnts)
      cnti=0
    else:
      cnti=cnti+1
      iwa=max(iwa,cnti)
      cnts=0
  if iwa>1:
    print("No")
  elif temp<3 and next==0:
    print("No")
  else:
    print("Yes")

Submission status: Runtime Error

Solution code:
def main():
    n, a, b, c, d = list(map(lambda x: int(x) - 1, input().split()))
    n += 1
    s = list(input())
    s = s[a:d + 1]
    for i in range(len(s) - 1):
        if s[i] == '#' and s[i + 1] == '#':
            print('No')
            exit()
    if c < d:
        print('Yes')
    else:
        ch = False
        for i in range(b, d + 1):
            if s[i - 1] == s[i] == s[i + 1] == '.':
                ch = True
        if ch:
            print('Yes')
        else:
            print('No')

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
##agc034_a
N,A,B,C,D = map(int, input().split()) #A→C、B→D #4≤N≤200,000
S = [0] + list(input())

#∴すれ違うには.の3連続が必要
#すれ違わなくても、#2連続があるとアウト

#すぬけ君かふぬけ君を選び、1 マス右か 2 マス右にジャンプさせる。
#このときジャンプ先にマスが存在しなければならない
#またそのマスに岩が置かれていたりもう一人がいてはならない。

#すれ違いが必要かを判定する
#A<B
#A<C
#B<D
#を利用すると下記の3パターンしかない。
if A < B < D < C:
    need_passing = True
elif (A < B < C < D) or (A < C < B < D):
    need_passing = False

#下記のように考える
#すれ違いが必要
    #Yes
        #すれ違い可能点(. . .)を列挙
        #A/B→すれ違い可能点へ行ける = 左記の区間に # # な並びがない
            #すれ違い可能点→C/Dへ行ける? = 左記の区間に # # な並びがない
    #No
        #A→CとB→Dで通行可能 = 左記の区間に # # な並びがない

passing_point_set = set() #すれ違い場所の始点のset
imos_stop = list() # "#"が2連続している場所で増加する。
imos_stop.append(0)

for i in range(1,N-1):
    if S[i] == S[i+1] == "#":
        imos_stop.append(imos_stop[-1] + 1)
    else:
        imos_stop.append(imos_stop[-1])

    if S[i] == S[i+1] == S[i+2] == ".":
        passing_point_set.add(i)

i += 1
if S[i] == S[i+1] == "#":
    imos_stop.append(imos_stop[-1] + 1)
else:
    imos_stop.append(imos_stop[-1])

imos_stop.append(imos_stop[-1])

#print(imos_stop)
#print(passing_point_set)

def is_reachable(start,goal):
    if imos_stop[start] == imos_stop[goal] and start < goal: #右に1か2マスにジャンプさせる ∴右方向にしか進めない
        return True
    else:
        return False

if need_passing == True:
    for passing_point in passing_point_set
        if is_reachable(A,passing_point) == is_reachable(passing_point,C) == is_reachable(B,passing_point) == is_reachable(passing_point,D) == True and D != passing_point and D != passing_point+2:
            #passing pointの範囲内にDがある場合、passingできない場合がある
            #ex.   A#..D#  …NG
            #ex.   A#D..#  …NG
            #ex.   A#..D.# …これはOK.ただし、.D.がpassing_pointになる
            print("Yes")
            break
    else:
        print("No")
else:
    if is_reachable(A,C) == is_reachable(B,D) == True:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
##agc034_a
N,A,B,C,D = map(int, input().split()) #A→C、B→D #4≤N≤200,000
S = [0] + list(input())

#∴すれ違うには.の3連続が必要
#すれ違わなくても、#2連続があるとアウト

#すぬけ君かふぬけ君を選び、1 マス右か 2 マス右にジャンプさせる。
#このときジャンプ先にマスが存在しなければならない
#またそのマスに岩が置かれていたりもう一人がいてはならない。

#すれ違いが必要かを判定する
#A<B
#A<C
#B<D
#を利用すると下記の3パターンしかない。
if A < B < D < C:
    need_passing = True
elif (A < B < C < D) or (A < C < B < D):
    need_passing = False

#下記のように考える
#すれ違いが必要
    #Yes
        #すれ違い可能点(. . .)を列挙
        #A/B→すれ違い可能点へ行ける = 左記の区間に # # な並びがない
            #すれ違い可能点→C/Dへ行ける? = 左記の区間に # # な並びがない
    #No
        #A→CとB→Dで通行可能 = 左記の区間に # # な並びがない

passing_point_set = set() #すれ違い場所の始点のset
imos_stop = list() # "#"が2連続している場所で増加する。
imos_stop.append(0)

for i in range(1,N-1):
    if S[i] == S[i+1] == "#":
        imos_stop.append(imos_stop[-1] + 1)
    else:
        imos_stop.append(imos_stop[-1])

    if S[i] == S[i+1] == S[i+2] == ".":
        passing_point_set.add(i)

i += 1
if S[i] == S[i+1] == "#":
    imos_stop.append(imos_stop[-1] + 1)
else:
    imos_stop.append(imos_stop[-1])

imos_stop.append(imos_stop[-1])

#print(imos_stop)
#print(passing_point_set)

def is_reachable(start,goal):
    if imos_stop[start] == imos_stop[goal] and start < goal: #右に1か2マスにジャンプさせる ∴右方向にしか進めない
        return True
    else:
        return False

if need_passing == True:
    for passing_point in passing_point_set
        if is_reachable(A,passing_point) == is_reachable(passing_point,C) == is_reachable(B,passing_point) == is_reachable(passing_point,D) == True
            and D != passing_point and D != passing_point+2:
            #passing pointの範囲内にDがある場合、passingできない場合がある
            #ex.   A#..D#  …NG
            #ex.   A#D..#  …NG
            #ex.   A#..D.# …これはOK.ただし、.D.がpassing_pointになる
            print("Yes")
            break
    else:
        print("No")
else:
    if is_reachable(A,C) == is_reachable(B,D) == True:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
flag1, flag2 = False, False
if d > c
    flag = "##" not in s[b: d] and "##" not in s[a: c]
else:
    flag = "..." in s[b: d]

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

Submission status: Runtime Error

Solution code:
from copy import deepcopy
def deal(s):
    stin=[]
    for i in range(len(s)):
        if s[i]==".":
            stin.append(0)
        else:
            stin.append(1)
    return stin
def dp(start,goal,stin):
    if goal<start or stin[goal-1]==1:
     #   print(start,goal)
      #  print(stin[goal-1])
       # print(stin)
        return False
    if start==goal:
        return True
    return dp(start,goal-1,stin) or dp(start,goal-2,stin)

n,a,b,c,d=map(int,input().split())
s=deal(input())
#print(s)
root=[]
if c<d:
    if dp(b,d,s):
       # print("ceh")
        if dp(a,c,s):
            print("Yes")
        else:
            print("No")
    else:
        print("No")
elif d<c:
    for i in range(b-1,d):
        if s[i]==0:
            q=deepcopy(s)
            q[i]=1
            root.append(q)
    #    print(root)
   # print("DAME")
    if dp(b,d,s):
        for x in root:
            if dp(a,c,x):
                print("Yes")
                exit()
        print("No")  
    else:
        print("No")
else:
    print("No")

Submission status: Runtime Error

Solution code:
from copy import deepcopy
def deal(s):
    stin=[]
    for i in range(len(s)):
        if s[i]==".":
            stin.append(0)
        else:
            stin.append(1)
    return stin
def dp(start,goal,stin):
    if goal<start or stin[goal-1]==1:
     #   print(start,goal)
      #  print(stin[goal-1])
       # print(stin)
        return False
    if start==goal:
        return True
    return dp(start,goal-1,stin) or dp(start,goal-2,stin)

n,a,b,c,d=map(int,input().split())
s=deal(input())
#print(s)
root=[]
if c<d:
    if dp(b,d,s):
       # print("ceh")
        if dp(a,c,s):
            print("Yes")
        else:
            print("No")
    else:
        print("No")
elif d<c:
    for i in range(b-1,d):
        if s[i]==0:
            q=deepcopy(s)
            q[i]=1
            root.append(q)
    #    print(root)
   # print("DAME")
    if dp(b,d,s):
        for x in root:
            if dp(a,c,x):
                print("Yes")
                exit()
        print("No")  
    else:
        print("aa")
        print("No")
else:
    print("No")

Submission status: Runtime Error

Solution code:
from copy import deepcopy
def deal(s):
    stin=[]
    for i in range(len(s)):
        if s[i]==".":
            stin.append(0)
        else:
            stin.append(1)
    return stin
def dp(start,goal,stin):
    if goal<start or stin[goal-1]==1:
     #   print(start,goal)
      #  print(stin[goal-1])
       # print(stin)
        return False
    if start==goal:
        return True
    return dp(start,goal-1,stin) or dp(start,goal-2,stin)

n,a,b,c,d=map(int,input().split())
s=deal(input())
#print(s)
root=[]
if c<d:
    if dp(b,d,s):
        print("ceh")
        if dp(a,c,s):
            print("Yes")
        else:
            print("No")
    else:
        print("No")
elif d<c:
    for i in range(b-1,d):
        if s[i]==0:
            q=deepcopy(s)
            q[i]=1
            root.append(q)
    #    print(root)
   # print("DAME")
    if dp(b,d,s):
        for x in root:
            if dp(a,c,x):
                print("Yes")
                exit()
        print("No")  
    else:
        print("aa")
        print("No")
else:
    print("No")

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,a,b,c,d=mp()
s=input()
if s[a-1]=="#" or s[b-1]=="#" or s[c-1]=="#" or s[d-1]=="#":
    print("No")
    exit()
for i in range(min(a,b)-1,max(c,d)):
    if s[i]=="#" and s[i+1]=="#":
        print("No")
        exit()
if d<c:
    ch=False
    for i in range(b-1,d):
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            ch=True
    if ch:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
else:
    print("Yes")

Submission status: Runtime Error

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

a = np.zeros(N+1)
b = np.zeros(N+1)
a[A-1] = 1
b[B-1] = 1

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

Submission status: Runtime Error

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

        for i in range(b-1,d-3):
            if s[i] == s[i+1] == s[i+2] and s[i] = '.':
                print('Yes')
                return
                

        print('No')



if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

        for i in range(a-1,c-3):
            if s[i] == s[i+1] == s[i+2] and s[i] == '.':
                print('Yes')
                return

        print('No')

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def main():
    #入力
    N, A, B, C, D = (int(_) for _ in input().split())
    S = input()

    sa, sb = S[A:C+1], S[B:D+1]
    can1 = can2 = True
    for i in range(len(sa)):
        if sa[i] == '#' and sa[i+1] == '#': can1 = False
    for i in range(len(sb)):
        if sb[i] == '#' and sb[i+1] == '#': can2 = False
    can = can1 and can2

    if can and D < C:
        sc = S[B-1:D]
        can3 = False
        for i in range(len(sc)-2):
            if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.': can3 = True
        can = can and can3

    print('Yes' if can else 'No')
    return

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n,a,b,c,d=map(int,input().split())
a-=1;b-=1;c-=1;d-=1 
from collections import deque 

queueA=deque([a])
queueB=deque([b])
S=input()
JinA=JinB=[0]*n 
if c<b or c<d:
    for i in range(a,d):
        if S[i]=="#" and S[i+1]=="#":
            print("No")
            exit() 
    else:
        print("Yes")
        exit()
    
else:
    for j in range(min(a,c),max(a,c)):
        if S[i]=="#" and S[i+1]=="#":
            print("No")
            exit() 
    for j in range(min(b,d),max(b,d)):
        if S[i]=="#" and S[i+1]=="#":
            print("No")
            exit() 
    for i in range(n-2):
        if S[i]==S[i+1]==S[i+2]==".":
            print("Yes")
            exit()
    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 
from collections import deque 

queueA=deque([a])
queueB=deque([b])
S=input()
JinA=JinB=[0]*n 
if c<b or c<d:
    for i in range(a,d):
        if S[i]=="#" and S[i+1]=="#":
            print("No")
            exit() 
    else:
        print("Yes")
        exit()
    
else:
    for j in range(a,max(c,d)):
        if S[i]=="#" and S[i+1]=="#":
            print("No")
            exit() 
    for i in range(n-2):
        if S[i]==S[i+1]==S[i+2]==".":
            print("Yes")
            exit()
    else:
        print('No')

Submission status: Runtime Error

Solution code:
n,a,b,c,d = map(int,input().split())
s = list(input())
for j in range(n):
    if s[j]=='#':
        able[j] = -1
        
if d<c:
    flag3 =  False
    for i in range(b,d):
        if s[i]=='.':
            if s[i-1]=='.':
                if s[i+1]=='.':
                    flag3 = True
                    
    if not flag3:
        print('No')
    else: 
        flag =True
        for i in range(b,d-1):
            if s[i]=="#" and s[i+1]=="#":
                flag = False

        for i in range(a,c-1):
            if s[i]=="#" and s[i+1]=="#":
                flag = False

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

else:
    flag =True
    for i in range(b,d-1):
        if s[i]=="#" and s[i+1]=="#":
            flag = False
        
    for i in range(a,c-1):
        if s[i]=="#" and s[i+1]=="#":
            flag = False

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
ans="Yes"
if c<b:
    for i in range(a-1,c-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
    if ans=="Yes":
        for i in range(b-1,d-1):
            if s[i]=="#" and s[i+1]=="#":
                ans="No"
                break
elif c<d:
    for i in range(a-1,d-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
else:
    cnt=0
    for i in range(a-1,c-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
    if ans=="Yes":
        for i in range(b-1,d):
            if s[i]==".":
                cnt+=1
                if cnt==3:
                    break
            else:
                cnt=0
        if cnt!=3:
            ans="No"
print(ans)n,a,b,c,d=map(int,input().split())
s=input()
ans="Yes"
if c<b:
    for i in range(a-1,c-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
    if ans=="Yes":
        for i in range(b-1,d-1):
            if s[i]=="#" and s[i+1]=="#":
                ans="No"
                break
elif c<d:
    for i in range(a-1,d-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
else:
    cnt=0
    for i in range(a-1,c-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
    if ans=="Yes":
        for i in range(b-1,d):
            if s[i]==".":
                cnt+=1
                if cnt==3:
                    break
            else:
                cnt=0
        if cnt!=3:
            ans="No"
print(ans)

Submission status: Runtime Error

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

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

cnt = 0
for i in range(a,max(c,d)+1):
    if s[i] == '#':
        cnt += 1
        if cnt >= 2:
            print('No')
            exit()
    else:
        cnt = 0

cnt = 0
if c > d:
    for i in range(b,d+1):
        if s[i] == '.':
            cnt += 1
            if cnt >= 3:
                if i-1 != d
                print('Yes')
                exit()
        else:
            cnt = 0
        if i == c:
            print('No')
            exit()
else:
    print('Yes')

Submission status: Runtime Error

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

flg = 0

if C < D:
   cnt = 0
    for i in range(A, D):
        if S[i] == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            flg = 1
            break

else:
    cnt = 0
    flg = 1
    for i in range(B-1, D+1):
        if S[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flg = 0
            break
if flg == 1:
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
if any(s[i]==s[i+1]=="#" for i in range(a-1, c-2)) or any(s[i]==s[i+1]=="#" for i in range(b-1, d-2)):
    print("No")
elif c<d:
    print("Yes")
else:
    for i in range(b-1, d-1):
        if s[i-1]==s[i]==s[i+1]==".":
            print("Yes")
            sys.exit()
    print("No")

Submission status: Runtime Error

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

"""
A<Bとする。
C<Dの場合：
A～CとB~Dの間に"##"が無ければ達成できる.
C>Dの場合：
上記に加え、B~Cの間に"..."が存在すれば達成できる
"""

n,a,b,c,d = map(int,readline().split())
s = readline().rstrip().decode('utf-8')
a,b,c,d = a-1,b-1,c-1,d-1

flag = 1
space = 0
res = 0
rock = 0
for i in range(a,c+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
for i in range(b,d+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
if c > d:
	for i in range(b-1,c+2):
		if s[i] == ".":
			space += 1
		else:
			res = max(res,space)
			space = 0
	if res < 3:
		flag = 0


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

Submission status: Runtime Error

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

a = A-1
b = B-1
c = C-1
d = D-1

ans = 1

for i_a in range(a,C):
  #2連続の##がa~Cにないことを確認
  if S[i_a] == "#":
    if S[i_a+1] == "#":
      ans =0

for i_b in range(b,D):
  #2連続の##がb~Dにないことを確認
  if S[i_b] == "#":
    if S[i_b+1] == "#":
      ans =0

if D < C:
  ans = 0
  for i in range(b-1,D+1):
    #3連続があるなら1
    if S[i] == ".":
      if S[i+1] == ".":
        if S[i+2] == ".":
          ans = 1

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

Submission status: Runtime Error

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

a = A-1
b = B-1
c = C-1
d = D-1

ans = 1

for i_a in range(a,C):
  #2連続の##がa~Cにないことを確認
  if S[i_a] == "#":
    if S[i_a+1] == "#":
      ans =0

for i_b in range(b,D):
  #2連続の##がb~Dにないことを確認
  if S[i_b] == "#":
    if S[i_b+1] == "#":
      ans =0

if D < C:
  ans = 0
  for i in range(b-1,D+1):
    #3連続があるなら1
    if S[i] == ".":
      if S[i+1] == ".":
        if S[i+2] == ".":
          ans = 1

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()
M=0
if C>D:
	for i in range(min(A,B)-1,C):
		if S[i]==".":
			if S[i-1]=="." and S[i+1]==".":
				M+=1
	if M==0:
		print("No")
		exit()
	else:
		if S[C-1]=="#":
			print("No")
			exit()
		else:
			for i in range(A-1,C):
				if S[i]=="#":
					if S[i+1]=="#":
						print("No")
						exit()
			if S[D-1]=="#":
				print("No")
				exit()
			else:
				for i in range(B-1,D):
					if S[i]=="#":
						if S[i+1]=="#":
							print("No")
							exit()
print("Yes")