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: Accepted

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

"""
基本的にはシャープが2連続するとだめ
ただし，片方が間に必ず入っている場合は，...が三連続するところがないとダメ
"""

if A<B and C>D:
    for i in range(B-2,D-1):
        if S[i:i+3] == [".", ".", "."]:
            print("Yes")
            exit()
    print("No")
    exit()
elif A>B and C<D:
    for i in range(A-2,C-1):
        if S[i:i+3] == [".", ".", "."]:
            print("Yes")
            exit()
    print("No")
    exit()
else:
    for i in range(min(A,B)-1, max(C,D)-1):
        if S[i] == S[i+1] == "#":
            print("No")
            exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# A - Kenken Race

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

should_change = int(C>D)
can_change = 0
space = 1
ans = 'Yes'

for i in range(A,max(C,D)):
    if S[i]=='.':
        space += 1
        if B<=i<=D and space==3:
            can_change = 1
    else:
        if space==0:
            ans = 'No'
            break
        space = 0

if can_change<should_change:
    ans = 'No'
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split());s=input()
if c<=d:
  if "##"in s[a-1:c] or"##"in s[b-1:d]:print("No")
  else:print("Yes")
else:
  if "..." not in s[max(0,b-2):d+1]:print("No");exit()
  if "##"in s[a-1:c] or"##"in s[b-1:d]:print("No")
  else:print("Yes")

Submission status: Accepted

Solution code:
_, A, B, C, D = map(lambda n: int(n) - 1, input().split())
S = input()
if S.count("##", A, D):
    print("No")
elif C < D:
    print("Yes")
elif S.count("...", B - 1, D + 2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

s = A
f = B
flag = True
if C < D:
    if '##' in S[A-1:C]:
        flag = False
    if '##' in S[B-1:D]:
        flag = False

else:
    if S[D - 2] == '#':
        if '...' not in S[B-2:D]:
            flag = False
    if '##' in S[A-1:C]:
        flag = False
ans = 'Yes' if flag else 'No'
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, a, b, c, d = map(int, input().split())
S = input()
if c < d:
    if "##" in S[a-1:d]:
        print("No")
    else:
        print("Yes")
else:
    f = S[b-2:d+1].find("...")
    if f != -1 and ("##" not in S[a-1:c]):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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

Submission status: Accepted

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-2,d-1):
        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: Accepted

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

if '##' in S[A-1:max(C, D)]:
    print('No')
elif C < D:
    print('Yes')
else:
    print('Yes' if '...' in S[B-2:D+1] else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,a,b,c,d = map(int, stdin.readline().rstrip().split())
#numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
#zeros = [[0] * w for i in range(h)]
s = str(stdin.readline().rstrip())

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-2:d+1]:
            print("Yes")
        else:
            print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b,c,d = map(int, input().split())
a-=1
b-=1
c-=1
d-=1
s = input()
s+='X'
ch=1
v=[]
st=[]
if s[0]=='#':
    v.append((0,0))
for i in range(1,n+1):
    if s[i]==s[i-1]:
        ch+=1
    else:
        v.append((ch,i-ch))
        ch=1
judge=[]
for i in range(len(v)):
    if i%2==1:
        x,y=v[i]
        if x>=2 and ((a < y and y < c) or (b < y and y < d)):
            print('No')
            exit()
    else:
        x,y=v[i]
        if x>=3:
            judge.append((y,y+x-1))
check=1
if (a<b and d<c) or (b<a and c<d):
    check = 0
    while judge:
        t1,t2=judge.pop()
        if t2>a and t2>b and t1<c and t1<d:
            check = 1
if check == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
if c<d:
  if "##" not in s[a-1:d]:
    print("Yes")
  else:
    print("No")
else:
  if "..." in s[b-2:d]:
    print("Yes")
  else:
    if s[d-2]=="#":
      print("No")
    else:
      print("Yes")

Submission status: Accepted

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
canA = "##" not in S[A-1:C]
canB = "##" not in S[B-1:D]
if C < D:
    if canA and canB:
        print("Yes")
    else:
        print("No")
else:
    if canA and canB and ("..." in S[B-2:D+1]):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = int(input())
n, a, b, c, d  = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s  = input()
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

is_rock2 = '##' in s[a:d+1]
is_empty3 = '...' in s[b-1:d+2]

joken = (not is_rock2) and (is_empty3 if c > d else 1)
print('Yes' if joken else 'No')

Submission status: Accepted

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

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

#hunuke

h = S[A-1:D+1].count('##')
m3 = S[B-2:D+1].count('...')

if C < D:
    if h == 0: print('Yes')
    else: print('No')
else:
    if m3 != 0 and h == 0:
        print('Yes')
    else: print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:

from re import search
def myAnswer(N:int,A:int,B:int,C:int,D:int,S:str) -> str:
   if (search(r'##',S[A-1:max(C,D)])): return "No"
   if(C > D):
      return "Yes" if (search(r'\.\.\.',S[B - 2:D+1])) else "No"
   return "Yes"

def modelAnswer():
   return
def main():
   N,A,B,C,D = map(int,input().split())
   S = input()
   print(myAnswer(N,A,B,C,D,S))
if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools

import copy

# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, a, b, c, d = ns()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = list(input())

    stone_twice_flg = True
    for i in range(a, max(c, d)):
        if s[i] == s[i + 1] == "#":
            stone_twice_flg = False
            break

    pass_flg = False
    if c > d:
        for i in range(b, d+1):
            if s[i - 1] == s[i] == s[i + 1] == ".":
                pass_flg = True
                break
    else:
        pass_flg = True

    if stone_twice_flg and pass_flg:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import re
N,A,B,C,D = (int(x) for x in input().split())
S = input()
if re.search(r'##',S[A-1:max(C,D)]):
    print('No')
else:
    if D < C:
        if re.search(r'\.\.\.',S[B-2:D+1]):
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    int1 = lambda x: int(x) - 1
    N, A, B, C, D = map(int1, input().split())
    S = input()

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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


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

    can_jump_R = True  # '##'
    can_jump_B = False  # '...'
    for i in range(A + 1, N - 1):
        if S[i] == S[i+1] == "#":
            if A < i < C or B < i < D:
                can_jump_R = False
        if S[i-1] == S[i] == S[i+1] == ".":
            if B <= i < C and i-1 != D:
                can_jump_B = True

    if C < D:
        if can_jump_R:
            ans = "Yes"
        else:
            ans = "No"
    else:
        if can_jump_R and can_jump_B:
            ans = "Yes"
        else:
            ans = "No"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 'Yes'
if s[a:c].find('##') > -1:
    ans = 'No'
elif s[b:d].find('##') > -1:
    ans = 'No'
else:
    if d < c:
        if s[b-2:d+1].find('...') == -1:
            ans = 'No'

print(ans)

Submission status: Accepted

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):
            if s[i-1] == s[i] == s[i+1] and s[i] == '.':
                print('Yes')
                return


        print('No')



if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

for i in range(a + 1, max(c, d) - 1):
    if s[i: i + 2] == '##':
        print('No')
        sys.exit()

if c < d:
    print('Yes')
    sys.exit()

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

print('No')

Submission status: Accepted

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

if('##' in s[a-1:d]):
    print('No')
    exit()
if(c < d):
    print('Yes')
else:
    if('...' in s[b-2:d+1]):
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
if d<c:
    if "##" not in s[a-1:d] and '...' in s[b-2:d+1]:
        print('Yes')
    else:
        print('No')
    
else:
    if "##" not in s[a-1:d]:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

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

if S[A-1:C].find('##') != -1 or S[B-1:D].find('##') != -1:
    print('No')
    exit()

ans = 'Yes'
if C > D and S[B-2:D+1].find('...') == -1:
    ans = 'No'
print(ans)

Submission status: Accepted

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

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

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if "##" in s[a:max(c,d)]:print("No")
elif c>d and "..." not in s[b-2:d+1]:print("No")
else:print("Yes")

Submission status: Accepted

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
if d<c:
    if "##" not in s[a-1:d] and '...' in s[b-2:d+1]:
        print('Yes')
    else:
        print('No')
    
else:
    if "##" not in s[a-1:d]:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

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

def solve(E, x, y, G):
    if y != -1:
        E[y-1] = '#'
    dp = [0]*N
    dp[x-1] = 1
    for i in range(2, N):
        if dp[i-2] or dp[i-1]:
            if E[i] == '.':
                dp[i] = 1
    # print(dp)
    return dp[G-1]

if C < D:
    p = solve(S, B, -1, D)
    q = solve(S, A, -1, C)
else:
    bla = 0
    idx = -1
    for i in range(B-2, N):
        if S[i] == '.':
            bla += 1
        else:
            bla = 0
        if bla == 3:
            idx = i
            break
    # print(idx)
    if idx == -1:
        print('No')
        exit()
    else:
        if D - 1 <= idx - 2:
            print('No')
            exit()

    p = solve(S, A, -1, C)
    q = solve(S, B, -1, D)
    # print(p, q)

if p and q:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

if c<d:
    if s[min(a,b)-1:d+1].count("##")==0:
        print("Yes")
    else:
        print("No")
else:
    if s[min(a,b)-1:d+1].count("##")==0:
        if s[max(a,b)-2:d+1].count("...")==0:
            print("No")
        else:
            print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    flg = False
    for i in range(a, d):
        if s[i] == "#":
            if s[i + 1] == "#":
                print("No")
                break

        if b - 1 <= i:
            if i + 1 < n:
                if s[i - 1] == s[i] == s[i + 1] == ".":
                    flg = True
    else:
        if c < d:
            print("Yes")
        else:
            if flg:
                print("Yes")
            else:
                print("No")


if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

# 2個以上の岩があればNG
if "##" in s[a:max(c,d)]:
    print("No")
    exit()

# AがBを抜けるかどうか
if d < c and not "..." in s[b-1:d+2]:
    print("No")
    exit()

print("Yes")

Submission status: Accepted

Solution code:
n,a,b,c,d = map(int,input().split())
s = '.'+input()
i=a
f = True
while i<c:
    if s[i+1]=='.':
        i += 1
    elif i<c-1 and s[i+2]=='.':
        i += 2
    else:
        f = False
        break
i = b
ok = False
while i<d:
    if s[i-1:i+2]=='...':
        ok = True
    if s[i+1]=='.':
        i += 1
    elif i<d-1 and s[i+2]=='.':
        i += 2
    else:
        f = False
        break
if d<n and s[d-1:d+2]=='...':ok=True
if d<c and not ok:f=False
print('Yes' if f else 'No')

Submission status: Accepted

Solution code:
def no():
    print("No")
    exit()

n, a, b, c, d = map(int, input().split())
s = list(input())
for i in range(a - 1, c - 1):
    if s[i] == s[i + 1] == "#":
        no()
for i in range(b - 1, d - 1):
    if s[i] == s[i + 1] == "#":
        no()
if c > d:
    t = 0
    for i in range(b - 2, d - 1):
        if s[i] == s[i + 1] == s[i + 2] == ".":
            t = 1
    if t == 0:
        no()
print("Yes")

Submission status: Accepted

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

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

Submission status: Accepted

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


if c<d:
    for i in range(b,d):
        if s[i]==s[i+1]=="#":
            print("No")
            exit()
    for i in range(a,c):
        if s[i]==s[i+1]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

flag = False
for i in range(b-1,d):
    if s[i]==s[i+1]==s[i+2]==".":
        flag = True
        break
if not flag:
    print("No")
    exit()

for i in range(b,d):
    if s[i]==s[i+1]=="#":
        print("No")
        exit()
for i in range(a,c):
    if s[i]==s[i+1]=="#":
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
flag=0
for i in range(n):
  if a-1<=i<=c-1 or b-1<=i<=d-1:
    if flag==1 and s[i]=="#":
      print("No")
      exit()
    elif flag==0 and s[i]=="#":
      flag=1
    elif s[i]==".":
      flag=0

m=0
con=0
if d<c:
  for i in range(b-2,d+1):
    if s[i]==".":
      con+=1
      m=max(m,con)
    else:
      con=0
  if m>=3:
    print("Yes")
    exit()
  else:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b,c,d=map(int,input().split())
    s=input()
    for i in range(a,max(c,d)):
        if i+2<=n:
            if s[i:i+2]=='##':
                print("No")
                break
    else:
        if c<d:
            print("Yes")
        else:
            flag=False
            for i in range(b-1,d):    
                if s[i-1:i+2]=="...":
                    flag=True
            if flag==True:
                print("Yes")
            else:
                print("No")

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
def check(s):
    for i in range(len(s) - 1):
        if s[i] == '#' and s[i + 1] == '#':
            return False
    return True


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


N, A, B, C, D = map(int, input().split(" "))
S = input()
A -= 1; B -= 1; C -= 1; D -= 1;

if C < D:
    if check(S[A:C+1]) and check(S[B:D+1]):
        print('Yes')
    else:
        print('No')
else:
    if checksp(S[B-1:D+2]) and check(S[B:D+1]) and check(S[A:C+1]):
        print('Yes')
    else:
        print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N, A, B, C, D = map(int, rl().split())
    S = input()
    
    if C < D:
        if S[A - 1:D].find('##') == -1:
            print('Yes')
        else:
            print('No')
    else:
        if S[B - 2:D + 1].find('...') == -1:
            print('No')
        else:
            print('Yes')


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

s=input()

s=list(s)

for i in range(a,max(c,d)):
    if s[i-1] == s[i] == '#':
        print('No')
        exit()

if c < d:
    print('Yes')
else:
    for i in range(b-2,d-1):
        if s[i] == s[i+1] == s[i+2] == '.':
            print('Yes')
            exit()
    print('No')

Submission status: Accepted

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

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

def can_reach(start, end):
    for i in range(start, end + 1):
        if S[i] == '#' and S[i + 1] == '#':
            return False
    return True


if not can_reach(A, C) or not can_reach(B, D):
    print("No")
    exit()

if C > D:
    cover = False
    for i in range(B, D + 1):
        if S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
            cover = True
    if not cover:
        print("No")
        exit()


print("Yes")

Submission status: Accepted

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

if "##" in S[A:C] or "##" in S[B:D]:
  print("No")
  exit()

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

Submission status: Accepted

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

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

Submission status: Accepted

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-2,d+1):
            if s[i]==".":
                cnt+=1
                if cnt==3:
                    break
            else:
                cnt=0
        if cnt!=3:
            ans="No"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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 b >= 2:
    if s[b-2] == '.' and s[b-1] == '.':
        cnt = 2

if s[b-1] == '.':
    cnt = 1

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

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
# a->c, b->d
# a<b
if c>d:
  if '...' in s[b-2:d+1]:
    if '##' in s[a:c]:
      print('No')
      exit()
  else:
    print('No')
    exit()

else:
  if '##' in s[a:c]:
    print('No')
    exit()
  if '##' in s[b:d]:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

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

flg = 0
cnt = 0
S_ac = S[A:C]
S_bd = S[B:D]

if '##' in S_ac or '##' in S_bd:
    flg = 1

if D < C and flg == 0:
    S = S[B-2:D+1]
    if '...' not in S:
        flg = 1

if flg == 1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

if "##" in S[A - 1: C] or "##" in S[B - 1: D]:
    print("No")
    exit(0)

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

ans = False
for i in range(B - 1, D):
    if (S[i - 1] == '.') and (S[i] == '.') and (S[i + 1] == '.'):
        ans = True
        break

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