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=input()
result = ""

for i in range(A,max(C,D)):
    if S[i:i+2]=="##":
        result = "No"
        break

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

if result == "":
    result = "No"

print(result)

Submission status: Accepted

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

for i in range(A,max(C,D)-1):
    if S[i:i+2]=="##":
        result ="No"
        break

if result == "":
    if C < D:
        result ="Yes"
    else: # D < C
        if S[B-2] == "." and S[B] == ".":
            result = "Yes"
        else:
            for i in range(B-2,D-1):
                if S[i:i+3] == "...":
                    result = "Yes"
            #if S[B-2:D+1].count('...')>0:
            #    result = 'Yes'
      
if result == "":
    result = "No"

print(result)

Submission status: Accepted

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

for i in range(A,max(C,D)-1):
    if S[i:i+2]=="##":
        result ="No"
        break

if result == "":
    if C < D:
        result ="Yes"
    else: # D < C
        if S[B-2] == "." and S[B] == ".":
            result = "Yes"
        else:
#            for i in range(B-2,D+1):
#                if S[i:i+3] == "...":
#                    result = "Yes"
            if S[B-2:D+1].count('...')>0:
                result = 'Yes'
      
if result == "":
    result = "No"

print(result)

Submission status: Accepted

Solution code:
figure=input()
math=input()
flg=False
 
figure=figure.split(' ')
if figure[3]>figure[4]:
  flg=True
  
for i in range(max(int(figure[3]),int(figure[4]))-1):
  if math[i]=='#' and math[i+1]=='#':
    if i>int(figure[1]) and i<int(figure[3])-1 or i>int(figure[2]) and i<int(figure[4])-1:
    	print('No')
    	exit()
    
  if flg and i>=int(figure[2])-2 and i<int(figure[4])-1 and math[i]=='.' and math[i+1]=='.' and math[i+2]=='.':
    flg=False

if not flg:
	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:C-1] or "##" in S[B:D-1]:
    print("No")
    exit()
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 = str(input())

ans = 'Yes'
if '##' in s[a-1:c] or '##' in s[b-1:d]:
    ans = 'No'

if ans == 'Yes':
    if c<d:
        pass
    else:
        if '...' in s[b-2:d+1]:
            pass
        else:
            ans = 'No'

print(ans)

Submission status: Accepted

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

if A < C < B < D:
    if not (S.find("##", A - 1) < C - 1 and S.find("##", A - 1) != -1) and not (
            S.find("##", B - 1) < D - 1 and S.find("##", B - 1) != -1):
        print("Yes")
    else:
        print("No")
elif C < D:
    if S.find("##", A - 1) > D - 1 or S.find("##", A - 1) == -1:
        print("Yes")
    else:
        print("No")
else:
    if S.find("...", B - 2) < D - 1 and S.find("...", B - 2) != -1:
        if S.find("##", A - 1) > C - 1 or S.find("##", A - 1) == -1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
count1 = 0
count2 = 0
if C>D:
    for i in range(B-2,D+1):
        if S[i] == ".":
            count1 += 1
            if count1 ==3:
                break
        else:
            count1 = 0
    for i in range(A-1,C):
        if S[i] == '#':
            count2 +=1
            if count2 == 2:
                break
        else:
            count2 =0
    if count1 == 3 and count2 !=2:
        print("Yes")
    else:
        print("No")
else:
    for i in range(A-1,D):
        if S[i] == "#":
            count2 += 1
            if count2 == 2:
                break
        else:
            count2 = 0
    if count2 != 2:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
ll= lambda : list(map(int,input().split()))
testcases=1
#testcases=int(input())
for testcase in range(testcases):
	[N,A,B,C,D]=ll()
	s=input() 
	index = [(n+1) for n, v in enumerate(s) if s[n:n+3] == "..."]
	if C < D:
	    if "##" in s[A-1:D]:
	        print("No")
	    else:
	        print("Yes")
	 
	if C > D:
	    if "##" in s[A-1:C]:
	        print("No")
	    else:
	        if len(index)>=1:
	            for i in index:
	                if B <= i+1 <= D:
	                    print("Yes")
	                    exit()
	            print("No")
	        else:
	            print("No")

Submission status: Accepted

Solution code:
n,s=open(0);n,a,b,c,d=map(int,n.split());print('YNeos'['##'*('...'*(d<c)in s[b-2:d+1])in s[a:d]::2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split());s=input();t=s[b-2:d+1];print('YNeos'['##'*('...'*(d<c)in t)in s[a:c]+t::2])

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split());s=input();print('YNeos'[not'...'*(d<c)in s[b-2:d+1]or'##'in s[a:d]::2])

Submission status: Accepted

Solution code:
N,A,B,C,D = map(int, input().split())
s = input()
index = [(n+1) for n, v in enumerate(s) if s[n:n+3] == "..."]

if C < D:
    if "##" in s[A-1:D]:
        print("No")
    else:
        print("Yes")

if C > D:
    if "##" in s[A-1:C]:
        print("No")
    else:
        if len(index)>=1:
            for i in index:
                if B <= i+1 <= D:
                    print("Yes")
                    exit()
            print("No")
        else:
            print("No")

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split());s=input();t=s[b-2:d+1];print('YNeos'[not'...'*(d<c)in t or'##'in s[a:c]+t::2])

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
f=0;F=0
for i in range(a,max(c,d)-1):
  if s[i:i+2]=='##':f=1
for i in range(b-2,min(c,d)-1):
  if s[i:i+3]=='...':F=1
if F==0 and c>d:f=1
print('YNeos'[f::2])

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split());s=input();print('YNeos'[not'...'*(d<c)in s[b-2:d+1]or'##'in s[a:c]+s[b:d]::2])

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
f=0;F=0
for i in range(a,max(c,d)-1):
  if s[i]=='#' and s[i+1]=='#':f=1
for i in range(b-2,min(c,d)-1):
  if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':F=1
if F==0 and c>d:f=1
print('YNeos'[f::2])

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split());s=input();print('YNeos'[not'...'in s[b-2:d+1]and d<c or'##'in s[a:c]+s[b:d]::2])

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split());s=input();print('YNeos'[1-('...'in s[b-2:d+1])and d<c or'##'in s[a:c]+s[b:d]::2])

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:
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")
else:
  if c < d:
    print("Yes")
  else: # C > D
    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();print('YNeos'['##'in s[a:c]+s[b:d]or(1-('...'in s[b-2:d+1]))*(d<c)::2])

Submission status: Accepted

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

Submission status: Accepted

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

s = input()

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000)
 
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()

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

if S[B-2] != "#" and S[B] == ".":
    print("Yes")
    exit()
    
if S[B-2] == "#" and S[B] == "." and S[B+1] == ".":
    print("Yes")
    exit()

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

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split())
s=list(input())
f=0
for i in range(b,d-1):
  if s[i]=='#' and s[i+1]=='#':
    f=1
    break
for i in range(a,c-1):
  if s[i]=='#' and s[i+1]=='#':
    f=1
    break
if c>d:
  F=0
  for i in range(b-2,d-1):
    if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
      F=1
      break
  if F==0:
    f=1
if f==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:c]or'##'in s[b:d]or d<c 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()
s = s + "."
cant = 0
sanrenzoku = 0
for i in range(a-1,max(c-1,d-1)):
    if s[i] == "#":
        if s[i+1] == "#":
            cant = 1

if c > d:
    for i in range(b-2,d-1):
        if s[i] == ".":
            if s[i+1] == ".":
                if s[i+2] == ".":
                   sanrenzoku = 1

if cant == 1:
    print("No")
elif c > d:
    if sanrenzoku == 0:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")

Submission status: Accepted

Solution code:
def passable(road):
    n=len(road)
    for i in range(n-1):
        block=road[i:i+2]
        if block=='##':
            return False
    return True

def blank(road):
    n=len(road)
    for i in range(1,n-1):
        block=road[i-1:i+2]
        if block=='...':
            return True
    return False

def judge(A,B,C,D,S):
    if C<D:
        return passable(S[A:C+1]) and passable(S[B:D+1])
    else:
        return passable(S[A:C+1]) and passable(S[B:D+1]) and blank(S[B-1:D+2])
N,A,B,C,D=map(int,input().split())
S=input()
if judge(A-1,B-1,C-1,D-1,S):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N, A, B, C, D = map(int,input().split())
S = input()
slist = list(S)
buf = "".join(slist[A:max(C,D)-1])
 
judge = buf.find("##")
 
if judge != -1:
  print("No")
else:
  if C < D:
    print("Yes")
  else:
    s_change= "".join(slist[B-2:D+1])
    judge = s_change.count("...")
    if judge > 0:
      print("Yes")
    else:
      print("No")

Submission status: Accepted

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

a_to_c = s[(a-1)+1:(c-1)-1 +1]

possibility = True

if c>d:
    b_to_d = s[(b-1)-1:(d-1)+1 +1]
    if "##" in a_to_c or "..." not in b_to_d:
        possibility = False
else:
    b_to_d = s[(b-1)+1:(d-1)-1 +1]
    if "##" in a_to_c or "##" in b_to_d:
        possibility = False

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

Submission status: Accepted

Solution code:
#Python標準入出力

import numpy as np

# 1行に複数の文字列（数字）を取得，整数に直す
# 今回は2つ受け取って，足し算する

# 0 len root 1 sunuke 2 funuke 3 point1 4 point2 funuke
Masu = list(map(int, input().split()))
Root = input()

N = Masu[0]
A = Masu[1]
B = Masu[2]
C = Masu[3]
D = Masu[4]

S = Root

At = A-1
Bt = B-1
Ct = C-1
Dt = D-1

Judge = True

#Answer 1 パターン入れ込み

# print(Root[Bt:Dt])


threePoints = False

if C < D:
    if "##" in Root[At:Dt+1]:
        Judge = False
else:

    if "##" in Root[At:Ct+1]:
        Judge = False

    if "..." in Root[Bt-1:Dt+2]:
        threePoints = True

    Judge = threePoints

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




    # Rock = []
    # for i in range(Masu[0]):
    #     if Root[i] == "#":
    #         Rock.append(i+1)



    # print(threePoints)
    # for j in range(N):
    #     if S[j] == "#" and S[j-1] == "#":
    #         Judge = False
    #
    #     if C == j+1 and D == j+1-1 and Root[j-2] == "#" and threePoints:
    #         Judge = False
    #     if C == j+1 and Root[j-1] == "#" and D == j+1-2 and threePoints:
    #         Judge = False
    #
    #     # if Masu[3] == j+1:
    #     #     for p in range(j):
    #     #         if Masu[4] == p+1 and Root[p-1] == "#":
    #     #             Judge = False




    #Answer 2 動かし

# Sunuke = At
# Funuke = Bt
# throuth = 0
#
#
# if C < D:
#     for i in range(N-Funuke):
#
#         ii = i+Bt
#
#         # print("current {0}: funuke: {1}".format(ii,Funuke))
#         if Funuke == Dt:
#             break
#
#         elif S[ii] == "#" and S[ii+1] == "#":
#             Judge = False
#             break
#
#         elif S[ii] == "#":
#             throuth = 0
#
#         elif S[ii+1] == ".":
#             Funuke = Funuke+1
#
#         elif S[ii+1] == "#":
#             Funuke = Funuke+2
#
#     #
#     # print("Funuke: {}".format(Funuke))
#     # print("Sunuke: {}".format(Sunuke))
#     # print(At)
#     if Judge:
#         for j in range(N-Sunuke):
#
#             jj = j+At
#             # print("current {0}: Sunuke: {1}".format(jj, Sunuke))
#
#             if Sunuke == Ct:
#                 break
#
#             elif S[jj] == "#" and jj + 1 == Funuke:
#                 Judge = False
#                 break
#
#             elif S[jj] == "#":
#                 throuth = 0
#
#             elif S[jj + 1] == ".":
#                 Sunuke = Sunuke + 1
#
#             elif S[jj + 1] == "#" or jj+1 == Funuke:
#                 Sunuke = Sunuke + 2
#
#     #
#     # print(Sunuke)
#     # print(Funuke)
#     #
#
# else:
#     Rock = []
#     for i in range(Masu[0]):
#         if Root[i] == "#":
#             Rock.append(i + 1)
#
#     threePoints = False
#
#     for k in range(N):
#         if k < 1:
#             gg = 0
#         elif S[k] == "." and S[k - 1] == "." and S[k - 2] == ".":
#             # print("roop{}".format(k))
#             if D+1 > k:
#                 threePoints = True
#
#     # print(threePoints)
#
#     for j in range(Masu[0]):
#         if S[j] == "#" and S[j - 1] == "#":
#             Judge = False
#
#         if C == j + 1 and D == j + 1 - 1 and Root[j - 2] == "#" and (not threePoints):
#             Judge = False
#         if C == j + 1 and Root[j - 1] == "#" and D == j + 1 - 2 and (not threePoints):
#             Judge = False
#
#             # if Masu[3] == j+1:
#             #     for p in range(j):
#             #         if Masu[4] == p+1 and Root[p-1] == "#":
#             #             Judge = False
#
# if Judge:
#     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, c - 2):
    if s[i] == "#" and s[i + 1] == "#":
        print("No")
        exit()
for i in range(b, d - 2):
    if s[i] == "#" and s[i + 1] == "#":
        print("No")
        exit()
if c > d:
    f = s[b - 2:d + 1].find("...")
    if f == -1:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

# A->CかB->Dどっちかの区間に##があったらfalse
# B<Cが保証されないから両方やる
if C<D:
    tmp_s = 0
    for s in S[A-1:C]:
        if s == '#' and tmp_s>0 :
            clear = False
            break
        elif s == '#':
            tmp_s += 1
        else:
            tmp_s = 0

    tmp_s = 0
    for s in S[B-1:D]:
        if s == '#' and tmp_s>0 :
            clear = False
            break
        elif s == '#':
            tmp_s += 1
        else:
            tmp_s = 0

    if clear == True:
        print('Yes')
    else:
        print('No')
    
# A<B<D<Cだから、AがBを追い抜くスペースが必要
# _B-D_の中に...があればOKっぽい
elif D<C:
    # とりま##の可能性を見る
    tmp_s = 0
    for s in S[A-1:C]:
        if s == '#' and tmp_s>0 :
            clear = False
            break
        elif s == '#':
            tmp_s += 1
        else:
            tmp_s = 0
    # ...を探す
    if clear == True:
        tmp_s = 0
        tmp_d = 0
        clear = False
        for s in S[B-2:D+1]:
            if s == '.' and tmp_d>=2 : # ...
                tmp_s += 1
                clear = True
            elif s == '.' and tmp_s>=0: # #->.
                tmp_d += 1
                tmp_s = 0
            elif s == '#' and tmp_d>=0: # .->#
                tmp_s += 1
                tmp_d = 0
        if clear == True:
            print('Yes')
        else:  
            print('No')
    else:
        print('No')

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(100000000)
 
N, A, B, C, D = map(int, input().split())
s = list(input())
 
A -= 1
B -= 1
C -= 1
D -= 1
 
for i in range(len(s)):
    if i == len(s) - 1:
        continue
    else:
        if s[i] == '#' and s[i+1] == '#' and max(C, D) < i and i <= C:
            print("No")
            exit()
 
if D < C:
    tmp = 0
    for i in range(len(s)):
        if i == len(s) - 2 or i == len(s) - 1:
            continue
        else:
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' and B <= i + 1 <= D:
                tmp = 1
    if tmp != 1:
        print("No")
        exit()
 
 
 
def check(s, start, goal, ans):
    if start == goal:
        return 1
    if s[start] == '#':
        return 0
    if start + 1 <= N - 1:
        ans += check(s, start + 1, goal, ans)
    if start + 2 <= N - 1:
        ans += check(s, start + 2, goal, ans)
    return ans
 
ans = 0
if not check(s, B, D, ans):
    print("No")
    exit()
#s[D] = '#'
if not check(s, A, C, ans):
    print("No")
    exit()
print("Yes")

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

a,b,c,d=a-1,b-1,c-1,d-1
if a > b:
    a, b, c, d = b, a, d, c


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

    else:
        if '...' in s[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()[:max(c,d)]
 
def main():
    if "##" in s[b:d-2]:
        return "No"
    if "##" in s[a:c-2]:
        return "No"
 
    if c < d:
        return "Yes"
    
    else:
 
        if "..." in s[b-2:d+1]:
            return "Yes"
                
        return "No"
 
print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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')
else:
    if c < d:
        print('Yes')
    else:
        if '...' in s[b - 2:d + 1]:
            print('Yes')
        else:
            print('No')

Submission status: Accepted

Solution code:
import math
import numpy as np
 
 
def inputs(): return list(map(int, input().split()))
 
 
def main():
    _, A, B, C, D = inputs()
    S = input()
    maxDst = max(C, D)
    courseA = S[A-1:C]
    courseB = S[B-1:D]
    cnt = 0
    ans = []
    for i in courseB:
        if i == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            ans.append(False)
            break
    else:
        ans.append(True)
    cnt = 0
    for i in courseA:
        if i == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            ans.append(False)
            break
    else:
        ans.append(True)
    if D < C:
        if '...' in S[B-2: D+1]:
            ans.append(True)
        else:
            ans.append(False)

    if all(ans):
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)
 
 
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python
 
import sys
import re
 
_,a,b,c,d = [ int(x)-1 for x in sys.stdin.readline().split() ]
m = sys.stdin.readline().strip()
#
if c>d:
    if m[b-1:d+2].find("...")<0:
        print( "No" )
        exit()
else:
    # b -> d
    if m[b+1:d].find("##")>=0:
        print( "No" )
        exit()
    #
    # a -> c
    if m[a+1:c].find("##")>=0:
        print( "No" )
        exit()

print( "Yes" )

Submission status: Accepted

Solution code:
N, A, B, C, D = map(int, input().split())
S = list(input())
S[A - 1] = 'A'
S[B - 1] = 'B'
a1 = 0
a2 = 0
ans = ''
if C > D:
    a1 = 'A'
    a2 = 'B'
    tmp1 = C - 1
    tmp2 = D - 1
    now1 = A - 1
    now2 = B - 1
else:
    a1 = 'B'
    a2 = 'A'
    tmp1 = D - 1
    tmp2 = C - 1
    now1 = B - 1
    now2 = A - 1

while True:
    if now1 != tmp1:
        if now1 + 1 <= len(S) - 1 and S[now1 + 1] == '.' and now1 + 1 <= tmp1:
            S[now1] = '.'
            S[now1 + 1] = a1
            now1 += 1
        elif now1 + 2 <= len(S) - 1 and S[now1 + 2] == '.' and now1 + 2 <= tmp1:
            S[now1] = '.'
            S[now1 + 2] = a1
            now1 += 2
        elif now2 + 1 <= len(S) - 1 and S[now2 + 1] == '.' and now2 + 1 <= tmp2:
            S[now2] = '.'
            S[now2 + 1] = a2
            now2 += 1
        elif now2 + 2 <= len(S) - 1 and S[now2 + 2] == '.' and now2 + 2 <= tmp2:
            S[now2] = '.'
            S[now2 + 2] = a2
            now2 += 2
        else:
            ans = 'No'
            break
    elif now2 != tmp2:
        if now2 + 1 <= len(S) - 1 and S[now2 + 1] == '.' and now2 + 1 <= tmp2:
            S[now2] = '.'
            S[now2 + 1] = a2
            now2 += 1
        elif now2 + 2 <= len(S) - 1 and S[now2 + 2] == '.' and now2 + 2 <= tmp2:
            S[now2] = '.'
            S[now2 + 2] = a2
            now2 += 2
        else:
            ans = 'No'
            break
    else:
        ans = 'Yes'
        break

print(ans)

Submission status: Accepted

Solution code:
import itertools as it
import collections as col
import heapq
import sys
sys.setrecursionlimit(10**9)

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

for i in range(A,C):
    if S[i] == '#' and S[i+1] == '#':   
        print('No')
        exit()

for i in range(B,D):
    if S[i] == '#' and S[i+1] == '#':   
        print('No')
        exit()

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

X=[-1]*N
X[B-1] = 0 if S[B-1] == '#' else 1
for i in range(B,D+2):
    X[i] = 0 if S[i] == '#' else (X[i-1] + 1)
    if X[i] >= 3:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
x = input().split()
s = input()
n = int(x[0])
a = int(x[1])
b = int(x[2])
c = int(x[3])
d = int(x[4])
 
 
kome_flag = False # ##がないとTrue
santen_flag = False # ... があればTrue
 
a_s = s[a:c]
b_s = s[b:d]
 
 
if d < c:
  if '...' in s[b-2:d+1]:
    santen_flag = True
kome_flag = True
if '##' in a_s or '##' in b_s:
  kome_flag = False
    

if True:
	if c < d:
		if kome_flag:
			print('Yes')
		else:
			print('No')
 
	if d < c:
		if kome_flag and santen_flag:
			print('Yes')
		else:
			print('No')

Submission status: Accepted

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

def max_stone(a, b):
  m = 0
  for j in range(a, b-1):
    if S[j] == S[j+1] == '#':
      return False
  
  return True
  
def reachable(b, d):
  n_sharp = 0
  n_dot = 0
  for j in range(b-1, d+2):
    s = S[j]
    if s=='.':
      n_dot += 1
      n_sharp = 0
    else:
      n_sharp += 1
      n_dot = 0
      
    if n_dot == 3:
      return True
    elif n_sharp == 2:
      return False
    
  return False
  
if C < B:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C < D:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C > D:
  if reachable(B-1, D-1) and max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')

Submission status: Accepted

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

def main():
    if "##" in s[b:d-2]:
        return "No"
    if "##" in s[a:c-2]:
        return "No"

    if c < d:
        return "Yes"
    
    else:

        if "..." in s[b-2:d+1]:
            return "Yes"
                
        return "No"

print(main())

Submission status: Accepted

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

Submission status: Accepted

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

s = input()

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

Submission status: Accepted

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


def reachable(start, end):
    now = start
    while now <= end:
        nex = now
        while nex <= end and S[now] == S[nex]:
            nex += 1
        if S[now] == '#' and nex - now >= 2:
            return False
        now = nex
    return True


if not reachable(A, C) or not reachable(B, D):
    print("No")
    quit()

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

print("Yes")

Submission status: Accepted

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

def max_stone(a, b):
  m = 0
  for j in range(a, b-1):
    if S[j] == S[j+1] == '#':
      return False
  
  return True
  
def reachable(b, d):
  n_sharp = 0
  n_dot = 0
  for j in range(b-1, d+2):
    s = S[j]
    if s=='.':
      n_dot += 1
      n_sharp = 0
    else:
      n_sharp += 1
      n_dot = 0
      
    if n_dot == 3:
      return True
    elif n_sharp == 2:
      return False
    
  return False

def reachable2(b, d):
  for k in range(b-1,d):
    if S[k] == S[k+1] == S[k+2] == ".":
      return True
  return False
  
if C < B:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C < D:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C > D:
  if reachable2(B-1, D-1) and max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')