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 = [int(x) for x in input().split(' ')]
S = []
S.append(-1)
p = 0
err = False
for s in input():
  if s == '.':
    S.append(0)
    p = 0
  else:
    S.append(1)
    if p == 1:
      err = True
    
    p = 1
    
res = err
if err == False:
  if (S[A] == 0) and (S[B] == 0) and (S[C] == 0) or (S[D] == 0):
    if C > D:
      if S[D-1] == 0:
        res = True
      if S[B-1] == 0:
        res = True
    else:
      res = True
    
if res == True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(str(input()))
a, b, c, d = a-1, b-1, c-1, d-1
rng = []
chg = []
left = a
for i in range(max(a, 1), min(n-1, max(c, d))):
  if s[i] == s[i+1] == "#":
    rng.append([left, i-1])
    left = i + 1
  elif i == n-2:
    rng.append([left, i+1])
  if s[i-1] == s[i] == s[i+1] == ".":
    chg.append(i)
#print(rng)
check = 0
if c < d:
  for r in rng:
    if r[0] <= a:
      if c <= r[1]:
        check = 1
      break
  if check:
    check = 0
    for r in rng:
      if r[0] <= b <= r[1]:
        if d <= r[1]:
          check = 1
        break

else:
  for r in rng:
    if r[0] <= a:
      if c <= r[1]:
        check = 1
      break
  if check:
    check = 0
    for i in chg:
      if b <= i <= d:
        check = 1
        break


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

Submission status: Wrong Answer

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

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 == False):
    isCan = True
    front = a-1
    back = b-1
    tof = c-1
    tof = d-1
    
    for i in range(front,tof-2):
        if(Sn[i+1] == 1 and Sn[i+2]==1):
            isCan = False
            break

        if(i != 0 and 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()
ans = False

if '#' not in s:
    print('Yes')
elif '##' in s and  a < s.index('##') < c:
    print('No')
elif '##' in s and  b < s.index('##') < d:
    print('No')
elif c > d:
    if s[d - 1] == '#' or s[d - 1] == '#':
        print('No')
    else:
        print('Yes')
# if c > d:
#     if '...' in s and a < s.index('...') < c:
#         print('Yes')
#     else:
#         print('No')
# elif '#.#' in s and a < s.index('#.#') and s.index('#.#') < c and a < b and c > d:
#     print('No')
# elif '#.#' in s and b < s.index('#.#') and s.index('#.#') < d:
#     print('No')
# elif '#..#' in s and a < b and c > d:
#     print('No')
# elif '#..#' in s and a > b and c < d:
#     print('No')
elif '...' in s:
    print('Yes')
elif c < d:
    print('Yes')
else:
    print('No')

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, B, .]であればAは到達可能
    if '...' in S[A:D]:
        print('Yes')
        sys.exit()
    elif A + 1 == B and S[B] == '.':
        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 = 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("No")
  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:
N, A,B,C,D = map(int, input().split())
S = input()

'''
7 1 2 3 4
....

7 1 3 5 7
.#.#.#.#.#.#

'''
#print(S)
iwa_cnt = 0
kusa_cnt = 0
result ='No'
for s in S[A-1:max(C,D)-1]:
    #print(s)
    #print(iwa_cnt)
    #print(kusa_cnt)
    if s =='#':
        iwa_cnt +=1
        kusa_cnt = 0
    else:
        kusa_cnt +=1
        iwa_cnt =0
    if iwa_cnt == 2:
        result ='No'
        break
    if kusa_cnt == 1 and C < D:
        result = 'Yes'
    if kusa_cnt == 3:
        result = 'Yes'
print(result)



'''
Aの現在地からCまでに...が三つ続いていれば、
そこにCをおける
Cは##がない限り、さきに動かせばいいので、問題ない


'''
#print(N,M)
#print(target)
#print(P)

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] or True in obs[A:C]:
    print("No")
  else:
    print("Yes")
else:
  if True not in space[B-1:D]:
    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:
n, a, b, c, d = map(int, input().split())
s = input()
s_flag = False
can_flag = True
count = 0

for i in range(n):
  if s[i] == '#':
    count = 0
    if s_flag:
      s_flag = True
      can_flag = False
      break
    else:
      s_flag = False
  else:
    count += 1
if count > 0 and count <= 2:
  if c >= d:
    can_flag = False
if s[a-1] == '#' or s[b-1] == '#':
  can_flag = False
if can_flag:
  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"
e = max(c, d)
for i in range(a, e-1, 1):
    if s[i] == "#" and s[i+1] == "#":
        ans = "No"

if s[c-1] == "#" or s[d-1] == "#":
    ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = list(input())
S[A - 1] = 'A'
S[B - 1] = 'B'
a1 = 0
a2 = 0
ans = ''
if C > D:
    a1 = 'A'
    a2 = 'B'
    tmp1 = C - 1
    tmp2 = D - 1
    now1 = A - 1
    now2 = B - 1
else:
    a1 = 'B'
    a2 = 'A'
    tmp1 = D - 1
    tmp2 = C - 1
    now1 = B - 1
    now2 = A - 1

while True:
    if now1 != tmp1:
        if now1 + 2 <= len(S) - 1 and S[now1 + 2] == '.' and now1 + 2 <= tmp1:
            S[now1] = '.'
            S[now1 + 2] = a1
            now1 += 2
        elif now1 + 1 <= len(S) - 1 and S[now1 + 1] == '.' and now1 + 1 <= tmp1:
            S[now1] = '.'
            S[now1 + 1] = a1
            now1 += 1
        elif now2 + 2 <= len(S) - 1 and S[now2 + 2] == '.' and now2 + 2 <= tmp2:
            S[now2] = '.'
            S[now2 + 2] = a2
            now2 += 2
        elif now2 + 1 <= len(S) - 1 and S[now2 + 1] == '.' and now2 + 1 <= tmp2:
            S[now2] = '.'
            S[now2 + 1] = a2
            now2 += 1
        else:
            ans = 'No'
            break
    elif now2 != tmp2:
        if now2 + 2 <= len(S) - 1 and S[now2 + 2] == '.' and now2 + 2 <= tmp2:
            S[now2] = '.'
            S[now2 + 2] = a2
            now2 += 2
        elif now2 + 1 <= len(S) - 1 and S[now2 + 1] == '.' and now2 + 1 <= tmp2:
            S[now2] = '.'
            S[now2 + 1] = a2
            now2 += 1
        else:
            ans = 'No'
            break
    else:
        ans = 'Yes'
        break

print(ans)

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

# stoneCnt=S.count("#")

# if stoneCnt == 0:
# 	print("Yes")
# 	exit(0)


curStoneLen=0

# 先にBがいけるか考える
# いけなければOUT
for b in range(B-1,D):
	if S[b] == ".":
		curStoneLen = 0
	else:
		curStoneLen += 1

	if 2 == curStoneLen:
		print("No")
		exit(0)



maxAtoDSeqSpaceLen=0
curSeqSpaceLen=0


curStoneLen=0

for a in range(A-1,C):
	if S[a] == ".":
		curStoneLen = 0
		curSeqSpaceLen += 1
	else:
		curStoneLen += 1
		curSeqSpaceLen = 0

	if a < D:
		maxAtoDSeqSpaceLen=max(maxAtoDSeqSpaceLen,curSeqSpaceLen)

	if 2 == curStoneLen:
		print("No")
		exit(0)

# print(maxAtoDSeqSpaceLen)

if D < C and maxAtoDSeqSpaceLen < 3:
	# AはBをかわさないといけないのに、Dまでにはかわすスペースが無い
	if S[D-2]=="." and S[D] == ".":
		# Dまでには無いが、Dの周りにかわすスペース有
		pass
	else: 
		print("No")
		exit(0)	
else:
	# その他の場合は、Bを無視して良い
	pass


print("Yes")

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

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


print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
rr = lambda: sys.stdin.readline().strip()
rri = lambda: int(rr())
rrs = lambda: [int(_) for _ in rr().split()]

N, A_, B_, C_, D_ = rrs()
A, B, C, D = [i-1 for i in [A_, B_, C_, D_]]
S = rr()

for i in range(1, N):
	if S[i] == '#' and S[i-1] == '#':
		print('No')
		sys.exit()

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

if S[B-1] == '.' and S[B+1] == '.':
	print('Yes')
	sys.exit()

if S[D-1] == '.' and S[D+1] == '.':
	print('Yes')
	sys.exit()

for i in range(B, N-3):
	if S[i] == '#':
		if S[i+1] == '.' and S[i+2] == '.' and S[i+3] == '.':
			print('Yes')
			sys.exit()

print('No')
sys.exit()

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("No")
    else:
      print("Yes")

Submission status: Wrong Answer

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

rock = "#"
S = list()
three_empty = []
two_rocks = []
rock_cnt, empty_cnt = 0, 0

# 通れない２連続岩の場所とABが交差できる３emptyの場所取得
for i, s in enumerate(input().strip(), start=1):
  is_rock = s == rock
  if is_rock:
    if empty_cnt >= 3:
      three_empty.append(i - 1)
    rock_cnt += 1
    empty_cnt = 0
  else:
    if rock_cnt >= 3:
      two_rocks.append(i - 1)
    rock_cnt = 0
    empty_cnt += 1
if rock_cnt >= 3:
  two_rocks.append(i)
if empty_cnt >= 3:
  three_empty.append(i)

flag = True
left = A if A < B else B
right = B if A > B else A
left_rock = 0
right_rock = 200001


for i in two_rocks:
  # 目標の間に岩があるか確認
  if A > i > C or B > i > D:
    flag = False
    break
  # 左と右にいる人から一番近い岩の位置
  if i < left:
    left_rock = i
  elif right_rock != 200001 and right < i:
    right_rock = i

if not flag:
  # 目標との間に2岩があるとき
  print("No")
elif (A > B and C > D) or (A < B and C < D):
  # 木彫との間に2岩がなく、交差が発生しない場合。
  print("Yes")
elif not three_empty:
  # 交差点となる3emptyがない場合
  print("No")
else:
  # 双方の一番近い岩との間に3emptyがあるかどうか 
  for i in three_empty:
    if left_rock < i < right_rock:
      flag = True
      break
  if flag:
    print("Yes")
  else:
    print("No")

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) - 2:]
lo = li[:lg]
ret = ''
# print(sh)
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 = list(map(int, input().split()))
S = list(input())
A = A-1
B = B-1
C = C-1
D = D-1
S[A] = 'a'
S[B] = 'b'
a = A
b = B
flag = False
if A > B:
    B, A = (A, B)
    D, C = (C, D)

if B > A and D > C:
    for i in range(N):
        if b == D:
            flag = True
            break
        if S[b+1]=='.':
            S[b+1] = 'b'
            S[b] = '.'
            b += 1
        elif S[b+2]=='.':
            S[b+2] = 'b'
            S[b] = '.'
            b += 2

elif B > A and C > D:
    for i in range(N):
        if b > 1 and b+1 < N:
            if S[b-1] == '.' and S[b+1] == '.':
                flag = True
                break
        if b + 1 < N:
            if S[b+1] == '.':
                S[b+1] = 'b'
                S[b] = '.'
                b += 1
            elif b + 2 < N:
                if S[b+2] == '.':
                    S[b+2] = 'b'
                    S[b] = '.'
                    b += 2
                

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

Submission status: Wrong Answer

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

l = min(A,B)-1
R = max(C,D)-1
if C < B:
    L = max(A,B)-1
    r = min(C,D)-1
    if S[l:r].find("##") == -1 and S[L:R].find("##") == -1:
        print("Yes")
    else:
        print("No")
elif D - C > 0:
    if S[l:R].find("##") >= 0:
        print("No")
    else:
        print("Yes")
else:
    r = min(C,D)-1
    if S[l:R].find("##") == -1 and S[l:r+2].find("...") >= 0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

    
ans="Yes"
for i in range(a,max(c,d)-1):
  if s[i-1]=="#" and s[i]=="#":
    ans="No"

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

Submission status: Wrong Answer

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

flag3 = 0
flagno = 0

if c > d:

    for i in range(a,c):

        if s[i:i+2] == "##":
            flagno += 1
            break

    if flagno == 0:

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

    else:
        print("No")

else:

    for i in range(a,d):

        if s[i:i+2] == "##":
            flagno += 1
            break
    
    if flagno == 0:
        print("Yes")

    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys

def PNO():
    print("No")
    sys.exit(0)

def PYES():
    print("Yes")
    sys.exit(0)



n, a, b, c, d = list(map(int, input().split()))
s = str(input())
a -= 1
b -= 1
c -= 1
d -= 1

ac = str(s[a:c])
if (ac.find("##") != -1):
    PNO()

bd = str(s[b:d])
if (bd.find("##") != -1):
    PNO()

if (c > d):
    bdd = str(s[b:d+2])
    if (bdd.find("...") == -1):
        PNO()

PYES()

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
dot = []
sharp = []
A_clear = True
B_clear = True

if C<D:
    # print(S[B-1:D])
    tmp_s = 0
    for s in S[B-1:D]:
        if s == '#' and tmp_s>0 :
            B_clear = False
            break
        elif s == '#':
            tmp_s += 1
        else:
            tmp_s = 0

    tmp_s = 0
    for s in S[A-1:C]:
        if s == '#' and tmp_s>0 :
            A_clear = False
            break
        elif s == '#':
            tmp_s += 1
        else: 
            tmp_s = 0
    if A_clear == True and B_clear == True:
        print('Yes')
    else:
        print('No')
    
elif D<C:
    # B
    tmp_s = 0
    for s in S[B-1:D]:
        if s == '#' and tmp_s>0 :
            B_clear = False
            break
        elif s == '#':
            tmp_s += 1
        else:
            tmp_s = 0
    # A
    tmp_s = 0
    tmp_d = 0
    A_clear = False
    for s in S[A-1:C]:
        if s == '.' and tmp_d>=2 :
            A_clear = True
        elif s == '#' and tmp_d>0:
            tmp_s += 1
            tmp_d = 0
        elif s == '.' and tmp_s>=0:
            tmp_d += 1
            tmp_s = 0
        elif s == '#' and tmp_d>=0 :
            A_clear = False
            break
    if A_clear == True and B_clear == True:
        print('Yes')
    else:  
        print('No')

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
ans = False
if C < B:
    # A ~ C に行けるか
    # B ~ D に行けるか
    count_x = 0
    ans = True
    for i in range(A, C):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_x = 0
        for i in range(B, D):
            if S[i] == "#":
                count_x += 1
            else:
                count_x = 0
            if count_x > 1:
                ans = False
                break
elif C < D:
    # B ~ D に行けるか
    # A ~ C に行けるか
    count_x = 0
    ans = True
    for i in range(A, D):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
else:
    # A ~ Cに行けるか
    # AがBを超えれるか
    # (B~Dに3つ以上の連続空きがある)
    count_x = 0
    ans = True
    for i in range(A, C):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_o = 0
        ans = False
        for i in range(B, D+1):
            if S[i] == "#":
                count_o = 0
            else:
                count_o += 1
            if count_o > 2:
                ans = True
                break
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 "##" in s[min(a,b)-1:max(c,d)]:
  print("No")
else:
  if c<d:
    print("Yes")
  else:
    if "..." in s[a-1:d]:
      print("Yes")
    else:
      print("No")

Submission status: Wrong Answer

Solution code:
## AからＣ　ＢからＤに移動させたい
## C<D なら簡単

N,A,B,C,D = map(int,input().split())
S = input()
flag = 0
obs = []
esc = []
ans = 1

#ＡとＢで小さいほうを low
if A<B:
    low = A
    mid1 = B
else:
    low = B
    mid1 = A
#ＣとＤで大きいほうをhigh
if C<D:
    high = D
    mid2 = C
else:
    high = C
    mid2 = D



for i in range(low,high):
     if S[i]=="#" and flag == 1:
         obs.append(i)
         flag = 0
     elif S[i] == "#":
         flag = 1
     else: flag = 0

 # obsに通れない位置を入力
flag = 0
for i in range(low,high):
      if S[i]=="." and flag == 2:
          esc.append(i)
          flag = 0
      elif S[i] == ".":
          flag += 1
      else:
          flag = 0

if len(obs)!=0:
    ans = 0

if D<C :
    flag = 0
    for i in range(len(esc)):
        if mid1<esc[i] <= mid2:
            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())
A -= 1
B -= 1
C -= 1
D -= 1
S = list(input())
if (A < B < D < C):
    cnt = 0
    cntl = [0]
    for i in range(A+1,C):
        if (S[i] == '.') & (S[i+1] == '.'):
            cnt += 1
            if i == C-1:
                cntl.append(cnt)
        elif (S[i] == '.') & (S[i+1] == '#'):
            cntl.append(cnt)
            cnt = 0
    if max(cntl) < 2:
        print('No')
    else:
        cnt = 0
        cntL = [0]
        for i in range(B+1,D-1):
            if (S[i] == '#') & (S[i+1] == '#'):
                cnt += 1
                if i == C-1:
                    cntL.append(cnt)
            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 = [0]
                for i in range(B-1,D-2):
                    if (S[i] == '.') & (S[i+1] == '.'):
                        x += 1
                        if i == D-3:
                            xl.append(x)
                    elif (S[i] == '.') & (S[i+1] == '#'):
                        xl.append(x)
                if max(xl) >= 2:
                    print('Yes')
                else:
                    print('No')
            else:
                x = 0
                xl = [0]
                for i in range(B-1,D-1):
                    if (S[i] == '.') & (S[i+1] == '.'):
                        x += 1
                        if x == D-2:
                            xl.append(x)
                    elif (S[i] == '.') & (S[i+1] == '#'):
                        xl.append(x)
                if max(xl) >= 2:
                    print('Yes')
                else:
                    print('No')
else:
    cnt = 0
    cntl = [0]
    for i in range(A+1,C):
        if (S[i] == '#') & (S[i+1] == '#'):
            cnt += 1
            if i == C-1:
                cntl.append(cnt)
        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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

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

    # A,Bからみて先が"##"の状態になったら詰み
    if "##" not in S[A:] or "##" not in S[B:]:
        if C < D:
            # 先にBをDまで移動させればAもたどり着ける
            print("Yes")
        else:
            # AがBを追い抜く必要があるので、
            # その瞬間に#B or B#にならないようにしないといけない
            # BからD+1の間に ... があればOK
            if "..." in S[B:D+2]:
                print("Yes")
            else:
                print("No")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: int, B: int, C: int, D: int, S: str): 
    if(S[C-1] == '#' or S[D-1]== '#'):
        print(NO)
        sys.exit()

    if(C < D):
        if(S[A-1:C].count('##') == 0 and S[B-1:D].count('##') == 0):
            print(YES)
    elif(C > D):
            if(S[B-1:D].count('...') == 0):
                print(NO)
            else:
                print(YES)
            # else:
            #     st = ''.join(list(S[:D]))
            #     # st = list(S)
            #     # st[B-1] = '#'
            #     # print(''.join(st[B-1:D]))
            #     if(st.rfind('...')+2 == B and st[D-2] == '#'):
            #         print(NO)
            #     else:
            #         print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
print('No')

Submission status: Wrong Answer

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

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, d):
        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:
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("Yes")
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:
n, a, b, c, d = map(int, input().split())

s = input()

flagA = True
flagB = True

for i in range(d - b - 1):
    if s[b + i] == "#" and s[b + i + 1] == "#":
        flagB = False

for i in range(c - a - 1):
    if ((s[a + i] == "#") or (a + i == d - 1)) and ((s[a + i + 1] == "#") or (a + i + 1 == d - 1)):
        flagA = False
        if d < c:
            for j in range(c - a - 2):
                if (s[a + j] == "." and s[a + j + 1] == "." and s[a + j + 2] == "."):
                    flagA = True

if flagA and flagB:
    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[min(a,b)-1:max(c,d)]:
  print("No")
else:
  if c<d:
    print("Yes")
  else:
    if "..." in s[a-1:d+2]:
      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]:
    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 heapq import heappush, heappop
import re
from collections import deque
import sys
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_invs(n, mod=DIV):
    inv = [0]*(n+1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, n+1):
        inv[i] = (-(mod//i)*inv[mod % i]) % mod
    return inv


N,A,B,C,D = ints_raw()
S = input()
#N = int_raw()


def main():
    ans = 0
    if D==C:
        return "No"
    if S[D-1]=="#" or S[C-1]=="#":
        return "No"
    if "##" in S[A:max(B, D)]:
        return "No"
    if D>C:
        return "Yes"
    else:
        if "..." in S[B-2:min(max(D+1,N),C)]:
            #print (S[B-2:min(max(D+1, N), C)])
            return "Yes"
        return "No" 
    return ans


print(main())