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: Wrong Answer

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

def check_serial(mark, number, start, end):
    ans = False
    i = start
    while i < end:
        for j in range(number):
            if j+i > end:
                break
            if s[i+j] != mark:
                i += j 
                break
            elif j == number-1:
                ans = True
        if ans:
            break
        i += 1
    return ans

# print(check_serial('.', 3, 0, n-1))
ans = True
if c > d:
    ans = check_serial('.', 3, b-1, d)
if check_serial('#', 2, a, c-1):
    ans = False
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

def check_serial(mark, number, start, end):
    ans = False
    i = start
    while i < end:
        for j in range(number):
            if j+i > end:
                break
            if s[i+j] != mark:
                i += j 
                break
            elif j == number-1:
                ans = True
        if ans:
            break
        i += 1
    return ans

# print(check_serial('.', 3, 0, n-1))
ans = False
if c > d:
    ans = check_serial('.', 3, b-1, d)
if check_serial('#', 2, a, c-1):
    ans = False
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if c > d:
	if s[b:d].count("...") == 0:
		print("No")
		exit()
print("Yes")

Submission status: Wrong Answer

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 "##" in s:
    print("No")

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

    if C > D:
        if len(index)>=1:
            for i in index:
                if B <= i+1 <= D:
                    print("Yes")
                    exit()
            print("No")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
lis=list(map(int,input().split()))
S=input()
ans="Yes"
memo=0
if lis[3]<lis[4]:
    #Bを先に行かせてみる
    for i in range(lis[2],lis[4]-1):
        if S[i:i+2]=="##":
            ans="No"
            break
    #更にAも行かせてみる
    for i in range(lis[1],lis[3]-1):
        if S[i:i+2]=="##":
            ans="No"
            break
    print(ans)

else:
    #Bの位置に岩を置く
    a=S[:lis[2]-1]
    b=S[lis[2]:]
    S=a+"#"+b
    #print(S)
    #Aを先に行かせる。可能なら終了。ダメならBを先に行かせてみる
    for i in range(lis[1],lis[3]-1):
        if S[i:i+2]=="##":
            ans="No"
            break
    #先にBを行かせる。まず可能か判定
    if ans=="No":
        ans="Yes"
        for j in range(lis[2],lis[4]-1):
            if S[j:j+2]=="##":
                ans="No"
                break
        for j in range(lis[2],lis[4]-2):
            if S[j:j+3]=="...":
                memo=j+1
                break
        #だめなら終了。可能ならmemoもしくはDに岩を置いてAについて検討
        if ans=="Yes":
            #print(S)
            if memo>0:
                a=S[:memo]
                b=S[memo+1:]
                S=a+"#"+b
            else:
                a=S[:lis[4]-1]
                b=S[lis[4]:]
                S=a+"#"+b
            #print(S)
            a=S[:lis[2]-1]
            b=S[lis[2]:]
            S=a+"."+b
            #print(S,memo)
            for k in range(lis[1],lis[3]-1):
                if S[k:k+2]=="##":
                    ans="No"
                    break
    print(ans)

Submission status: Wrong Answer

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

if c > d:
	if s[:d].count("...") == 0:
		print("No")
		exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
lis=list(map(int,input().split()))
S=input()
ans="Yes"
memo=0
if lis[3]<lis[4]:
    #Bを先に行かせてみる
    for i in range(lis[2],lis[4]-1):
        if S[i:i+2]=="##":
            ans="No"
            break
    #更にAも行かせてみる
    for i in range(lis[1],lis[3]-1):
        if S[i:i+2]=="##":
            ans="No"
            break
    print(ans)

else:
    #Bの位置に岩を置く
    a=S[:lis[2]-1]
    b=S[lis[2]:]
    S=a+"#"+b
    #print(S)
    #Aを先に行かせる。可能なら終了。ダメならBを先に行かせてみる
    for i in range(lis[1],lis[3]-1):
        if S[i:i+2]=="##":
            ans="No"
            break
    #先にBを行かせる。まず可能か判定
    if ans=="No":
        ans="Yes"
        for i in range(lis[2],lis[4]-1):
            if S[i:i+2]=="##":
                ans="No"
                break
        for j in range(lis[2],lis[4]-2):
            if S[j:j+3]=="...":
                memo=j+1
                break
        #だめなら終了。可能ならmemoもしくはDに岩を置いてAについて検討
        if ans=="Yes":
            #print(S)
            if memo>0:
                a=S[:memo]
                b=S[memo+1:]
                S=a+"#"+b
            else:
                a=S[:lis[4]-1]
                b=S[lis[4]:]
                S=a+"#"+b
            #print(S)
            a=S[:lis[2]-1]
            b=S[lis[2]:]
            S=a+"."+b
            #print(S,memo)
            for i in range(lis[1],lis[3]-1):
                if S[i:i+2]=="##":
                    ans="No"
                    break
    print(ans)

Submission status: Wrong Answer

Solution code:
figure=input()
math=input()
flg=False
 
figure=figure.split(' ')
if figure[3]>figure[4]:
  flg=True
  
for i in range(len(math)-1):
  if math[i]=='#' and math[i+1]=='#':
    print('No')
    exit()
    
  if flg 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: Wrong Answer

Solution code:
import sys    

# 入力の読み込み
n, a , b, c, d = list(map(int, input().split()))
s = input()

# a,b,c,dをそれぞれ-1する
a, b, c, d = map(lambda x:x-1,[a,b,c,d])

# aとbのうち、小さい方を開始位置とする
# cとdのうち、大きい方を終了位置とする
start = a if a<b else b
end = c if c>d else d
cut_str = s[start:end+1]

## start~endの間に岩が２連続あったらだめ
if cut_str.find('##') != -1:
    print('No')
    sys.exit()

## 追い抜きが発生する場合はb~dの間に...がないとだめ
if c > d and s[b:d+1].find('...') == -1:
    print('No')
    sys.exit()

print('Yes')

Submission status: Wrong Answer

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 "##" in s:
    print("No")

elif C < D:
    print("Yes")

elif C > D:
    if len(index)>=1:
        for i in index:
            if B <= i+1 <= D:
                print("Yes")
                exit()
        print("No")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
lis=list(map(int,input().split()))
S=input()
ans="Yes"
memo=0
if lis[3]<lis[4]:
    #Bを先に行かせてみる
    for i in range(lis[2],lis[4]-1):
        if S[i:i+2]=="##":
            ans="No"
            break
    #更にAも行かせてみる
    for i in range(lis[1],lis[3]-1):
        if S[i:i+2]=="##":
            ans="No"
            break
    print(ans)

else:
    #Bの位置に岩を置く
    a=S[:lis[2]-1]
    b=S[lis[2]:]
    S=a+"#"+b
    #print(S)
    #Aを先に行かせる。可能なら終了。ダメならBを先に行かせてみる
    for i in range(lis[1],lis[3]-1):
        if S[i:i+2]=="##":
            ans="No"
            break
    #先にBを行かせる。まず可能か判定
    if ans=="No":
        ans="Yes"
        for i in range(lis[2],lis[4]-1):
            if S[i:i+2]=="##":
                ans="No"
                break
        for i in range(lis[2],lis[4]-1):
            if S[i:i+3]=="...":
                memo=i+1
                break
        #だめなら終了。可能ならmemoもしくはDに岩を置いてAについて検討
        if ans=="Yes":
            #print(S)
            if memo>0:
                a=S[:memo]
                b=S[memo+1:]
                S=a+"#"+b
            else:
                a=S[:lis[4]-1]
                b=S[lis[4]:]
                S=a+"#"+b
            #print(S)
            a=S[:lis[2]-1]
            b=S[lis[2]:]
            S=a+"."+b
            #print(S,memo)
            for i in range(lis[1],lis[3]-1):
                if S[i:i+2]=="##":
                    ans="No"
                    break
    print(ans)

Submission status: Wrong Answer

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

tmp_s = s[:b - 1] + "#" + s[b:]
a_s = tmp_s[a:]
tmp_s = s[:d - 1] + "#" + s[d:]
aa_s = tmp_s[a:c]

tmp_s = s[:a - 1] + "#" + s[a:]
b_s = tmp_s[b:]
tmp_s = s[:c - 1] + "#" + s[c:]
bb_s = tmp_s[b:d]

a_flag = False
b_flag = False
if d < c:
    if ("##" not in a_s and "##" not in bb_s) or ("##" not in aa_s and "##" not in b_s) or "..." in a_s or "..." in aa_s:
        print("Yes")
    else:
        print("No")
else:
    if ("##" not in a_s and "##" not in bb_s) or ("##" not in aa_s and "##" not in b_s):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

def check_serial(mark, number, start, end):
    ans = False
    i = start
    while i < end:
        for j in range(number):
            if j+i > end:
                break
            if s[i+j] != mark:
                i += j 
                break
            elif j == number-1:
                ans = True
        if ans:
            break
        i += 1
    return ans

# print(check_serial('.', 3, 0, n-1))
ans = False
if c > d:
    ans = check_serial('.', 3, b-1, d-1)
ans = not check_serial('#', 2, a, c-1)
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

e = s.find("##")
if e != -1:
	if e < c or e < d: 
		print("No")
		exit()

e = s.find("...")
if c > d:
	if e == -1:
		print("No")
		exit()
	elif e > c or e > d:
		print("No")
		exit()
print("Yes")

Submission status: Wrong Answer

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 d < c:
    for i in range(b-2, d-1):
        if s[i:i+3] == "...":
            print('Yes')
            exit()
    print('No')
print('Yes')

Submission status: Wrong Answer

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-1,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: Wrong Answer

Solution code:
import sys    

# 入力の読み込み
n, a , b, c, d = list(map(int, input().split()))
s = input()

# a,b,c,dをそれぞれ-1する
a, b, c, d = map(lambda x:x-1,[a,b,c,d])

# aとbのうち、小さい方を開始位置とする
# cとdのうち、大きい方を終了位置とする
start = a if a<b else b
end = c if c>d else d
cut_str = s[start+1:end]

## start~endの間に岩が２連続あったらだめ
if cut_str.find('##') != -1:
    print('No')
    sys.exit()

## 追い抜きが発生する場合はb~dの間に...がないとだめ
if c > d and s[b:d].find('...') == -1:
    print('No')
    sys.exit()

print('Yes')

Submission status: Wrong Answer

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 "##" in s:
    print("No")
    exit()

if C < D:
    print("Yes")

elif C > D:
    if len(index)>=1:
        for i in index:
            if B <= i+1 <= D:
                print("Yes")
                exit()
        print("No")
    else:
        print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

N, A, B , C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = input().strip().translate(str.maketrans({'#': '1', '.': '0'}))
ss = [int(c) for c in S ]

ans = 'Yes'

# 場合分けして解く
if ss[C-1] == 1:
    ans = 'No'

elif ss[D-1] == 1:
    ans = 'No'

elif D > C:
    # 連続して岩があるとき（＝解けない）
    for i in range(D - 1):       
        if ss[i] == 1  and ss[i+1] == 1 :
            ans = 'No'

elif D < C:
    
    # 連続して岩があるとき（＝解けない）
    for i in range(C - 1):       
        if ss[i] == 1  and ss[i+1] == 1 :
            ans = 'No'
    
    # 3マス連続する空きマスがあれば順番をいれかえられる
    if ans == 'Yes':
        ans = 'No'
        for i in range(D - B + 1):
            i = i + B -1
            if ss[i-1] == 0 and ss[i] == 0 and ss[i+1] == 0 :
                ans = 'Yes'
else :
    ans = 'No'

print(ans)

Submission status: Wrong Answer

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] == ".":
                    if i > b-2:
                        if i < d:
                            sanrenzoku = 1

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

Submission status: Wrong Answer

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

if not flg:
	print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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:D+1])

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: Wrong Answer

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

over = 0
e = s.find("##")
if e != -1:
	if e < c or e < d: 
		print("No")
		exit()

if s[c-1] == "#":
	print("No")
	exit()
elif s[d-1] == "#":
	print("No")
	exit()

if c > d:
	if s.find("...") == -1:
		print("No")
		exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
def ans():
    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 s.count("##")>=1:
        return "No"
        

    if C < D:
        return "Yes"

    elif C > D:
        if len(index)>=1:
            for i in index:
                if B <= i+1 <= D:
                    return "Yes"
            return "No"
        else:
            return "No"

print(ans())

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

N, A, B , C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = input().strip().translate(str.maketrans({'#': '1', '.': '0'}))
ss = [int(c) for c in S ]

ans = 'Yes'

# 場合分けして解く
if D > C:
    # 連続して岩があるとき（＝解けない）
    for i in range(D - 1):       
        if ss[i] == 1  and ss[i+1] == 1 :
            ans = 'No'

elif D < C:
    
    # 連続して岩があるとき（＝解けない）
    for i in range(C - 1):       
        if ss[i] == 1  and ss[i+1] == 1 :
            ans = 'No'
    
    # 3マス連続する空きマスがあれば順番をいれかえられる
    if ans == 'Yes':
        ans = 'No'
        for i in range(D - B + 1):
            i = i + B -1
            if ss[i-1] == 0 and ss[i] == 0 and ss[i+1] == 0 :
                ans = 'Yes'
else :
    ans = 'No'

print(ans)

Submission status: Wrong Answer

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

def check_serial(mark, number, start, end):
    ans = False
    i = start
    while i < end:
        for j in range(number):
            if s[i+j] != mark:
                i += j 
                break
            elif j == number-1:
                ans = True
        if ans:
            break
        i += 1
    return ans

ans = False
if c > d:
    ans = check_serial('.', 3, b-1, d-1)
ans = not check_serial('#', 2, a, c-1)
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

N, A, B , C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = input().strip().translate(str.maketrans({'#': '1', '.': '0'}))
ss = [int(c) for c in S ]

ans = 'Yes'

# 場合分けして解く
if D > C:
    # 連続して岩があるとき（＝解けない）
    for i in range(D - 1):       
        if ss[i] == 1  and ss[i+1] == 1 :
            ans = 'No'

elif D < C:
    
    # 連続して岩があるとき（＝解けない）
    for i in range(C - 1):       
        if ss[i] == 1  and ss[i+1] == 1 :
            ans = 'No'
    
    # 3マス連続する空きマスがあれば順番をいれかえられる
    if ans == 'Yes':
        ans = 'No'
        for i in range(D - B):
            i = i + B -1
            if ss[i-1] == 0 and ss[i] == 0 and ss[i+1] == 0 :
                ans = 'Yes'
else :
    ans = 'No'

print(ans)

Submission status: Wrong Answer

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

over = 0
e = s.find("##")
if e != -1:
	if e < c or e < d: 
		print("No")
		exit()

if c > d:
	if s.find("...") == -1:
		print("No")
		exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys    

# 入力の読み込み
n, a , b, c, d = list(map(int, input().split()))
s = input()

# a,b,c,dをそれぞれ-1する
a, b, c, d = map(lambda x:x-1,[a,b,c,d])

# aとbのうち、小さい方を開始位置とする
# cとdのうち、大きい方を終了位置とする
start = a if a<b else b
end = c if c>d else d
cut_str = s[start+1:end]

## start~endの間に岩が２連続あったらだめ
if cut_str.find('##') != -1:
    print('No')
    sys.exit()

## 追い抜きが発生する場合はb~dの間に...がないとだめ
b_to_d_str = s[b+1:d]
if c > d and b_to_d_str.find('...') == -1:
    print('No')
    sys.exit()   

print('Yes')

Submission status: Wrong Answer

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].find("...")
    if f == -1:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

if not flg:
	print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

a_to_c = s[a-1:c-1]
b_to_d = s[b-1:d-1]
b2 = b
d2 = d
if (b-1)-1 >= 0:
    b2 = b-1
if s[d-1]=='#':
    d2 = d-4
b_to_d2 = s[b2-1:d2-1]
    
possibility = True

if a_to_c.find("##")!=-1 or b_to_d.find("##")!=-1:
    possibility = False
if c>d:
    if not(b_to_d2.find('...')!=-1):
        possibility = False

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

Submission status: Wrong Answer

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: Wrong Answer

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]:
        Judge = False
else:

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

    if "..." in Root[Bt-1:Dt+1]:
        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: Wrong Answer

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[Bt:Dt]:
        Judge = False
else:

    if "##" in Root[Bt:Ct]:
        Judge = False

    if "..." in Root[Bt-1:Dt+1] :
        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: Wrong Answer

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

a_to_c = s[a:(c-1)-1]
b_to_d = s[b-1:d-1]

possibility = True

if c>d:
    b_to_d = s[(b-1)-1:(d-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]
    if "##" in a_to_c or "##" in b_to_d:
        possibility = False

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
lis=list(map(int,input().split()))
S=input()
ans="Yes"
memo=0
if lis[3]<lis[4]:
    #Bを先に行かせてみる
    for i in range(lis[2],lis[4]-1):
        if S[i:i+2]=="##":
            ans="No"
            break
    #更にAも行かせてみる
    for i in range(lis[1],lis[3]-1):
        if S[i:i+2]=="##":
            ans="No"
            break
    print(ans)

else:
    #Bの位置に岩を置く
    a=S[:lis[2]-1]
    b=S[lis[2]:]
    S=a+"#"+b
    #Aを先に行かせる。可能なら終了。ダメならBを先に行かせてみる
    for i in range(lis[1],lis[3]-1):
        if S[i:i+2]=="##":
            ans="No"
            break
    #先にBを行かせる。まず可能か判定
    if ans=="No":
        ans="Yes"
        for i in range(lis[2],lis[4]-1):
            if S[i:i+2]=="##":
                ans="No"
                break
        for i in range(lis[2],lis[4]-2):
            if S[i:i+3]=="...":
                memo=i+1
                break
        #だめなら終了。可能ならmemoもしくはDに岩を置いてAについて検討
        if ans=="Yes":
            #print(S)
            if memo>0:
                a=S[:memo]
                b=S[memo+1:]
                S=a+"#"+b
            else:
                a=S[:lis[4]-1]
                b=S[lis[4]:]
                S=a+"#"+b
            #print(S)
            a=S[:lis[2]-1]
            b=S[lis[2]:]
            S=a+"."+b
            #print(S,memo)
            for i in range(lis[1],lis[3]-1):
                if S[i:i+2]=="##":
                    ans="No"
                    break
    print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

N, A, B , C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = input().strip().translate(str.maketrans({'#': '1', '.': '0'}))
ss = [int(c) for c in S ]

ans = 'Yes'

# 場合分けして解く
if D > C:
    # 連続して岩があるとき（＝解けない）
    for i in range(D - 1):       
        if ss[i] == 1  and ss[i+1] == 1 :
            ans = 'No'

elif D < C:
    
    # 連続して岩があるとき（＝解けない）
    for i in range(C - 1):       
        if ss[i] == 1  and ss[i+1] == 1 :
            ans = 'No'
    
    # 3マス連続する空きマスがあれば順番をいれかえられる
    if ans == 'Yes':
        ans = 'No'
        for i in range(D - B):
            i = i + B
            if ss[i-1] == 0 and ss[i] == 0 and ss[i+1] == 0 :
                ans = 'Yes'
else :
    ans = 'No'

print(ans)