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

a_to_c = s[a-1:c]
b_to_d = s[b-1:d]
# print(a_to_c)
# print(b_to_d)
if '##' in a_to_c or '##' in b_to_d:
    print('No')
    exit()

s_range = s[max(a, b)-1:min(c, d)]
# print(s_range)
if not ((a > b and c > d) or (a < b and c < d)):
    if '...' not in s_range:
        print('No')
        exit()
print('Yes')

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

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 safe_place(road):
    n=len(road)
    for i in range(n-2):
        block=road[i:i+3]
        if block=='...':
            return i+1
    return -1

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(input())
last = ""
for i in range(a, max(c, d)):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
if c > d:
    s[b - 1] = "#"
    flag = True
    for i in range(a, c):
        if last == "#" and s[i] == "#":
            flag = False
        last = s[i]
    s[b - 1] = "."
    count = 0
    for i in range(b, c):
        if s[i] == ".":
            count += 1
            if count == 3:
                flag = True
        else:
            count = 0
else:
    flag = True
    for i in range(b, d):
        if last == "#" and s[i] == "#":
            flag = False
        last = s[i]
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

# 連続空白を調べる
isStone = False
spaceChainCount = 0
threeSpaceCenterIndex = -1
for i in range(a - 0, len(s)):
    if s[i] == '#':
        # 2連続の場合
        if isStone:
            print("No")
            sys.exit()
        isStone = True
        spaceChainCount = 0
    else:
        isStone = False
        spaceChainCount += 1
        if spaceChainCount >= 3:
            threeSpaceCenterIndex = i - 1

# A,Bが入れ替わる場合
if c > d:
    # 3連続空白が無い場合 or 3空白がA,B両方より左の場合
    if threeSpaceCenterIndex < 0 or (threeSpaceCenterIndex >= 0 and threeSpaceCenterIndex < b - 1):
        print("No")
        sys.exit()

# 通ってきたならOK
print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if s[a-1:max(c,d)].count("##")>0:
    print("No")
elif c<d:
    print("No")

Submission status: Wrong Answer

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

if c < d:
  if "##" in s[:d]:
    print("No")
  else:
    print("Yes")
else:
  if "##" in s[:c]:
    print("No")
  else:
    if "..." in s[b-2:d+1]:
      print("Yes")
    else:
      print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import sys

def is_dubble_wall(min_, max_, S):
    for i in range(min_, max_):
        if (S[i] == "#") and (i < len(S) - 1) and (S[i + 1] == "#"):
            return True
    return False

def is_change(A, B, C, D):
    if (A < B) and (C > D):
        return True
    else:
        return False

def main():
    N, A, B, C, D = map(int, input().split())
    S = "#"
    S += input()
    assert(len(S) == N + 1)
    if (B < C) and (D < C):
        if is_dubble_wall(A, C, S):
            print("No")
            sys.exit()
        if (is_change(A, B, C, D)):
            #二人が入れ替わる時
            num = 0
            array = []
            for i in range(B - 1, D + 2):
                if S[i] == ".":
                    num += 1
                else:
                    array.append(num)
                    num = 0
            if max(array) >= 3:
                print("Yes")
            else:
                print("No")
    else:
        if (~is_dubble_wall(A, C, S) and ~is_dubble_wall(B, D, S)):
            print("Yes")
        else:
            print("No")

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = [int(x) for x in input().split(" ")]
S = str(input())

Sn = list()
for i in S:
    if(i == "."):
        Sn.append(0)
    else:
        Sn.append(1)
        

front = b-1
back = a-1
tof = d-1
tob = c-1

isCan = True
isHide = False

for i in range(front,tof-2):
    if(Sn[i+1] == 1 and Sn[i+2]==1):
        isCan = False
        break
        
    if(Sn[i] == 0 and Sn[i-1] == 0 and Sn[i+1] == 0):
        isHide = True

if(isCan == True and isHide == False):
    Sn[tof] = 1
    
        
for j in range(back,tob-2):
    if(Sn[j+1] == 1 and Sn[j+2] == 1):
        isCan = False
        break
        
if(isCan == True):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
muripo = ((A>B and C<D) and S[B-2] == '#' or S[B] == '#') or ((B>A and C>D) and S[A-2] == '#' or S[A] == '#')
if muripo:
	print("No")
	exit(0)
koerunka = (A>B and C<D) or (B>A and C>D)
koreikoukoerenyo=float('inf')
for i in range(min(A-1,B-1)+2, N):
	if S[i-1] == S[i] == '#':
		koreikoukoerenyo = i
		break
	if S[i-3] == S[i] == '#':
		if koerunka:
			koreikoukoerenyo = i-2
			break
print(koerunka, koreikoukoerenyo, max(C,D))
muripo=koreikoukoerenyo < max(C,D)
print("No" if  muripo else "Yes")

Submission status: Wrong Answer

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


for i in range(N-1):
    if S[i] == "#" and S[i+1] == "#":
        print("No")
        exit()

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


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

print("No")

Submission status: Wrong Answer

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

if s[a:c-1].count("##") > 0 or s[b:d-1].count("##") > 0:
    print("No")
elif c < d:
    print("Yes")
else:
    if s[b:].count("...") > 0 or s[b:b+2] == ".." or s[b-2] == "." and s[b] == ".":
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

N,A,B,C,D = list(map(int, input().split()))
S = input()
s = S
ans = "No"
if "##" in S[B : min([C, D])]:
    ans = "No"
else:
    if C < D:
        ans = "No"
        if not "##" in S[B:D]:
            if not "##" in S[A:C]:
                ans = "Yes"
    else:
        S = S[:C]
        s = S
        
        if not "##" in S[B:D]:
            S = S[:D-1] + "#" + S[D:]
            if not "##" in S[A:]:
                ans = "Yes"
            else:
                ans = "No"
        else:
            ans = "No"

        S = s
        if ans is "No":
            S = S[:B-1] + "#" + S[B:]
            if not "##" in S[A:]:
                S = S[:D]
                if not "##" in S[B:]:
                    ans = "Yes"
                else:
                    ans = "No"
            else:
                ans = "No"

            if ans is "No":
                S = s
                if "..." in S[B:D]:
                    if not "##" in S[A:]:
                        S = S[:D]
                        if not "##" in S[B:]:
                            ans = "Yes"
                        else:
                            ans = "No"
                    else:
                        ans = "No"        

print(ans)

Submission status: Wrong Answer

Solution code:
import copy
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:
        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:
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def SI(): return input()

N,A,B,C,D=LI()
st=input()

if C < D:
    if st[A:C].find('##') >= 0 or st[B:D].find('##') >= 0:
        print('No')
    else:
        print('Yes')
else:
    # Cの方がおおきいケース 入れ替わる
    if st[A:C].find('##') >= 0:
        print('No')
    else:
        lft = 0
        for i in reversed(range(1, A)):
            if st[i] == '#' and st[i-1] == '#':
                lft = i+1
                break
        rgt = st.find('##', C)

        aru = st[lft:rgt].find('...')
        # print("lft{} rgt{} aru{}".format(lft, rgt, aru))
        if aru == -1:
            print('No')
        else:
            print('Yes')

Submission status: Wrong Answer

Solution code:
# 2019/06/02
# AtCoder Grand Contest 034 - A

# For the answer:
# 1-1. Search min(ac) and max(abcd)
# 1-2. Search ## between min and max
# 2. Case:B<C, Left of B is . and (. or C), or exist .. -> Yes

# Def 1 : True is "Case No"
def searchRock(in_l, in_r, in_str, in_tg):

    wflg = False    
    rcflg = False
    for i in range(in_l - 1, in_r - 2):
        if in_str[i] == in_tg and in_str[i+1] == in_tg:
            if wflg == True:
                rcflg = True
                break
            else:
                wflg = True
        else:
            wflg = False
    return rcflg

# Input
n, a, b, c, d = map(int, input().split())
s = input()
ans = ""

# 1. Search ##
if c < b:
    # Search between a and c, b and d
    rflg = searchRock(a, c, s, "#")
    if rflg == True:
        ans = "No"
    else:
        rflg = searchRock(b, d, s, "#")
        if rflg == True:
            ans = "No"

else:
    # Search between a and max(c, d)
    rflg = searchRock(a, max(c, d), s, "#")
    if rflg == True:
        ans = "No"
    
# 2. Check around b
if ans != "No":
    if (b < c and d < c):
        pflg = searchRock(b, c, s, ".")
        if pflg == False:
            if s[b-2] == "." and s[b] == ".":
                ans = "Yes"
            else:
                ans = "No"
        else:
            ans = "Yes"
    else:
        ans = "Yes"

# Output
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-1:c]:
    return 'No'
  if '##' in s[b-1:d]:
    return 'No'
  
  if d<c:
    print(s[a:c])
    if '...' not in s[a-1:c]:
      return 'No'

    if s[d-2:d+1]=='#.#':
      return 'No'

  return 'Yes'

print(main())

Submission status: Wrong Answer

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

if Sp[A-1:max([C, D])].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:
def test():
    n, a, b, c, d = map(int, input().split())
    s = list(input())

    s.insert(0, '.')

    # C D までに岩が2個あるか
    t = s[min(a,b):max(c,d)]
    st = "".join(t)
    if '##' in st:
        print("No")
        return

    # A B が入れ替わるかどうか
    if (c > d):
        # 入れ替わるスペースがあるか
        u = s[max(a,b):min(c,d)]
        su = "".join(u)
        if not '...' in su:
            print("No")
            return

    print("Yes")

test()

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 a < b and c > d:
    if "##" in s[a-1:c]:
        print("No")
        exit()

    if "..." not in s[a-1:c]:
        print("No")
        exit()

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

    if "..." not in s[b-1:d]:
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

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

# dot: 0
# sharp: 1
current_letter = '.'
current_continuous_num = 0
continuous_num = {".": 0, "#": 0}
for i in s:
    if i == current_letter:
#         print(i + ", " + "true")
        current_continuous_num += 1
#         print(continuous_num)
    else:
#         print(i + ", " + "false")
        if continuous_num[current_letter] < current_continuous_num:
            continuous_num[current_letter] = current_continuous_num
        current_letter = i
        current_continuous_num = 1
#         print(continuous_num)
if continuous_num[i] < current_continuous_num:
    continuous_num[i] = current_continuous_num


possibility = True

if continuous_num["#"] >= 2:
    possibility = False
if (a>b and c<d) or (a<b and c>d):
    if continuous_num["."] < 3:
        possibility = False

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

Submission status: Wrong Answer

Solution code:
def check(start,end,road):
    s = road[start-1:end-1]
    if '##' in s:
        return False
    else:
        return True
 
def check2(start,end,road):
    s = road[start-1:end-1]
    if '...' in s:
        return True
    else:
        return False
 
if __name__ == '__main__':
    n,a,b, c,d = map(int, input().split())
    s = input()
    if c < d:
        if check(a,d,s):
            print('Yes')
        else:
            print('No')
    else:
        if check2(a,c,s):
            if check(a,d,s):
                print('Yes')
            else:
                print('No')
        else:
            print('No')

Submission status: Wrong Answer

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

if "##" in S[A-1:C]:
	print("No")
elif "##" in S[B-1:D]:
	print("No")
elif D < C:	# A jumps over B
	if not "..." in S[A-1:C]:
		print("No")
	elif S[A-1:C].count("...") == 1:
		if S[D-2:D+1] == "#..":
			print("No")
		else:
			print("Yes")
	else:
		print("Yes")
else:
	print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
c1 = [0] * N
c2 = [0] * N
cnt1 = 0
cnt2 = 0
for i in range(N):
    if S[i] == '.':
        c2[i] = cnt2
        cnt2 = 0
        cnt1 += 1
    else:
        c1[i] = cnt1
        cnt1 = 0
        cnt2 += 1
        
if cnt1 >= 1:
    c1[-1] = cnt1
if cnt2 >= 1:
    c2[-1] = cnt2
    
index2 = []
index1 = []
for i in range(N):
    if c2[i] >= 2:
        index2.append(i)
    if c1[i] >= 3:
        index1.append(i)
flag = True
for i in index2:
    if A < i - c2[i] + 1 < C or B < i - c2[i] + 1 < D:
        flag = False
    if C < i < A or D < i < B:
        flag = False

if len(index1) == 0:
    if A < B and C > D:
        flag = False
    if A > B and C < D:
        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()
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[A:C-1])
    #print(s_change)
    judge = s_change.count("..")
    #print(judge)
    if judge > 1:
      print("Yes")
    else:
      print("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:
        if d - b == 1:
            isOK = ('##' not in s[a:c]) and (not s[b:d+2] == '#..#')
        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:

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] == '.' and i + 2 < D and A < i:
                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 = input()

ans = "Yes"
space = 0
tmpSpace = 0
# 岩判定
for i in range(A - 1, C):
    if i != 0 and s[i-1:i+1] == "##":
        ans = "No"
        break

for i in range(B - 1, D):
    if i != 0 and s[i-1:i+1] == "##":
        ans = "No"
        break

# スペース >= 2 判定
spaceFlg = False
for i in range(max(A, B) - 1, min(C, D) + 1):
    if i != 0 and s[i-1:i+2] == "...":
        spaceFlg = True
        break

if (A - B) * (C - D) < 0 and not spaceFlg:
    ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
import re

n,a,b,c,d = input().split()
li = input()

pat1 = '##'
pat2 = r'\.\.\.'

sm = int(c) if int(c) < int(d) else int(d)
lg = int(c) if int(c) > int(d) else int(d)

sh = li[:sm]
sh = li[int(b) - 1:]
lo = li[:lg]
ret = ''

if re.match(pat1, lo):
    ret = 'No'
else:
    if c > d:
        if re.match(pat2, sh):
            ret = 'Yes'
        else:
            ret = 'No'
    else:
        ret = 'Yes'
    

print(ret)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=(int(x) for x in input().split())
S=input()
def Solve():
    if '##' in S[B-1:D] or '##' in S[A-1:C]:#道中に石が2つ並んでたらその時点でアウト
        return 'No'
    if C<D:
        return 'Yes'
    if '...' in S[B-1:D]:
        return 'Yes'
    if D!=N and S[D]=='.' or S[B-2]=='.':
        return 'Yes'
    else:
        return 'No'
    

print(Solve())

Submission status: Wrong Answer

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

stoneflag = 0
clearflag = 0
if b < c:
    for i in range(n - 1):
        if i >= min(a - 1,b - 1) and i <= max(c - 1,d - 1):
            if s[i] == '#' and s[i + 1] == '#':
                stoneflag = 1
            elif i > b - 1 and i < d - 1 and i <= n - 3:
                if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
                    clearflag = 1
else:
    for i in range(n - 1):
        if i > a - 1 and i < c - 1:
            if s[i] == '#' and s[i + 1] == '#':
                stoneflag = 1
        if i > b - 1 and i < d - 1:
            if s[i] == '#' and s[i + 1] == '#':
                stoneflag = 1

if stoneflag == 1:
    print('No')
elif c < d:
    print('Yes')
elif c > d and clearflag == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def SI(): return input()

N,A,B,C,D=LI()
st=input()

if C < D:
    if st[A:C].find('##') >= 0 or st[B:D].find('##') >= 0:
        print('No')
    else:
        print('Yes')
else:
    # Cの方がおおきいケース 入れ替わる
    if st[A:C].find('##') >= 0:
        print('No')
    else:
        lft = 0
        for i in reversed(range(1, A)):
            if st[i] == '#' and st[i-1] == '#':
                lft = i+1
                break
        rgt = st.find('##', C)

        aru = st[lft:rgt].find('...')
        print("lft{} rgt{} aru{}".format(lft, rgt, aru))
        if aru == -1:
            print('No')
        else:
            print('Yes')

Submission status: Wrong Answer

Solution code:
a=input().split()
b=input()

ans = 0
re = 0
if int(a[3])>int(a[4]):
	re = 1

p = 0
rock = 0
dot = 0
rock_ver = 0
re_ok = 0
for i in range(int(a[0])):
	if i + 1 == int(a[1]):
		p = 1
	b_i = b[int(i)]
	if b_i == "#":
		if rock == 1:
			ans = 1
			break
		if rock_ver == 0:
			rock_ver = 1
		rock = 1
		dot = 0
	else:
		rock = 0
		if p == 1:
			dot += 1
			if rock_ver == 0:
				if dot >=2:
					re_ok = 1
					break
			elif dot >= 3:
				re_ok = 1
				break

if re == 1:
	if re_ok == 0:
		ans = 1

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
obs = [S[i] is "#" and S[i+1] is "#" for i in range(min(A,B),max(C,D)-1)]
space = [S[i] is "." and S[i+1] is "." and S[i+2] is "." for i in range(min(A,B),max(C,D)-2)]
if C < D:
  if True in obs[B:D-1] or True in obs[A:C-1]:
    print("No")
  else:
    print("Yes")
else:
  if not True in space[B-1:D+1]:
    print("No")
  elif True in obs[B:D-1] or True in obs[A:C-1]:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


def inpl():
    return list(map(int, input().split()))


N, A, B, C, D = inpl()
S = "#" + input() + "#"
section = [-1 for i in range(N + 2)]
ischange = defaultdict(lambda: False)
interval = defaultdict(lambda: [-1, -1])
sec_num = 0

flag = True
for i, s in enumerate(zip(S, S[1:])):
    if s == ("#", "#"):
        sec_num += 1
        section[i] = -1
        section[i + 1] = -1
        flag = True
    else:
        section[i] = sec_num
        section[i + 1] = sec_num
        if flag is True:
            interval[sec_num][0] = sec_num
            flag = False
        else:
            interval[sec_num][1] = sec_num + 1
    if i < N and S[i] + S[i + 1] + S[i + 2] == "...":
        ischange[sec_num] = True

if section[A] != section[C] or section[B] != section[D]:
    print("No")
elif section[A] != section[B]:
    print("Yes")
elif C < D:
    print("Yes")
elif ischange[section[A]] is True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def check(b,d,path):
    seq = False
    for s in path[b:d]:
        if s == '#':
            if seq:
                return False
            else:
                seq = True
        else:
            seq = False  

    return True  


n,a,b,c,d = map( int, input().split() ) 
npath = input()
path = []
for s in npath:
    path.append(s)

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


ans = True
if c < d:
    ans = check(b,d,path) and check(a,c,path)
else:
    triple = 0
    for s in path[b-1:c+2]:
        if triple == 3:
            break
        if s == '#':
            triple = 0
        else:
            triple += 1

    if triple == 3:
        ans = check(a,d,path) and check(b,c,path)
    else:
        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())

# 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 = B - 1
    T = S.copy()
    while D - 1 != i:
        if T[i + 1] == ".":
            i += 1
        elif T[i + 2] == ".":
            i += 2
        else:
            break
    if i == D - 1:
        T2 = S.copy()
        j = A - 1
        while C - 1 != j:
            if T[j + 1] == ".":
                j += 1
            elif T[j + 2] == ".":
                j += 2
            else:
                break
        if j == C - 1:
            print("Yes")
            exit()
print("No")

Submission status: Wrong Answer

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

#N,A,B,C,D = 15,1,3,15,13
#S = "...#.#...#.#..."

#N,A,B,C,D = 4,1,2,4,3
#S = "...."

S = "#" + S + "#"
N = N+2

M = max(C,D)

if "##" in S[A:M+1]:
	print('No')
	exit()
if C < D:
	print('Yes')
	exit()

pos = B
while(True):
	if pos == D:
		if S[pos+1] == "#" or S[pos-1] == "#":
			print("No")
			exit()
		else:
			print("Yes")
			exit()
	if pos == D-1:
		if S[pos+2] == "#":
			print("No")
			exit()
		else:
			print("Yes")
			exit()
	loc = S[pos+1:pos+3]
	if loc == "..":
		print('Yes')
		exit()
	if loc == "#.":
		pos += 2
	if loc == ".#":
		pos += 3

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:
    for i in range(a, c-2):
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
            flag=1
    if flag == 0:
        ans=0
        
flag=0
if b<a and c<d:
    for i in range(b, d-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, raw_input().split())
S = raw_input()

if C < B:
    if S[A-1:C].find('##') < 0 and S[B-1:D].find('##') < 0: print 'Yes'
    else: print 'No'
elif C < D:
    if S[B-1:D].find('##') >= 0: print 'No'
    elif S[A-1:C].find('##') >= 0: print 'No'
    else:
        print 'Yes'
else:
    if S[B-1:D].find('##') >= 0: print 'No'
    else:
        if S[A-1:C].find('##') >= 0: print 'No'
        else:
            list_s = list(S)
            list_s[D-1] = '#'
            S = ''.join(list_s)
            if S[A-1:C].find('##') >= 0:
                if S[B-1:D].find('...') >= 0: 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()
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]=='#' or i==d:
            buf=max([span,buf])
            span=0
        elif 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:
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-1:c]:
    return 'No'
  if '##' in s[b-1:d]:
    return 'No'
  
  if d<c:
    if '...' not in s[a:c]:
      return 'No'

    if s[d-2:d+1]=='#.#':
      return 'No'

  return 'Yes'

print(main())