Problem:


Score : 400 points

Problem Statement

There are N squares arranged in a row, numbered 1, 2, ..., N from left to right.
You are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.

In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.

You can repeat the following operation any number of times:

Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.

You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.

Determine whether this is possible.

Constraints

4 \leq N \leq 200\ 000

S is a string of length N consisting of . and #.

1 \leq A, B, C, D \leq N

Square A, B, C and D do not contain a rock.

A, B, C and D are all different.

A < B

A < C

B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

Print Yes if the objective is achievable, and No if it is not.

Sample Input 1

7 1 3 6 7
.#..#..

Sample Output 1

Yes

The objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)

A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB

Sample Input 2

7 1 3 7 6
.#..#..

Sample Output 2

No

Sample Input 3

15 1 3 15 13
...#.#...#.#...

Sample Output 3

Yes



Sample input:
7 1 3 6 7
.#..#..


Sample output:
Yes

Submission status: Runtime Error

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
flag=True
for i in range(len(s)-1):
    if s[i]=="#" and s[i+1]=="#":
        flag=False
        break

if c<d:
    if flag:
        print("Yes")
    else:
        print("No")
elif c>d:
    flag=False
    for i in range(b,d+1):
        if s[i-1]=="." and s[i]=="." and s[i+1]==".":
            flag=True
            break
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

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

a -= 1; b -= 1; c -= 1; d -= 1

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

#ABDC
elif d < c:
    flag_a = False
    for i in range(b, c+1):
        if s[i-1] == "." and s[i] == "." and s[i+1] == ".":
            flag_a = True

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

    if flag_a and flag_b:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

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

if (b-a)*(d-c)>0 and max(a,b) < min(c,d):
  for i in range(min(a,b),max(c,d)):
    if s[i]=='#' and s[i+1]=='#':
      print('No')
      exit()
  print('Yes')

elif (b-a)*(d-c)>0 and max(a,b) > min(c,d):
  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()
  print('Yes')
 
else:
  for i in range(min(a,b),max(c,d)):
    if s[i]=='#' and s[i+1]=='#':
      print('No')
      exit()
  for i in range(max(a,b),min(c,d)+1):
    if s[i-1]=='.' and s[i]=='.' and s[i+1]=='.':
      print('Yes')
      exit()
  print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
print("Yes)

Submission status: Runtime Error

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

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

if (con):
    if (c<b) or (c<d):
        print("Yes")
        con = False

if (con):
    for i in range(b-1,c):
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            print("Yes")
            con = False
            break

if (con):
    print("No")

Submission status: Runtime Error

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

d=0
for i in range(min(A+1,N-1),min(C+1,N-1)):
  if S[i]=="#" and S[i+1]=="#":
    d=1
    break
for i in range(min(B+1,N-1),min(D+1,N-1)):
  if S[i]=="#" and S[i+1]=="#":
    d=1
    break

if C<D:
  t=1
else:
  for i in range(max(0,min(B-1,N-2)),min(C+1,N-2)):
    if S[i]=="." and S[i+1]=="." and S[i+2]==".":
      t=1
      break

if C==D:
  print("No")
else:
  if d==1:
    print("No")
  else:
    if t==0:
      print("No")
    else:
      print("Yes")

Submission status: Runtime Error

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

s=input()

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

can_reach = True
bef = False
for i in range(a,c):
    if s[i] == "#":
        if bef:
            can_reach = False
        else:
            bef = True
    else:
        bef = False

bef = False
for i in range(b,d):
    if s[i] == "#":
        if bef == True:
            can_reach = False
        else:
            bef = True
    else:
        bef = False

if can_reach:
    if c < d:
        print("Yes")
    else:
        can_over = False
        bef1 = False
        bef2 = False
        for i in range(b-1,c+1):
            if s[i] == ".":
                if bef1:
                    if bef2:
                        can_over = True
                    else:
                        bef2 = True
                else:
                    bef1 = True
            else:
                bef1 = False
                bef2 = False
        if can_over:
            print("Yes")
        else:
            print("No")
else:
    print("No")

Submission status: Runtime Error

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

if c < d:
    # ふぬけ君を動かす
    for i in range(b, d):
        if s[i] == s[i+1] and s[i] == "#":
            print("No")
            exit()
    # すぬけ君を動かす
    for i in range(a, c):
        if s[i] == s[i+1] and s[i] == "#":
            print("No")
            exit()
    print("Yes")
    exit()

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

Submission status: Runtime Error

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

if c < d:
    # ふぬけ君を動かす
    for i in range(b, d):
        if s[i] == s[i+1] and s[i] == "#":
            print("No")
            exit()
    # すぬけ君を動かす
    for i in range(a, c):
        if s[i] == s[i+1] and s[i] == "#":
            print("No")
            exit()
    print("Yes")
    exit()

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) or compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) or compute(B-1, D-1)
elif D < C:
    pass

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

Submission status: Runtime Error

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

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and B < C:
    flag = compute(A-1, C-1) or compute(B-1, D-1)
elif B < C < D:
    pass
elif D < C:
    pass

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
a=0
E=N-D
if C>D:
    for i in range(N-3):
        if S[i]=="#":
            for j in range(1,4):
                if S[i]==S[i+j]:
                    a=1
    if E==0:
        for i in range(B-1,D-1):
            if S[i]==".":
                if S[i]==S[i+1] and S[i+1]==S[i+2]:
                    a=0
                    break
    if E>=1:
        for i in range(B-1,D):
            if S[i]==".":
                if S[i]==S[i+1] and S[i+1]==S[i+2]:
                    a=0
                    break
for i in range(N-1):
    if S[i]=="#":
        if S[i+1]=="#":
            a=1
if a==0:
    print("Yes")
if a==1:
    print("No")

Submission status: Runtime Error

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
a=0
E=N-D
if C>D:
    for i in range(N-3):
        if S[i]=="#":
            for j in range(1,4):
                if S[i]==S[i+j]:
                    a=1
    if E==0:
        for i in range(B-1,D-1):
        if S[i]==".":
            if S[i]==S[i+1] and S[i+1]==S[i+2]:
                a=0
                break
    if E>=1:
        for i in range(B-1,D):
        if S[i]==".":
            if S[i]==S[i+1] and S[i+1]==S[i+2]:
                a=0
                break
for i in range(N-1):
    if S[i]=="#":
        if S[i+1]=="#":
            a=1
if a==0:
    print("Yes")
if a==1:
    print("No")

Submission status: Runtime Error

Solution code:
import sys
INPUT = sys.stdin.readline
 
def SINGLE_INT(): 
    return int(INPUT())
def MULTIPLE_INT_LIST(): 
    return list(map(int, INPUT().split()))
def MULTIPLE_INT_MAP(): 
    return map(int, INPUT().split())
def SINGLE_STRING(): 
    return INPUT()
def MULTIPLE_STRING(): 
    return INPUT().split()

N, A, B , A_goal, B_goal = MULTIPLE_INT_MAP()
S = SINGLE_STRING()
 
def surpass():
    if '...' in S[B-2:B_goal+1]:
        return 'Yes'
	else:
        return 'No'
 
 
if '##' in S[A-1: A_goal+1] or '##' in S[B-1:B_goal+1]:
    print('No')

else:
    if A_goal < B_goal:
        print('Yes')
    else:
        print(surpass())

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for i in range(len(S) - 1):
    if S[i] == S[i+1] and S[i+1] == '#':
        print("No")
        quit()
S = C[B:M]
for i in range(len(S) - 2):
    if S[i] == S[i+1] and S[i+1]== S[i+2]  and S[i+2] == '.':
        print("Yes")
        quit()
if C <= B:
    print("Yes")
elif  C < D:
    print("Yes")
elif D <= C:
    print("No")

Submission status: Runtime Error

Solution code:
l = list(map(int,input().split()))
N = l[0]
A = l[1] 
B = l[2]
C = l[3]
D = l[4]
S = input()
S_list = list(S)

if B < C < D :
    count = 0
    for i in range(A, D-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else : 
        print('Yes')
elif C < B < D :
        count = 0
    for i in range(A, C-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    for i in range(B, D-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else :
        print('Yes')
elif B < D < C
    count = 0
    for i in range(A, C-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    count = 0
    for i in range(B-2, D-1):
        if S_list[i] == S_list[i+1] == S_list[i+2] == '.' :
            count += 1
    if count >= 1:
        print('Yes')  
    else:
        print('No')

Submission status: Runtime Error

Solution code:
#%%
l = list(map(int,input().split()))
N = l[0]
A = l[1] 
B = l[2]
C = l[3]
D = l[4]
S = input()
S_list = list(S)

if C < D :
    count = 0
    for i in range(A-1, D-1):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else : 
        print('Yes')
elif C == D :
    print('No')
else:
    count = 0
    for i in range(A-1, C-1):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    count = 0
    for i in range(B-2, D):
        if S_list[i] == S_list[i+1] == S_list[i+2] == '.' :
            count += 1
    if count >= 1:
        print('Yes')  
    else:
        print('No')

Submission status: Runtime Error

Solution code:

N = int(input())
A = list(map(lambda x: int(x),input().split()))

judge=False
#print(A)

for i in range(1,N):
    left = A[0]
    right = A[i]
    tmp_1=A[:]
    #print(tmp_1)
    tmp_1.remove(right)
    tmp_1.remove(left)
    tmp_2=[]
    isAble=True
    while isAble:
        #print(tmp_1)
        #print(tmp_2)
        x = right ^ left
        #print(x)
        if x in tmp_1:
            #print(x)
            left = right
            right = x
            tmp_1.remove(x)
            tmp_2.append(x)
        else:
            isAble=False

    if len(tmp_1)==0:
        judge=True
        break
    else:
        continue


ans = 'Yes' if judge else 'No'
print(ans)

Submission status: Runtime Error

Solution code:
N ,A ,B ,C ,D = list(map(int,input().split()))
S = input()
 
def judgeArrive(S, x, y):
    flag = "Yes"
    for i in range(x-1 ,y-2):
        if S[i] ==  S[i+1] == "#":
            flag = "No"
  return flag

def judgeJumpOver(S, x , y):
    flag = "No"
    for i in range(x-1 ,y):
        if S[i-1] ==  S[i] ==  S[i+1] == ".":
            flag = "Yes"
        break
 
  return flag
 
result = "Yes"
if(C > D):
    result = judgeJumpOver(S, B, D)
if(result == "Yes"):
    result = judgeArrive(S, B, D)
if(result == "Yes"):
    result = judgeArrive(S, A, C)
print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
 
def step(x,y):
    N_last = S[x:y-1]
    return N_last.find('##') == -1
 
 

if C > D:
    pass_path = False
    for b in range(B-1,D):
        if S[b] == '#':
            continue
        if S[b-1] == '.' and S[b+1] == '.':
            pass_path = True
            break


if step(A,C) and step(B,D)  and pass_path == True:
    print('Yes')
else:
    print('No')
if step(A,C) and step(B,D)  and pass_path == True:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
 
def step(x,y):
    N_last = S[x:y-1]
    return N_last.find('##') == -1
 
 
pass_path = False
if C > D:
    for b in range(B-1,D):
        if S[b-1] == '.' and S[b+1] == '.':
             path_pass = True
            continue
        elif S[b] == '#':
            break

if step(A,C) and step(B,D)  and pass_path == True:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
S = input()
 
def step(x,y):
    N_last = S[x:y-1]
    return N_last.find('##') == -1
 
 
pass_path = True

if C > D:
    for b in range(B-1,D):
        if S[b-1] == '.' and S[b+1] == '.':
            continue
        elif S[b] == '#':
            path_pass = False
            break

if step(A,C) and step(B,D)  and pass_path == True:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

flag = 0
if s[c-1] == "#" or s[d-1] == "#":
    flag = 1
elif s[a-1] == "#" or s[b-1] == "#":
    flag = 1
elif c == d:
    flag == 1
else:
    for i in range(n-1):
        if s[i] == s[i+1] == "#":
            flag = 1
            break

if flag == 1:
    print("No")
elif c > d:
    ans = 0
    if s[c-2] == "#" or s[c] == "#":
        print("No")
    else:
        for i in range(a-1,n-2):
            if s[i] == s[i+1] == s[i+2] ==".":
                ans = 1
                break
        if ans == 1:
            print("Yes")
        else:
            print("No")
else:
    print("Yes")

Submission status: Runtime Error

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

flag = 0
if s[c-1] == "#" or s[d-1] == "#":
    flag = 1
elif s[a-1] == "#" or s[b-1] == "#":
    flag = 1
else:
    for i in range(n-1):
        if s[i] == s[i+1] == "#":
            flag = 1
            break

if flag == 1:
    print("No")
elif c > d:
    ans = 0
    if s[c-2] == "#" or s[c] == "#":
        print("No")
    else:
        for i in range(a-1,n-2):
            if s[i] == s[i+1] == s[i+2] ==".":
                ans = 1
                break
        if ans == 1:
            print("Yes")
        else:
            print("No")
else:
    print("Yes")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N,A,B,Q,D = map(int,input().split())
S = input()
C = []
for i in range(len(S)):
    C.append(S[i])

if Q<D:
    error = 0
    for i in range(B,C):
        if C[i]=="#" and C[i+1]=="#":
            error = 1
            break
else:
    error = 0
    for i in range(B,D):
        if C[i]=="#" and C[i+1]=="#":
            error = 1
            break
    flag = 0
    for i in range(B-1,D):
        if C[i-1]=="." and C[i+1]=="." and C[i]==".":
            flag = 1
    if flag==0:
        error = 1

if error==0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N,A,B,Q,D = map(int,input().split())
S = input()
C = []
for i in range(len(S)):
    C.append(S[i])

if Q<D:
    error = 0
    for i in range(len(C)-1):
        if C[i]=="#" and C[i+1]=="#":
            error = 1
else:
    error = 0
    for i in range(len(C)-2):
        if C[i]=="#" and C[i+1]=="#":
            error = 1
            break
    flag = 0
    for i in range(max(A,B),min(Q,D)+1):
        if C[i]=="." and C[i+1]=="." and C[i+2]==".":
            flag = 1
    if flag==0:
        error = 1

if error==0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
N,A,B,Q,D = map(int,input().split())
S = input()
C = []
for i in range(len(S)):
    C.append(S[i])

if Q<D:
    error = 0
    for i in range(len(C)-1):
        if C[i]=="#" and C[i+1]=="#":
            error = 1
else:
    error = 0
    for i in range(len(C)-2):
        if C[i]=="#" and C[i+1]=="#":
            error = 1
            break
    flag = 0
    for i in range(max(A,B),min(Q,D)):
        if C[i]=="." and C[i+1]=="." and C[i+2]==".":
            flag = 1
    if flag==0:
        error = 1

if error==0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
sb=s[b-1:d]
nb=len(sb)
for i in range(nb-1):
  if sb[i:i+2]=='##':
    print('No')
    exit()
  else:
    s[d-1]='#'
    
sa=s[a-1:c]
na=len(sa)
for i in range(na-1):
  if sa[i:i+2]=='##':
    print('No')
    exit()
  else:
    print('Yes')

Submission status: Runtime Error

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

for i in range(D-A):
  if (road[A+i-1] == '#') & (road[A+i] == '#'):
    judge = 0
    break
  else:
    judge = 1
if judge == 1:
  if C < D:
    judge = 1
  else:
    for i in range(D-B+1):
      print(B+i)
      if (road[B+i-1] == '.') & (road[B+i] == '.') & (road[B+i+1] == '.'):
        judge = 1
        break
      else:
        judge = 0

if judge == 0:
  print("No")
else:
  print("Yes")

Submission status: Runtime Error

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

for i in range(len(road)-1):
  if (road[i] == '#') & (road[i+1] == '#'):
    judge = 0
    break
  else:
    judge = 1
if judge == 1:
  if C < D:
    judge = 1
  else:
    for i in range(D-B+1):
      if (road[B+i-1] == '.') & (road[B+i] == '.') & (road[B+i+1] == '.'):
        judge = 1
        break
      else:
        judge = 0

if judge == 0:
  print("No")
else:
  print("Yes")

Submission status: Runtime Error

Solution code:
#https://atcoder.jp/contests/agc034/tasks/agc034_a
N,A,B,C,D = [int(i) for i in input().split()]
s = list(input())

flag = True
if C < D:
    for i in range(A,C):
        if s[i] == '#' and s[i+1] == '#':
            flag = False
    for i in range(B,D):
        if s[i] == '#' and s[i+1] == '#':
            flag = False
if C > D:
    for i in range(A,C-1):
        if s[i] == '#' or s[i+1] == '#' or s[i+2] == '#':
            flag = False
    for i in range(B,D-1):
        if s[i] == '#' or s[i+1] == '#' or s[i+2] == '#':
            flag = False

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

Submission status: Runtime Error

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

sunuke = A
hunuke = B

def hanteiki():
    if C < D:
        if "##" in S[B:D]:
            return False
        else:
            if "##" in S[A:C]:
                return False
            else:
                return True

    else:
        tmp1 = S[B-1:D+1].count("...")
        tmp2 = S[B-1:D+1].rfind("...")
        if tmp1 > 0:
            if "##" in S[A:C]:
                return False
            else:
                if tmp1 == 1 and tmp2 == D-1:
                    return False
                else
                    return True
        else:
            return False

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,a,b,c,d=map(int,input().split())
s=list(input())
fa=True
fb=True
ff=False
for i in range(a,c-1):
    if s[i]=="#" and s[i+1]=="#":
        fa=False
for i in range(b,d-1):
    if s[i]=="#" and s[i+1]=="#":
        fb=False

for i in range(a,d-1):
    if s[i]=="." and s[i+1]=="." and s[i+2]==".":
        ff=True
if c<d:
    if fa and fb:
        print("Yes")
    else:
        print("No")
else:
    if fa and fb and ff:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
def check_double_block(start, end, S):
    for i in range(start, end-1):
        if S[i] == "#" and S[i+1] == "#":
            return False
    return True

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

    if C < D:
        if not check_double_block(A, C, S) or not check_double_block(B, D, S):
            print("No")
        else:
            print("Yes")
    else:
        for i in range(B, D+1):
            if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
                print("Yes")
                exit()
        print("No")


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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


def rec(s, a, b, c, d):
    #ss = s.copy()
    #ss[a] = 'A'
    #ss[b] = 'B'
    #print(str(ss),a,b,c,d)
    if a > c or b > d:
        return False
    if a == c and b == d:
        return True

    if a+1 < len(s) and s[a + 1] == '.' and a+1 != b:
        if rec(s, a + 1, b, c, d):
            return True
    if a+2 < len(s) and s[a + 2] == '.' and a + 2 != b:
        if rec(s, a + 2, b, c, d):
            return True
    if b + 1 < len(s) and s[b + 1] == '.' and b + 1 != a:
        if rec(s, a, b + 1, c, d):
            return True
    if b+2 < len(s) and s[b + 2] == '.' and b + 2 != a:
        if rec(s, a, b + 2, c, d):
            return True

    return False

result = rec(s, a, b, c, d)
if result:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

if c > d:#追い抜きが必要な場合
    x = 0
    for i in range(b-1,d-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            x = 1
    if x == 0:
        print("No")#追い抜きが出来ない
    else:#追い抜き可能な場合
        check = 0#岩が2連続以上だと達成不能
        for i in range(a-1,c-1):
            if s[i] == "#" and s[i+1] == "#":
                check = 1
        if check == 1:
            print("No")
        else:
            print("Yes")
else:#a<b<c<dと並ぶ場合、もしくはacbdと並ぶ場合
    a_check = 0#Aがいけるか
    b_check = 0#Bがいけるか
    for i in range(a-1,c-1):
        if s[i] == "#" and s[i+1] == "#":
            a_check = 1
    for i in range(b-1,d-1):
        if s[i] == "#" and s[i+1] == "#":
            b_check = 1
    if a_check == 0 and b_check == 0:
        print("Yes")
    else: