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:
#!/usr/bin/env python

import sys
import re

_,a,b,c,d = [ int(x)-1 for x in sys.stdin.readline().split() ]
m = sys.stdin.readline().strip()
#
loc= []
for match in re.finditer( "##",m ): loc.append( match.start() )
if c>d:
    if m[b-1:b+2]!="..." and m[b+1:d+1].find("..")<0:
        print( "NO" )
        exit()
#
# check b->d
flag= False
ii= b+1
jj= d-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
if flag:
    print( "NO" )
    exit()
#
# check a->c
ii= a+1
jj= c-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
#
if flag:
    print( "NO" )
    exit()
#
print( "YES" )

Submission status: Wrong Answer

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

# 3マス空きがあるか
white = []
for i in range(N - 2):
    if S[i] == "." == S[i + 1] == S[i + 2]:
        white.append(i + 1)
if C > D:
    # Aからスタート
    i = A - 1
    T = S.copy()
    T[B - 1] = "#"
    while C - 1 != i:
        if T[i + 1] == ".":
            i += 1
        elif T[i + 2] == ".":
            i += 2
        elif i + 1 == B - 1 or i + 2 == B - 1:
            es = False
            for w in white:
                if w <= D:
                    es = True
            if es:
                i = B - 1
            else:
                break
        else:
            break
    if i == C - 1:
        print("Yes")
        exit()
else:
    i = A - 1
    T = S.copy()
    T[A - 1] = "#"
    while D - 1 != i:
        if T[i + 1] == ".":
            i += 1
        elif T[i + 2] == ".":
            i += 2
        elif i + 1 == A - 1 or i + 2 == A - 1:
            es = False
            for w in white:
                if w <= C:
                    es = True
            if es:
                i = A - 1
            else:
                break
        else:
            break
    if i == D - 1:
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

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

for i in range(0, n-1):
        if s[i] == '#' and s[i+1] == '#':
            ans=0

flag=0
if (a<b and d<c) or (b<a and c<d):
    for i in range(0, n-2):
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
            flag=1
    if flag == 0:
        ans=0
        
if ans == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

if c < d:
    if '##' in s[min(a,b)-1:max(c,d)]:
        print('No')
    else:
        print('Yes')

else:
    if '...' in s[b-2:d]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

if Sp.find('##') != -1:
    print('No')
    exit()

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

if Sp[B-2:D].find('...') >= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, A, B, C, D = read_ints()
S = input()

A -= 1
B -= 1
C -= 1
D -= 1
# 大小関係の実装
plan = 1  # ひっくり返らない処理が1,ヒックリ変えるのが2、領域が二分割されるのが3

if D < C:
    plan = 2

if C < B:
    plan = 3

from sys import exit

# 入れ替わるかの条件ごとに実装する
if plan == 1:
    s = min(A, B, C, D)
    g = max(A, B, C, D)
    for s_left, s_right in zip(S[s:g-1], S[s + 1:g]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()
    print('Yes')
elif plan == 2:
    # planAでない。つまり入れ替わる場合
    s = min(A, B, C, D)
    g = max(A, B, C, D)
    for s_left, s_right in zip(S[s:g-1], S[s + 1:g]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()
    for s_left, s_center, s_right in zip(S[B:D - 1], S[B + 1:D], S[B + 2:D + 1]):
        if s_left == '.' and s_center == '.' and s_right == '.':
            print('Yes')
            exit()
    print('No')
elif plan == 3:
    # AC,BD間に##の存在を確かめれば良い
    for s_left, s_right in zip(S[A:], S[A+1:C]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()
    for s_left, s_right in zip(S[B:], S[B+1:D]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()
    print('Yes')

Submission status: Wrong Answer

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

if A<C<B<D:
    if CanKenKen(S,A,C) and CanKenKen(S,B,D):
        print("Yes")
    else:print("No")
elif A<B<D<C:
    if CanKenKen(S,A,C):
        oikosi=0
        if B>=2:Q=S[B-2:D+1]
        else:Q=S[:D+1]
        for n,i in enumerate(Q):
            if i=="." and Q[n+1]=="." and Q[n+2]==".":
                oikosi=1
                break
            if n==D-B-2:break
        if oikosi: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: Wrong Answer

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

ans = 0
def aaa(s,g):
    global ans
    if S[s:g].count("##") == 0:
        ans += 1
    
def bbb(s,g):
    global ans
    if S[s:g].count("##") == 0:
        ans += 1
        return(1)
    else:
        return(0)
        
if c < d:
    aaa(b,d)
    aaa(a,c)
else:
    flag = bbb(b,d)
 #   print(ans)
    if flag == 1:
        """
        for i in range(b,d+1):
            if S[i-1:i] != "#":
                k = S[:i-1] + "#" + S[i:]
   #             print(k,i)
                if k[a:c].count("##") == 0:
                    flag = 2
                    break
        if flag == 2:
            aaa(a,c)
        """
        if S[a:c].count("...") != 0:
            ans += 1
#    print(flag)
  #  print(ans)

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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
S = input()
flg = True
if S[C-1] == '#' or S[D-1] == '#':flg =False
for i in range(A,C):
    if S[i] == '#' and S[i+1] == '#':
        flg = False
        break

for r in range(B-1,D):
    if S[r] == '#' and S[r+1] == '#':
        flg = False
        break
if C == D:flg=False
if C > D:
    threeFlg =True
    #../../
    for k in range(B-1,D-3):
        if S[k] == '#':
            if not S[k+3] == '#':
                threeFlg = False
                break
    #../.D/ or ../.D
    if threeFlg:
       if (D-1-S.find('#',B-1))%3 == 2:
           if D == N or S[D] == '#':
               flg = False
       else: flg = False

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

Submission status: Wrong Answer

Solution code:
from copy import deepcopy

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


def start_funuke():
    s = deepcopy(S)
    funuke = s[B - 1 : D]
    for i in range(1, len(funuke)):
        if funuke[i] == "#" and funuke[i - 1] == "#":
            return False
    s[D - 1] = "#"
    sunuke = s[A - 1 : C]
    for i in range(1, len(sunuke)):
        if sunuke[i] == "#" and sunuke[i - 1] == "#":
            return False
    return True


def start_sunuke():
    s = deepcopy(S)
    sunuke = s[A - 1 : C]
    for i in range(1, len(sunuke)):
        if sunuke[i] == "#" and sunuke[i - 1] == "#":
            return False
    s[C - 1] = "#"
    funuke = s[B - 1 : D]
    f = True
    for i in range(2, len(funuke)):
        if funuke[i] == "." and funuke[i - 1] == "." and funuke[i - 2] == ".":
            f = False
    if f:
        return False
    for i in range(1, len(funuke)):
        if funuke[i] == "#" and funuke[i - 1] == "#":
            return False
    return True


f1 = start_funuke()
f2 = start_sunuke()
if f1 or f2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=list(map(int,input().split()))
S=input()
bS=S[B-1:D]
a=True
if C<D:
    if "##" in bS:
        a=False
    else:
        aS=S[A-1:C]
        if "##" in aS:
            a=False

else:
    if "##" in bS:
        a=False
    else:
        aS=S[A-1:C]
        if "##" in aS:
            a=False
        else:
            tmp=S[:B-1]+"#"+S[B:]
            aS=tmp[A-1:C]
            j1= ("##" in aS)
            tmp=S[:D-1]+"#"+S[D:]
            aS=tmp[A-1:C]
            j2= ("##" in aS)
            if  ("..." in bS or (j1 or j2)):
                a=True
            else:
                a=False
            
        
        
if a:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if "##" in s[b:d+1]:
	# print('b-dで岩２つ')
	ans = 'No'
else:
	if "##" in s[a:c+1]:
		# print('a-cで岩２つ')
		ans = 'No'
	else:#邪魔な岩は無し
		if c>d: #ふぬけを飛び越える必要がある場合
			#ふぬけ君を飛び超えるために3マス以上連続で空いてる場所を探してあげる
			if "..." in s[b:d+1]:
				# print('空きマス３つある')
				ans = 'Yes'
			else:#飛び越えるスペースが無かった
				# print(s[b:])
				# print('空きマス３つない・・・')
				ans = 'No'
		else:#ふぬけ、すぬけの順に動かせばいい場合、岩はもう見た
			# print('ふぬけ→すぬけ　OK')
			ans = 'Yes'

print(ans)

Submission status: Wrong Answer

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(a-1,c):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
        elif s[i]=='#':
            buf=max([span,buf])
            span=0
        elif b-1<i<d+1:
            span+=1
    if buf<=2:
        flag=1
        #print(buf)
print('No' if flag==1 else 'Yes')

Submission status: Wrong Answer

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


def f():
    can_over = False

    prev_1 = ""
    for i in range(A, C + 1):
        now = S[i]
        if prev_1 == "#" and now == "#":
            return False

    prev_1 = ""
    for i in range(B, D + 1):
        now = S[i]
        if prev_1 == "#" and now == "#":
            return False

    if C < D:
        return True

    prev_2 = ""
    prev_1 = ""
    for i in range(B, min(D + 2, N)):
        now = S[i]
        if prev_1 == prev_2 == now == ".":
            can_over = True

        prev_2, prev_1 = prev_1, now

    return can_over

print("Yes" if f() else "No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys

[N, A, B, C, D] = [int(i) for i in input().split()]

S = input()

# '#'が2連続あれば移動不可能
S_split = S.split('.')

max_length = 0
for s in S_split:
    if len(s) > max_length:
        max_length = len(s)

if max_length >= 2:
    print('No')
    sys.exit()

# ここまでくればBは必ず目的地に到着可能

# もしC<DだったらAも必ず到着可能
if C < D:
    print('Yes')
    sys.exit()

# もしC>Dだったら、Dの手前が'#'もしくはDの奥が'#'の場合はAはほぼ到達不可能
if S[D-2] == '#' or S[D] == '#':
    # もしS[A]からS[D-1]の間に'...'があればAは到達可能
    if '...' in S[A:D]:
        print('Yes')
        sys.exit()
    print('No')
    sys.exit()

print('Yes')

Submission status: Wrong Answer

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

flag = True

# c < dならbを先にゴールさせれば良い
s_bd = s[b:d-1]
for i in range(len(s_bd)-1):
    if s_bd[i:i+2] == "##":
        flag = False
        break
s_ac = s[a:c-1]
for i in range(len(s_ac)-1):
    if s_ac[i:i+2] == "##":
        flag = False
        break

if c > d:
    s_ac = s[a-1:c]
    has_ddd = False
    for i in range(len(s_ac)-2):
        if s_ac[i:i+3] == "...":
            has_ddd = True
    if has_ddd == False:
        flag = False

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if '##' in S :
    print("No")
    quit()

if C > D:
    if '...' not in S[B:C-2]:
        print("No")
        quit()


print("Yes")

Submission status: Wrong Answer

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


if s[c-1] =='#':
    print('No')
    exit(0)
if s[c-1] =='#':
    print('No')
    exit(0)
for i in range(b,d-1):
    if s[i]=='#' and s[i+1]=='#':
        print('No')
        exit(0)
for i in range(a,c-1):
    if s[i]=='#' and s[i+1]=='#':
        print('No')
        exit(0)
if c>d:
    flag = False
    for i in range(b-2,n):
        if s[i:i+3]=='...':
            flag = True
            break
    if not flag:
        print("No")
        exit(0)
    else:
        print("Yes")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
A -= 1
B -= 1
C -= 1
D -= 1
S = list(input())
if (A < B < D < C):
    cnt = 0
    cntl = []
    for i in range(A+1,C-1):
        if (S[i] == '.') & (S[i+1] == '.'):
            cnt += 1
        elif (S[i] == '.') & (S[i+1] == '#'):
            cntl.append(cnt)
            cnt = 0
    if max(cntl) < 2:
        print('No')
    else:
        cnt = 0
        cntL = []
        for i in range(B+1,D-1):
            if (S[i] == '#') & (S[i+1] == '#'):
                cnt += 1
            elif (S[i] == '#') & (S[i+1] == '.'):
                cntL.append(cnt)
                cnt = 0
        if max(cntL) >= 1:
            print('No')
        else:
            if (S[D+1] == '.')&(S[D-1] == '.'):
                print('Yes')
            elif S[D-1] == '#':
                x = 0
                xl = []
                for i in range(B-1,D-2):
                    if (S[i] == '.') & (S[i+1] == '.'):
                        x += 1
                    elif (S[i] == '.') & (S[i+1] == '#'):
                        xl.append(x)
                if max(xl) >= 2:
                    print('Yes')
                else:
                    print('No')
            else:
                x = 0
                xl = []
                for i in range(B-1,D-1):
                    if (S[i] == '.') & (S[i+1] == '.'):
                        x += 1
                    elif (S[i] == '.') & (S[i+1] == '#'):
                        xl.append(x)
                if max(xl) >= 2:
                    print('Yes')
                else:
                    print('No')
else:
    cnt = 0
    cntl = []
    for i in range(A+1,C-1):
        if (S[i] == '#') & (S[i+1] == '#'):
            cnt += 1
        elif (S[i] == '#') & (S[i+1] == '.'):
            cntl.append(cnt)
            cnt = 0
    if max(cntl) >= 1:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

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

if Sp.find('##') != -1:
    print('No')
    exit()

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

if Sp[B-1:D].find('...') >= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def main():
    inp = input()
    st = inp.split()
    n = int(st[0])
    a = int(st[1])
    b = int(st[2])
    c = int(st[3])
    d = int(st[4])
    inp = input()
    # 2 rocks
    rock_count = 0
    for i in range(a, b):
        if inp[i] == '#':
            rock_count += 1
        elif inp[i] == '.':
            rock_count = 0
        if rock_count == 2:
            print("No")
            return

    max_cd = c if c > d else d
    continuous_count = 0
    nothing_count = 0
    nothing_3 = False
    if inp[b-1] == '.':
        nothing_count += 1
    for i in range(b, max_cd):
        if inp[i] == '#':
            continuous_count += 1
            nothing_count = 0
        elif inp[i] == '.':
            continuous_count = 0
            nothing_count += 1
        if continuous_count == 2:
            print("No")
            return
        if nothing_count == 3 and i < d + 1:
            nothing_3 = True

    # c < d
    if c < d or nothing_3:
        print("Yes")
    else:
        if (inp[d-1] == '.' and inp[d-2] == '.') and (inp[d] == '.' or inp[d-3] == '.'):
            print("Yes")
        else:
            print("No")
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if "##" in s:
    print("No")
    exit()

if a < b and c > d:
    if "..." not in s[b-1:d-1]:
        print("No")
        exit()

if a > b and c < d:
    if "..." not in s[a-1:c-1]:
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

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

if "##" in s[A-1:C]+" "+s[B-1:D]:
  print("NO")
  quit()
st,e=0,0
for spl in s.split("##"):
  e += len(spl)
  if st <A<max(C,D)<e:
    break
  st+= len(spl)

if "..." in s[st:e]:
  print("YES")
elif D<C:
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
s = input()
if '##' in s:
    print('No')
else:
    if C > D:
        if '...' in s[B:D]:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
S = input()
flg = True
if S[C-1] == '#' or S[D-1] == '#':flg =False
for i in range(A,C):
    if S[i] == '#' and S[i+1] == '#':
        flg = False
        break

for r in range(B-1,D):
    if S[r] == '#' and S[r+1] == '#':
        flg = False
        break
if C == D:flg=False
if C > D:
    threeFlg =True
    #../../
    for k in range(B-1,D-3):
        if S[k] == '#':
            if not S[k+3] == '#':
                threeFlg = False
                break
    print(S.find('#',B-1))
    #../.D/ or ../.D
    if threeFlg:
       if (D-1-S.find('#',B-1))%3 == 2:
           if D == N or S[D] == '#':
               flg = False
       else: flg = False

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

Submission status: Wrong Answer

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")
    elif B-A == 1 and S[A-1:A+2] == '...':
        print("Yes")
    elif '...' in S[B-1:D]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int, input().split())
S='.'+input()
dpa=[0]*(n+1)
dpb=[0]*(n+1)
seta=[c]
setb=[d]
if d<c:
    if S[b-1:d+2].find('...')>0:
        S[b-1:d+2].replace('...', '.#.', 1)
        while seta:
            i = seta.pop()
            if i>0 and S[i-1]=='.' and dpa[i-1]==0:
                dpa[i-1]=1
                seta.append(i-1)
            if i>1 and S[i-2]=='.' and dpa[i-2]==0:
                dpa[i-2]=1
                seta.append(i-2)
        while setb:
            i = setb.pop()
            if i>0 and S[i-1]=='.' and dpb[i-1]==0:
                dpb[i-1]=1
                setb.append(i-1)
            if i>1 and S[i-2]=='.' and dpb[i-2]==0:
                dpb[i-2]=1
                setb.append(i-2)

else:
    while setb:
        i = setb.pop()
        if i>0 and S[i-1]=='.' and dpb[i-1]==0:
            dpb[i-1]=1
            setb.append(i-1)
        if i>1 and S[i-2]=='.' and dpb[i-2]==0:
            dpb[i-2]=1
            setb.append(i-2)
    while seta:
        i = seta.pop()
        if i>0 and S[i-1]=='.' and dpa[i-1]==0:
            dpa[i-1]=1
            seta.append(i-1)
        if i>1 and S[i-2]=='.' and dpa[i-2]==0:
            dpa[i-2]=1
            seta.append(i-2)
if dpa[a]==1 and dpb[b]==1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from sys import stdin

n, a, b, c, d = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()

# A..C 二つの岩 あったらだめ
# B..D二つの岩 あったらだめ
# D < Cのとき、 AがBを追い越せななかったらだめ

ans = "Yes"

rock = 0
for i in range(a, c):
    if '#' == s[i-1]:
        rock += 1
        if rock >= 2:
            ans = "No"
            break
    else:
        rock = 0

rock = 0
for i in range(b, d):
    if '#' == s[i-1]:
        rock += 1
        if rock >= 2:
            ans = "No"
            break
    else:
        rock = 0


space = 0
if d < c:
    ok = 0
    for i in range(b, d):
        if '.' == s[i-1]:
            space += 1
            if space >= 3:
                ok = 1
    if '.' == s[d-1-1] and '.' == s[d+1-1]:
        ok = 1
    if '.' == s[b-1-1] and '.' == s[b+1-1]:
        ok = 1
    if 0 == ok:
        ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,a,b,c,d=LI()
  s=S()

  if '##' in s[a:c-1]:
    return 'No'
  if '##' in s[b:d-1]:
    return 'No'

  if s[c-1]=='#':
    return 'No'
  if s[d-1]=='#':
    return 'No'
  
  if d<c:
    if '...' not in s[a:c]:
      return 'No'

  return 'Yes'

print(main())

Submission status: Wrong Answer

Solution code:

import sys
sys.setrecursionlimit(100000000)

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

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

for i in range(len(s)):
    if i == len(s) - 1:
        continue
    else:
        if s[i] == '#' and s[i+1] == '#':
            print("No")
            exit()

if D < C:
    tmp = 0
    for i in range(len(s)):
        if i == len(s) - 2 or i == len(s) - 1:
            continue
        else:
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
                tmp = 1
    if tmp != 1:
        print("No")
        exit()



def check(s, start, goal, ans):
    if start == goal:
        return 1
    if s[start] == '#':
        return 0
    if start + 1 <= N - 1:
        ans += check(s, start + 1, goal, ans)
    if start + 2 <= N - 1:
        ans += check(s, start + 2, goal, ans)
    return ans

ans = 0
if not check(s, B, D, ans):
    print("No")
    exit()
#s[D] = '#'
if not check(s, A, C, ans):
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

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

l_s = []
for i in range(len(s)):
    l_s += [0 if s[i] == '.' else 1]

ans = 'Yes'
if i in range(len(s)-1):
    if sum(l_s[i:i+2])==2:
        ans = 'No'

if ans == 'Yes':
    if d>c:
        pass
    else:
        ans = 'No'
        for j in range(d-b-2):
            if sum(l_s[j:3+j]) == 0:
                ans = 'Yes'
            else:
                pass

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
 
S = input()
 
S = S + '#'
 
def continuous_rock_search(S, C, D):
    target = max(C, D)
    for i in range(target - 1):
        if S[i] == '#' and S[i+1] == '#':
            return True
    return False
  
def validation_funuke_move(S, B, D):
    '''
    ふぬけ君が両隣に岩がなくなるまで移動したとき、Dより向こうにはイカないことを確認する。
    True/False and ふぬけの移動後の位置
    '''
    funuke_position = B
    while (B <= D):
        if (S[B-2] == '#' or S[B] == '#'):
            if S[B] == '.' :
                B = B + 1
            else:
                B = B + 2
        elif (S[B-2] == '.' and S[B] == '.'):
            return True, B
    
    return False, -1
  
def KenKenRace(S, A, B, C, D):
    if continuous_rock_search(S, C, D):
        return False
    
    if C < D:
        return True
    
    if D < C:
        valid , _ = validation_funuke_move(S, B, D)
        if valid:
            return True
        else:
            return False
          
if KenKenRace(S, A, B, C, D):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
mx = max(C,D)
r_count = [len(s) for s in S[A-1:mx].split('.') if len(s) > 1]
if r_count != []:
    print('No')
    exit()
if C < D:
    print('Yes')
    exit()

count = [len(s) for s in S[A-1:D+1].split('#') if len(s) > 2]
print('Yes' if len(count) > 0 else 'No')

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    split = input().split(' ')
    n = int(split[0]) - 1
    a = int(split[1]) - 1
    b = int(split[2]) - 1
    c = int(split[3]) - 1
    d = int(split[4]) - 1
    s = input()
    isOK = False
    if c < d:
        isOK = not ('##' in s[a:c] or '##' in s[b:d])
    else:
        isOK = (not ('##' in s[a:c] or '##' in s[b:d])) and ('...' in s[b:d+1])
    print('Yes' if isOK else 'No')

Submission status: Wrong Answer

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

ans = True
d = False
for i in range(B,D):
    if(S[i] == "#" and d):
        ans = False
        break
    elif(S[i] == "#"):
        d = True
    else:
        d = False
d = False
for j in range(A,C):
    if(S[j] == "#" and d):
        ans = False
        break
    elif(S[j] == "#"):
        d = True
    else:
        d = False
if(C>D):
    ans = ans and S[B-1:C].count("...")!=0

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
s=list(s)
s.append('#')
s.append('#')
out=0
ct=0
if c<d:
    for i in range(a-1,c):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    if out>0:print('No')
    else:print('Yes')
        
elif c>d:
    for i in range(a-1,c):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
            #print('Yes')
            ct+=1
        
    if(out>0 or ct==0):print('No')
    else:print('Yes')

Submission status: Wrong Answer

Solution code:
I=lambda:map(int,input().split())
N,A,B,C,D=I()
S=input()
cross=True if D<C else False
if not(cross):
    ac = [i for i in range(A-1,C) if S[i]=='#']
    bd = [i for i in range(B-1,D) if S[i]=='#']
    f=True
    for i in range(len(ac)-1):
        if ac[i]+1==ac[i+1]:f=False
    for i in range(len(bd)-1):
        if bd[i]+1==bd[i+1]:f=False
    print('Yes' if f else 'No')
else:
    ac = [i for i in range(A-1,C) if S[i]=='#']
    bd = [i for i in range(B-1,D) if S[i]=='#']
    f=True
    akichi=False
    for i in range(len(ac)-1):
        if ac[i]+1==ac[i+1]:f=False
        if ac[i+1]-ac[i]>=4:akichi=True
    for i in range(len(bd)-1):
        if bd[i]+1==bd[i+1]:f=False
    print('Yes' if f and akichi else 'No')

Submission status: Wrong Answer

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

listA=list(map(int,input().split()))

kenken_map = input()

A_init = listA[1]-1
B_init = listA[2]-1
A_goal = listA[3]-1
B_goal = listA[4]-1


kenken_temp = kenken_map[A_init:]
kenken_temp_b = kenken_map[:B_goal] + '#' + kenken_map[B_goal+1:]

if '##' in kenken_temp or '##' in kenken_temp_b:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
#ぬかさないケース
if s[a:d].find("##")==-1:
  if c<b:
    if s[a:c].find("##")==-1 and s[b:d].find("##")==-1:
      print("Yes")
    else:
      print("No")
  elif c<d:
    print("Yes")
  else:
    if s[b-1:d+1].find("...")==-1:
      print("No")
    else:
      print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

if "##" in s[b:d+1]:
	# print('b-dで岩２つ')
	ans = 'No'
else:
	if "##" in s[a:c+1]:
		# print('a-cで岩２つ')
		ans = 'No'
	else:#邪魔な岩は無し
		if c>d: #ふぬけを飛び越える必要がある場合
			#ふぬけ君を飛び超えるために3マス以上連続で空いてる場所を探してあげる
			if "..." in s[b:d]:
				# print('空きマス３つある')
				ans = 'Yes'
			else:#飛び越えるスペースが無かった
				# print(s[b:])
				# print('空きマス３つない・・・')
				ans = 'No'
		else:#ふぬけ、すぬけの順に動かせばいい場合、岩はもう見た
			# print('ふぬけ→すぬけ　OK')
			ans = 'Yes'

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int, input().split())
A-=1
B-=1
C-=1
D-=1
S=input()
s=[0]*N
stop=[0]*N
space=[0]*N
for i in range(N):
    if S[i]=='#':
        s[i]=1
        if i>0 and s[i-1]==1:
            stop[i]=1
    elif i>1 and s[i-1]==0 and s[i-2]==0:
        space[i]=1
    if i>0:
        stop[i]+=stop[i-1]
        space[i]+=space[i-1]
if stop[C]-stop[A]>0 or stop[D]-stop[B]>0:
    ans=0
elif C<D:
    ans=1
elif space[D+1]-space[B+1]>0:
    ans=1
else:
    ans=0
print(['No','Yes'][ans])