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:
#coding:utf-8
def main():
    N,A,B,C,D = list(map(int,input().split()))
    S = input()
    A -=1
    B -=1
    C -=1
    D -=1
    #C>Dのとき:AがBを追い越す
    prev = -1
    if C < D:  #AがBを追い越さない場合
        
        for i in range(A+1,min(C,B)):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i
        for i in range(B+1,D):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i

        
        print('Yes')
    prev = -1
    if C > D:  #AがBを追い越す時
        for i in range(A+1,B):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i
        f = False  #追い越せるか

        prevS = -1
        prevprevS = -1

        for i in range(B-1,D+2):
            if S[i] == '#' :
                if i - prev == 1:
                    print('No')
                    return
                prev = i
            else:
                #print(i,prevS,prevprevS)
                if i - prevS == 1 and prevS - prevprevS ==1:
                    f = True
                prevprevS = prevS
                prevS = i
                
                
                
        # if S[D-1] == '.':
        #     f = True
                
        if not f:
            print('No')
            return
        
        for i in range(D+1,C):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i
        print('Yes')
if __name__ == '__main__':
    main()

Submission status: Accepted

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

if c > d:#追い抜きが必要な場合
    x = 0
    for i in range(b-2,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:
        print("No")

Submission status: Accepted

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
s = [0]
for i in range(N):
    if S[i] == '.':
        s.append(0)
    else:
        s.append(1)
if C < B and B < D: #ACBDの順番
    flag = 0
    for i in range(C - A):
        if s[A + i] == 1 and s[A + i + 1] == 1:
            flag = 1
            break
    if flag == 0:
        for i in range(D - B):
            if s[B + i] == 1 and s[B + i + 1] == 1:
                flag = 1
                break
    if flag == 1:
        print('No')
    else:
        print('Yes')
elif B < C and C < D: # ABCDの順番
    flag = 0
    for i in range(D - B):
        if s[B + i] == 1 and s[B + i + 1] == 1:
            flag = 1
            break
    if flag == 0:
        for i in range(B - A):
            if s[A + i] == 1 and s[A + i + 1] == 1:
                flag = 1
                break
    if flag == 1:
        print('No')
    else:
        print('Yes')
else: #ABDCの順番
    flag = 0
    for i in range(D - B + 1):
        if s[B + i - 1] == 0 and s[B + i] == 0 and s[B + i + 1] == 0:
            flag = 1
            break
    if flag == 1:
        for i in range(C - A):
            if s[A + i] == 1 and s[A + i + 1] == 1:
                flag = 0
                break
    if flag == 1:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

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

flag1 = 0

for i in range(C-A-2):
    if S[i+A] == S[i+A+1] == "#":
        flag1 = 1
for i in range(D-B-2):
    if S[i+B] == S[i+B+1] == "#":
        flag1 = 1    

flag2 = 0

if (B<D) & (D<C): #ABDC
    flag2 = 1
    for i in range(D-B+1):
        if S[B-2+i] == S[B-1+i] == S[B+i] == ".":
            flag2 = 0

if (flag1 == 0) & (flag2 == 0):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N, A, B, C, D = map(int, input().split()) # 横に2個
S = [0 if s == '.' else 1  for s in input()]

if C <= B:
    ans = 'Yes'
    for i in range(A, C):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
    for i in range(B, D):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break

elif C < D:
    ans = 'Yes'
    for i in range(A, D):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
else:
    ans = '?'
    for i in range(A, C):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
        if B - 1 <= i <= D - 1 and S[i] == 0 and S[i-1] == 0 and S[i+1] == 0:
            ans = 'Yes'
            break
    if ans == '?':
        ans = 'No'

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(n, a, b, c, d, s):
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    for left, right in [(a, c), (b, d)]:
        for i in range(left, right):
            if s[i:i+2] == '##':
                return "No"
    if d < c:
        for i in range(b, d+1):
            if s[i-1:i+2] == "...":
                return "Yes"
        return "No"
    else:
        return "Yes"

n, a, b, c, d = map(int, input().split())
s = input()
print(solve(n, a, b, c, d, s))

Submission status: Accepted

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

count_dot = 0
count_sharp = 0
max_dot = 0

if(c>d):
  for i in range(a-1,c):
    if li[i]=='.':
      count_sharp = 0
      if b-2 <= i and i <= d:
        count_dot += 1
    else:
      max_dot = max(max_dot, count_dot)
      count_dot = 0
      count_sharp += 1
      if count_sharp>1:
        break
  max_dot = max(max_dot, count_dot)

  if(count_sharp<=1 and max_dot>2):
    print('Yes')
  else:
    print('No')
  # print(count_sharp,max_dot)
else:
  for i in range(a-1,d):
    if li[i]=='#':
      if not c<b:
        count_sharp += 1
        if count_sharp>1:
          break
    else:
      count_sharp = 0
  if(count_sharp<=1):
    print('Yes')
  else:
    print('No')
  # print(count_sharp)

Submission status: Accepted

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

def can_reach(s, p, q):
	for i in range(p, q):
		if s[i] == '#' and s[i+1] == '#':
			return False
	return True

def main():
	_, a, b, c, d = map(lambda i: int(i)-1, input().strip().split())
	s = input().strip()
	if a < c < b < d:
		if can_reach(s, a, c) and can_reach(s, b, d):
			print('Yes')
		else:
			print('No')
	elif a < b < c < d:
		if can_reach(s, a, c) and can_reach(s, b, d):
			print('Yes')
		else:
			print('No')
	else:
		if can_reach(s, a, c) and can_reach(s, b, d):
			for i in range(b-1, d):
				if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
					print('Yes')
					return
		print('No')

if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
import bisect
from collections import defaultdict
import math

def judge(start, end, S):
    for i in range(start, end):
        s = S[i:i+2]
        if tuple(s) == ("#", "#"):
            return False
    return True

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

    is_ok = judge(A-1, C-1, S)
    if not is_ok:
        print("No")
        return
    is_ok = judge(B-1, D-1, S)
    if not is_ok:
        print("No")
        return

    if C > D:
        for i in range(B-1, D):
            if S[i] != "#" and S[i-1] != "#" and S[i+1] != "#":
                print("Yes")
                return
        print("No")
    else:
        print("Yes")

if __name__ == '__main__':
    main()

Submission status: Accepted

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

if '##' in s[a-1:c] or '##' in s[b-1:d]:
    flag = 'No'
if not '...' in s[b-2:d+1] and c > d:
    flag = 'No'
print(flag)

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()
swap = True if '...' in S[B-2:D+1:] else False
if C > D and not swap:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

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

ok = 1
for p, q in ((A, C), (B, D)):
    cnt = 0
    for i in range(p-1, q):
        if S[i] == '#':
            cnt += 1
        else:
            if cnt > 2:
                ok = 0
            cnt = 0
if not ok:
    print("No")
    exit(0)

if C > D:
    ok = 0
    for i in range(B-1, D):
        if S[i-1] == S[i] == S[i+1] == '.':
            ok = 1
if ok:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from copy import*
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[max(0,b-2):min(d+1,n)]:
            print("Yes")
        else:
            print("No")

Submission status: Accepted

Solution code:
n, a, b, c, d = [int(x) for x in input().split()]
s = ''.join(['#',input(),'#'])
if '##' in s[a:c+1] or '##' in s[b:d+1]:
	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())
a -= 1
b -= 1
s = input()
ans = "No"
snk = s[a:c].count("##")
fnk = s[b:d].count("##")
if snk == 0 and fnk == 0:
  if c > d:
    if s[b-1:d+1].count("...") >= 1:
      ans = "Yes"
  else:
    ans = "Yes"
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B,C,D = [int(x) for x in input().split()]
S = input()
if('##'in S[min(A,B)-1:max(C,D)]):
    print('No')
else:
    flag = False
    if((B-A)*(D-C)<0):
        if('...'in S[max(A,B)-2:min(C,D)+1]):
            flag = True
    else:
        flag = True
    if(flag):
        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-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()
sac = s[a-1:c]
sbd = s[b-1:d]
ac = "##" not in sac
bd = "##" not in sbd
if c < d:
    if ac and bd:
        print("Yes")
    else:
        print("No")
else:
    sbd2 = s[b-2:d+1]
    if ac and bd and "..." in sbd2:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
def CanKenKen(List,Start,Goal):
    Q=List[Start:Goal+1]
    return all([i=="." or Q[n+1]=="." or n==Goal-Start for n,i in enumerate(Q[:-1])])
N,A,B,C,D=map(int,input().split())
A,B,C,D=map(lambda x:x-1 ,[A,B,C,D])#0-indexed
S=input()

if A<C<B<D:
    if CanKenKen(S,A,C) and CanKenKen(S,B,D+1):
        print("Yes")
    else:print("No")
elif A<B<D<C:
    if CanKenKen(S,A,C):
        if B>=2:Q=S[B-1:D+2]
        else:Q=S[:D+2]
        if "..." in Q:print("Yes")
        else:print("No")
    else:print("No")
elif A<B<C<D:
    if CanKenKen(S,A,D):print("Yes")
    else:print("No")

Submission status: Accepted

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

S0 = S[:A]
Sa = S[A-1:C]
Sb = S[B-2:D+1]
F = max(C,D)
S1 = S[F:]
#if S0.rfind('##')>=0 and S1.find('##')>=0 :
#    Sfe = S[S0.rfind('##'):(F+S1.find('##'))]
#elif S0.rfind('##')>=0 :
#    Sfe = S[S0.rfind('##'):]
#elif S1.find('##')>=0 :
#    Sfe = S[:(F+S1.find('##'))]
#else :
#    Sfe = S


#if S.find('##')>=0 and A<S.find('ABC')<C or B<S.find('ABC')<D:
if Sa.find('##')>=0 or Sb.find('##')>=0:
    ans = "No"

if A<B<D<C and not '...' in Sb:
    ans = "No"

print(ans)

Submission status: Accepted

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

def no2rock(l, r):
    global s
    for i in range(l + 1, r + 1):
        if s[i - 1] == "#" and s[i] == "#":
            return False
    return True

def rest(l, r):
    global s
    for i in range(l, r + 1):
        if s[i - 1] == "." and s[i] == "." and s[i + 1] == ".":
            return True
    return False

if c < d:
    if no2rock(a, c) and no2rock(b, d):
        print("Yes")
    else:
        print("No")
else:
    if no2rock(a, c) and no2rock(b, d) and rest(b, d):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
rock = 0
brank = 0
rfrag = 0
bfrag = 0
mrock = 0
mbrank = 0
rlist = []
blist = []
for i in range(n):
    if s[i] == "#":
        if bfrag == 1:
            if brank >= 3:
                blist.append(i-brank+1)
            if mbrank < brank:
                mbrank = brank
                brank = 0
            brank = 0
        rock += 1
        rfrag = 1
    if s[i] == ".":
        if rfrag == 1:
            if rock >= 2:
                rlist.append(i-rock+1)
            if mrock < rock:
                mrock = rock
                rock = 0
            rock = 0
        brank += 1
        bfrag = 1
if mrock < mbrank:
    if brank >= 3:
        blist.append(n-brank+1)
    if mbrank < brank:
        mbrank = brank
        brank = 0    
else:
    if mrock < rock:
        mrock = rock
        rock = 0

p = 0
for i in range(len(rlist)):
    if a < rlist[i] < c or b <  rlist[i] < d:
        print("No")
        p = 1
        break

y = 0 
if d < c and p == 0:
    x = 0
    for i in range(len(blist)):
        if b-1 <= blist[i] < d:
            x = 1            
    if x == 1:
        print("Yes")
        y = 1
    elif x == 0:
        print("No")
        y = 1
        
if p == 0 and y == 0:
    print("Yes")

Submission status: Accepted

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

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

if '##' in s[a:c+1] or '##' in s[b:d+1]:
    print('No')  # そもそも移動経路の中に岩が二つ並んでいたら不可能ということ！
else:
    if c < d:  # この状態ならBにいる人をDに動かしてから、AをCに動かすだけでOK
        print('Yes')
    elif c > d:  # Aの目的地が、Bの目的地よりも右にあるなら
        # B-1からD+2にまでの中にBくんを退避させることが可能なスペースがあるか。
        # BくんはDまでしか動けない
        if "..." in s[b-1:d+2]:
            print('Yes')
        else:
            print('No')

Submission status: Accepted

Solution code:
def check(X, Y, N, S):
    overtake = False
    while X <= Y:
        if S[X-2] == "." and S[X] == ".":
            overtake = True
        if X == Y:
            break
        if S[X] == ".":
            X += 1
        else:
            if X+1 <= N and S[X+1] == ".":
                X += 2
            else:
                return False, False
    return True, overtake

def main():
    N, A, B, C, D = map(int, input().split())
    S = input()
    S += "#"
    A_ok, _ = check(A, C, N, S)
    B_ok, overtake = check(B, D, N, S)
    if A_ok and B_ok and (C < D or overtake):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

if '##' in S[A:C+1] or '##' in S[B:D+1]:
    print('No')  # そもそも移動経路の中に岩が二つ並んでいたら不可能ということ！
else:
    if C < D:  # この状態ならBにいる人をDに動かしてから、AをCに動かすだけでOK
        print('Yes')
    elif C > D:  # Aの目的地が、Bの目的地よりも右にあるなら
        # B-1からD+2にまでの中にBくんを退避させることが可能なスペースがあるか。
        # BくんはDまでしか動けない
        if "..." in S[B-1:D+2]:
            print('Yes')
        else:
            print('No')

Submission status: Accepted

Solution code:
n, a, b, c, d = [int(i) for i in input().split()]
s = input()
res = "Yes"
e = max(c,d)
if "##" in s[a-1:e-1]:
	res = "No"
elif c > d:
	if "..." not in s[b-2:d+1]:
		res = "No"
print(res)

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 '##' in S[A:C] or '##' in S[B:D]:
    print("No")
    exit()
if C > D:
    if  '...' 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()

# AからDの間に岩が二つ連続で置かれている箇所があれば不可
# C > D の場合、すぬけ君はふぬけ君を追い越す必要があることに注意
ans = (
    'Yes' if ('##' not in S[(A - 1):D]) and (
        C < D or
        '...' in S[(B - 2):(D + 1)]
    ) else
    'No'
)

# 出力
print(ans)

Submission status: Accepted

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

# AからDの間に岩が二つ連続で置かれている箇所があれば不可
# C > D の場合、すぬけ君はふぬけ君を追い越す必要があることに注意
ans = (
    'Yes' if ('##' not in S[(A - 1):max(C, D)]) and (
        C < D or
        '...' in S[(B - 2):(D + 1)]
    ) else
    'No'
)

# 出力
print(ans)

Submission status: Accepted

Solution code:
n, a, b, c, d = [int(i) for i in input().split()]
S = ' ' + input()

if '##' in S[a:c + 1]:
    print('No')
elif '##' in S[b:d + 1]:
    print('No')
else:
    if c < d:
        print('Yes')
    elif '...' 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=str(input())
s=s.replace('.','0')
s=s.replace('#','1')
x=0
y=0
f=0
g=0
for i in range(c-a-1):
    x=int(s[i+a])
    y=int(s[i+a+1])
    if(x*y==1):
        f=-1
for j in range(d-b-1):
    x=int(s[j+b])
    y=int(s[j+b+1])
    if(x*y==1):
        g=-1
if(d<c):
    if(s[b-2:d+1].find('000')==-1):
        f=-1
if(f==0 and g==0):
    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")
elif c<d:
  print("Yes")
elif "..." in s[b-2:d+1] :#以下 d<c の場合
  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")
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()

flag = True

#search '##'
if "##" in S[A-1:C] or "##" in S[B-1:D]:
    flag = False

#search '...'
if C > D and flag:
    flag = False
    if "..." in S[B-2:D+1]:
        flag = True

if flag:
    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

index1 = s[a:c].find("##")
index2 = s[b:d].find("##")

ans = "No"

if index1 == -1 and index2 == -1:
  if c < d :
    ans = "Yes"
  elif s[max(b-1,0):d+1].find("...") != -1 :
    ans = "Yes"
  
print(ans)

Submission status: Accepted

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

index1 = s[a:c].find("##")
index2 = s[b:d].find("##")

ans = "No"

if index1 == -1 and index2 == -1:
  if c < d :
    ans = "Yes"
  elif s[b-1:d+1].find("...") != -1 :
    ans = "Yes"
  
print(ans)

Submission status: Accepted

Solution code:

def check_two_stones(S, A, B, C, D):
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            return False
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            return False

    return True

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

S = S_org + "#"
if (B < C and C < D) or (C < B and B < D):
    if check_two_stones(S, A, B, C, D) is False:
        print("No")
        exit()
else:
    check = True
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            check = False

    #  ゴールと手前が"##"
    #if check is True and S[D-2] is "#":
         # 途中に"..."があれば回避できる

    S = S_org + "#."
    for j in range(B-2, D-1):
        if S[j] is "." and S[j+1] is "." and S[j+2] is ".":
            check = True
            break
        else:
            check = False

    if check is False:
        print("No")
        exit()

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

print("Yes")

Submission status: Accepted

Solution code:

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

    return True


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


if can_reach(S, A, C) == False or can_reach(S, B, D) == False:
    print("No")
    exit()

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


    if snuke_can_over is False:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
def hantei(n, a, b, c, d, s):
    if s[a - 1:c].find("##") > 0:
        return "No"
    if s[b - 1:d].find("##") > 0:
        return "No"
    if c > d:
        if s[max(0, b - 2):min(n, d + 1)].find("...") == -1:
            return "No"
    return "Yes"

n, a, b, c, d = map(int, input().split())
s = input()
print(hantei(n, a, b, c, d, s))

Submission status: Accepted

Solution code:
import sys
import numpy as np


def main():
    n, a, b, c, d = [int(x) for x in input().split()]
    nv = np.insert(np.array([1 if char == '#' else 0 for char in input()]), 0, 0)
    nv1 = nv[1:] + nv[:-1]
    nv2 = nv[2:] + nv[1:-1] + nv[:-2]
    if np.any(nv1[a:max(c, d)] == 2):
        print("No")
    elif c < d:
        print("Yes")
    elif np.any(nv2[b-1:d] == 0):
        print("Yes")
    else:
        print("No")


main()

Submission status: Accepted

Solution code:
import sys
import numpy as np


def main():
    n, a, b, c, d = [int(x) for x in input().split()]
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    nv = np.insert(np.array([1 if char == '#' else 0 for char in input()]).cumsum(), 0, 0)
    for i in range(a, max(c, d)):
        if nv[i + 2] - nv[i] == 2:
            print("No")
            sys.exit()
    if c < d:
        print("Yes")
        sys.exit()
    for i in range(b, d + 1):
        if nv[i + 2] - nv[i - 1] == 0:
            print("Yes")
            sys.exit()
    print("No")


main()

Submission status: Accepted

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

e = 'Yes'
f = 0
g = 1

if c < d:
    for i in range(b-1,d-1):
        if s[i]=='#' and s[i+1]=='#':
            e ='No'
    if e =='Yes':
        for j in range(a-1,b-1):
            if s[j]=='#' and s[j+1]=='#':
                e ='No'
                        
if c > d:
    for i in range(a-1,c-1):
        if s[i]=='#' and s[i+1]=='#':
            f = 1
    
    for j in range(b-2,d-1):
        if s[j]=='.' and s[j+1]=='.' and s[j+2]=='.':
            g = 0

    if g == 0 and f ==0:
        e ='Yes'
    else:
        e ='No'
            
print(e)

Submission status: Accepted

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

def check1(l,r):
    if S[l:r+1].count("##") > 0:
        return False
    return True

def check2():
    if S[B-1:D+2].count("...") > 0:
        return True
    return False

if C < D:
    if check1(A,C) and check1(B,D):
        ans = "Yes"
    else:
        ans = "No"
elif D < C:
    if check1(B,D) and check2():
        ans = "Yes"
    else:
        ans = "No"
else:
    ans = "No"

print(ans)

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

Submission status: Accepted

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

    if '##' in s[a:c]:
        return False
    if '##' in s[b:d]:
        return False
    if c > d:
        if '...' not in s[b-1:d+1]:
            return False
    return True

print(['No', 'Yes'][f()])

Submission status: Accepted

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

Submission status: Accepted

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

string = input()

if "##" in string[a-1:c] or "##" in string[b-1:d]:
    print("No")

elif c < d:
    print("Yes")

else :
    if "..." in string[b-2:d+1]:
        print("Yes")

    else :
        print("No")

Submission status: Accepted

Solution code:
#A問題
N,A,B,C,D = map(int,input().split())
Slist = list(str(input()))

flag = 0

Rock = 0
for i in range(D-B+1):
    I = B-1+i
    if Slist[I] == "#":
        Rock+=1
        if Rock == 2:
            flag = 1
            break
    else:
        Rock = 0
Rock = 0
for i in range(C-A+1):
        I = A-1+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0

if C > D:
    white = 0
    wflag = 0
    for i in range(D-B+3):
        I = B-2+i
        if Slist[I] == ".":
            white+=1
            if white >= 3:
                wflag = 1
                break
        else:
            white = 0
    if white >= 3:
        wflag = 1
        
    if wflag == 0:
        flag = 1
        
if flag == 1:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
c=0
if '##' in S[A:C] or '##' in S[B:D]:
    c=1
if C<D:#大きい方から先に目的地に配置
    if c==0:
        print("Yes")
    else:
        print("No")

elif C>D:
    if '...' in S[B-2:D+1] and c==0:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
N,A,B,C,D=map(int,input().split())
ans='Yes'
S=input()
if C<D:
    if '##' in S[B-1:D-1] or '##' in S[A-1:C-1]:
        ans='No'
else:
    if '##' in S[B-1:D-1] or '##' in S[A-1:C-1] or '...' 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())
s = input()
if '##' in s[a-1:c] or '##' in s[b-1:d]:
    print('No')
elif 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 '##' in s[a-1:c] or '##' in s[b-1:d]:
    print('No')
elif 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()

flag = False

if c < d:
  if s[a-1:c].count('##') == 0 and s[b-1:d].count('##') == 0:
    flag = True
else:
  if s[a-1:c].count('##') == 0 and s[b-2:d+1].count('...') >= 1:
    flag = True

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

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('No')
elif c<d:
  for i in range(a,d+1):
    if s[i]=='#' and s[i+1]=='#':
      print('No')
      break
  else:
    print('Yes')
elif c>d:
  for i in range(a,c+1):
    if s[i]=='#' and s[i+1]=='#':
      print('No')
      break
  else:
    for i in range(b,d+1):
      if s[i]=='.':
        if s[i-1]=='.' and s[i+1]=='.':
          print('Yes')
          break
    else:
      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()
if C<D:
    for i in range(B,D-1):
        if S[i:i+2]=='##':
            print('No')
            sys.exit()
    for i in range(A,C-1):
        if S[i:i+2]=='##':
            print('No')
            sys.exit()
    print('Yes')
    sys.exit()
for i in range(B,D-1):
    if S[i:i+2]=='##':
        print('No')
        sys.exit()
for i in range(A,C-1):
    if S[i:i+2]=='##':
        print('No')
        sys.exit()
for i in range(B,D+1):
    if S[i-1:i+2]=='...':
        print('Yes')
        sys.exit()
print('No')