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:
#Python標準入出力

import numpy as np

# 1行に複数の文字列（数字）を取得，整数に直す
# 今回は2つ受け取って，足し算する

# 0 len root 1 sunuke 2 funuke 3 point1 4 point2 funuke
Masu = list(map(int, input().split()))
Root = input()

N = Masu[0]
A = Masu[1]
B = Masu[2]
C = Masu[3]
D = Masu[4]

S = Root

At = A-1
Bt = B-1
Ct = C-1
Dt = D-1

Judge = True

#Answer 1 パターン入れ込み

# Rock = []
# for i in range(Masu[0]):
#     if Root[i] == "#":
#         Rock.append(i+1)


threePoints = True

for k in range(N):
    if k < 1:
        gg = 0
    elif S[k] == "." and S[k-1] == "." and S[k-2] == ".":
        # print("roop{}".format(k))
        if Dt+1 > k > Bt:
            threePoints = False

# print(threePoints)

for j in range(Masu[0]):
    if S[j] == "#" and S[j-1] == "#":
        Judge = False

    if C == j+1 and D == j+1-1 and Root[j-2] == "#" and threePoints:
        Judge = False
    if C == j+1 and Root[j-1] == "#" and D == j+1-2 and threePoints:
        Judge = False

    # if Masu[3] == j+1:
    #     for p in range(j):
    #         if Masu[4] == p+1 and Root[p-1] == "#":
    #             Judge = False

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









#Answer 2 動かし

# Sunuke = At
# Funuke = Bt
# throuth = 0
#
#
# if C < D:
#     for i in range(N-Funuke):
#
#         ii = i+Bt
#
#         # print("current {0}: funuke: {1}".format(ii,Funuke))
#         if Funuke == Dt:
#             break
#
#         elif S[ii] == "#" and S[ii+1] == "#":
#             Judge = False
#             break
#
#         elif S[ii] == "#":
#             throuth = 0
#
#         elif S[ii+1] == ".":
#             Funuke = Funuke+1
#
#         elif S[ii+1] == "#":
#             Funuke = Funuke+2
#
#     #
#     # print("Funuke: {}".format(Funuke))
#     # print("Sunuke: {}".format(Sunuke))
#     # print(At)
#     if Judge:
#         for j in range(N-Sunuke):
#
#             jj = j+At
#             # print("current {0}: Sunuke: {1}".format(jj, Sunuke))
#
#             if Sunuke == Ct:
#                 break
#
#             elif S[jj] == "#" and jj + 1 == Funuke:
#                 Judge = False
#                 break
#
#             elif S[jj] == "#":
#                 throuth = 0
#
#             elif S[jj + 1] == ".":
#                 Sunuke = Sunuke + 1
#
#             elif S[jj + 1] == "#" or jj+1 == Funuke:
#                 Sunuke = Sunuke + 2
#
#     #
#     # print(Sunuke)
#     # print(Funuke)
#     #
#
# else:
#     Rock = []
#     for i in range(Masu[0]):
#         if Root[i] == "#":
#             Rock.append(i + 1)
#
#     threePoints = False
#
#     for k in range(N):
#         if k < 1:
#             gg = 0
#         elif S[k] == "." and S[k - 1] == "." and S[k - 2] == ".":
#             # print("roop{}".format(k))
#             if D+1 > k:
#                 threePoints = True
#
#     # print(threePoints)
#
#     for j in range(Masu[0]):
#         if S[j] == "#" and S[j - 1] == "#":
#             Judge = False
#
#         if C == j + 1 and D == j + 1 - 1 and Root[j - 2] == "#" and (not threePoints):
#             Judge = False
#         if C == j + 1 and Root[j - 1] == "#" and D == j + 1 - 2 and (not threePoints):
#             Judge = False
#
#             # if Masu[3] == j+1:
#             #     for p in range(j):
#             #         if Masu[4] == p+1 and Root[p-1] == "#":
#             #             Judge = False
#
# if Judge:
#     print("Yes")
# else:
#     print("No")

Submission status: Wrong Answer

Solution code:
## 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:
         ans = 0
         flag = 0
     elif S[i] == "#":
         flag = 1
     else: flag = 0

 # obsに通れない位置を入力
flag = 0
flag2 = 1
if D<C:
    flag2 = 0
    for i in range(B,D):
          if S[i]=="." and flag == 2:
              flag2 = 1
              flag = 0
          elif S[i] == ".":
              flag += 1
          else:
              flag = 0
if flag2 ==0:
    ans = 0


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

Submission status: Wrong Answer

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

t2 = "##" in s
u3 = "..." in s

if c == d:
    print("No")
elif c < d:
    print("Yes" if not t2 else "No")
else:
    print("Yes" if u3 else "No")

Submission status: Wrong Answer

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

two_sharp = False
three_point = False
n = len(S)
for j in range(n-2):
  if S[j] == '.' and S[j+1] == '.' and S[j+2] == '.':
    three_point = True

  if S[j] == '#' and S[j+1] == '#':
    two_sharp = True

if two_sharp:
  print 'No'
elif D > C:
  print 'Yes'
elif C > D:
  if three_point:
    print 'Yes'
  else:
    print 'No'

Submission status: Wrong Answer

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


if a > b:
    a, b, c, d = b, a, d, c


def search(start, goal):
    for i in range(start, goal - 2):
        if s[i] + s[i + 1] == '##':
            return False
    return True


def search3(start, goal):
    for i in range(start, goal - 3):
        if s[i] + s[i + 1]+s[i+2] == '...':
            return True
    return False


if c < d:
    if not '##'in s[a:c] and not '##'in s[b:d]:
        print('Yes')
    else:
        print('No')

else:
    if '...'in s[b-1:d+2]and not '##'in s[a:c]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
x = input().split()
s = input()
n = int(x[0])
a = int(x[1])
b = int(x[2])
c = int(x[3])
d = int(x[4])
 
 
kome_flag = False
santen_flag = False
 
a_s = s[a-1:c]
b_s = s[b-1:d]
 
if c < d:
  santen_flag = True
if d < c:
  if '...' in s[b-1:d]:
    santen_flag = True
  
if not '##' in a_s and not '##' in b_s:
  kome_flag = True
    
if not '#' in a_s and not '#' in b_s:
	print('Yes')
    
else:
	if c < d:
		if kome_flag:
			print('Yes')
		else:
			print('No')
 
	if d < c:
		if kome_flag and santen_flag:
			print('Yes')
		else:
			print('No')

Submission status: Wrong Answer

Solution code:
import sys

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

S = input()

# ゴールまでに#の連続があるか
for i in range(A,max(C,D)):
    if S[i:i+2]  == '##':
        print('No')
        sys.exit()

# 追い越す必要がある場合
if C > D:
    for i in range(B,D):
        if S[i-1:i+2] == '...':
            print('Yes')
            sys.exit()
    else:
        print('No')
        sys.exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
#Python標準入出力

import numpy as np

# 1行に複数の文字列（数字）を取得，整数に直す
# 今回は2つ受け取って，足し算する

# 0 len root 1 sunuke 2 funuke 3 point1 4 point2 funuke
Masu = list(map(int, input().split()))
Root = input()

N = Masu[0]
A = Masu[1]
B = Masu[2]
C = Masu[3]
D = Masu[4]

S = Root

At = A-1
Bt = B-1
Ct = C-1
Dt = D-1

Judge = True

#Answer 1 パターン入れ込み

# Rock = []
# for i in range(Masu[0]):
#     if Root[i] == "#":
#         Rock.append(i+1)


threePoints = True

for k in range(N):
    if k < 1:
        gg = 0
    elif S[k] == "." and S[k-1] == "." and S[k-2] == ".":
        # print("roop{}".format(k))
        if D+1 > k > B:
            threePoints = False

# print(threePoints)

for j in range(Masu[0]):
    if S[j] == "#" and S[j-1] == "#":
        Judge = False

    if C == j+1 and D == j+1-1 and Root[j-2] == "#" and threePoints:
        Judge = False
    if C == j+1 and Root[j-1] == "#" and D == j+1-2 and threePoints:
        Judge = False

    # if Masu[3] == j+1:
    #     for p in range(j):
    #         if Masu[4] == p+1 and Root[p-1] == "#":
    #             Judge = False

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









#Answer 2 動かし

# Sunuke = At
# Funuke = Bt
# throuth = 0
#
#
# if C < D:
#     for i in range(N-Funuke):
#
#         ii = i+Bt
#
#         # print("current {0}: funuke: {1}".format(ii,Funuke))
#         if Funuke == Dt:
#             break
#
#         elif S[ii] == "#" and S[ii+1] == "#":
#             Judge = False
#             break
#
#         elif S[ii] == "#":
#             throuth = 0
#
#         elif S[ii+1] == ".":
#             Funuke = Funuke+1
#
#         elif S[ii+1] == "#":
#             Funuke = Funuke+2
#
#     #
#     # print("Funuke: {}".format(Funuke))
#     # print("Sunuke: {}".format(Sunuke))
#     # print(At)
#     if Judge:
#         for j in range(N-Sunuke):
#
#             jj = j+At
#             # print("current {0}: Sunuke: {1}".format(jj, Sunuke))
#
#             if Sunuke == Ct:
#                 break
#
#             elif S[jj] == "#" and jj + 1 == Funuke:
#                 Judge = False
#                 break
#
#             elif S[jj] == "#":
#                 throuth = 0
#
#             elif S[jj + 1] == ".":
#                 Sunuke = Sunuke + 1
#
#             elif S[jj + 1] == "#" or jj+1 == Funuke:
#                 Sunuke = Sunuke + 2
#
#     #
#     # print(Sunuke)
#     # print(Funuke)
#     #
#
# else:
#     Rock = []
#     for i in range(Masu[0]):
#         if Root[i] == "#":
#             Rock.append(i + 1)
#
#     threePoints = False
#
#     for k in range(N):
#         if k < 1:
#             gg = 0
#         elif S[k] == "." and S[k - 1] == "." and S[k - 2] == ".":
#             # print("roop{}".format(k))
#             if D+1 > k:
#                 threePoints = True
#
#     # print(threePoints)
#
#     for j in range(Masu[0]):
#         if S[j] == "#" and S[j - 1] == "#":
#             Judge = False
#
#         if C == j + 1 and D == j + 1 - 1 and Root[j - 2] == "#" and (not threePoints):
#             Judge = False
#         if C == j + 1 and Root[j - 1] == "#" and D == j + 1 - 2 and (not threePoints):
#             Judge = False
#
#             # if Masu[3] == j+1:
#             #     for p in range(j):
#             #         if Masu[4] == p+1 and Root[p-1] == "#":
#             #             Judge = False
#
# if Judge:
#     print("Yes")
# else:
#     print("No")

Submission status: Wrong Answer

Solution code:
"""
B,"s/BC/X"したうえで、
置換できないB,Cで区切って、(re.finditer(r"[AX+"])
各区間でAをすべて右側に寄せるAの移動回数の和 例: AXAXAXA -> XXXAAAA にするには6回
"""
import re
s = input()
s = s.replace("BC", "X")
m = re.search(r"[AX]+", s)
res = 0
for m in re.finditer(r"([AX]+)", s): # それぞれの[AX]+のパターンについてloop
    count = 0 #
    # 時間なくて、index間違えたくないので、逆順にした
    # (AXAXAXA -> XXXAAAA にするんじゃなくて AXAXAXA -> AAAAXXXにする回数)
    t = ''.join(list(reversed(str(m.groups()[0]))))
    for i in range(len(t)):
        if t[i] == "A":
            # Aが見つかったらXの一番右端に持ってくるのに必要な回数をカウント。例えば、
            # AAAXXXAA で4つめのAを探索しているのなら
            # AAAAXXXA にするのに必要な回数は3 と数えたい
            # Aのindex 6 - (既に見つかっているAの数) 3 = 3 で求められる
            res += (i - count)
            count += 1
print(res)

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = list(map (int, input().split()))
s = input ()
s = '#' + s
 
ans = True
 
if '##' in s[a:max(c,d)+1]:
    ans = False
else:
    if d < c:
        ans = False
        if '...' in s[b-1:d+1]:
            ans = True
        
 
if ans is True:
    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 = input()

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun  2 22:01:55 2019

@author: hisaki
"""

import sys
N, A, B, C, D = map(int, input().split())
S = input()
A_start = A -1
B_start = B -1
A_goal = C -1
B_goal = D -1

A_pos = A_start
B_pos = B_start

flag = True
for i in range(A_pos, A_goal):
    if S[i] == '#':
        if S[i+1] == '#':
            flag = False

for i in range(B_pos, B_goal):
    if S[i] == '#':
        if S[i+1] == '#':
            flag = False
            
if flag == False:
    print ("No")
    sys.exit()
  


if A_goal < B_goal:
    print ("Yes")
    sys.exit()


if B_goal < A_goal :
    for i in range(B_pos , B_goal):
        if (S[i-1] == '.' or i-1 == A_pos) and (S[i]== '.') and (S[i+1] == '.'):
            print ("Yes")
            sys.exit()

            
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
check = 1
if c < d:
  for i in range(a,c):
    if s[i] == s[i+1] == "#":
      check = 0
      break
  if check:
    for i in range(b,d):
      if s[i] == s[i+1] == "#":
        check = 0
        break

else:
  for i in range(a,c):
    if s[i] == s[i+1] == "#":
      check = 0
      break
  if check:
    check = 0
    for i in range(b, d-1):
      if s[i] == s[i+1] == s[i+2] == ".":
        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 = input()

def max_stone(a, b):
  m = 0
  for j in range(a, b-1):
    if S[j] == S[j+1] == '#':
      return False
  
  return True
  
def reachable(b, d):
  n_sharp = 0
  n_dot = 0
  for j in range(b-1, d+1):
    s = S[j]
    if s=='.':
      n_dot += 1
      n_sharp = 0
    else:
      n_sharp += 1
      n_dot = 0
      
    if n_dot == 3:
      return True
    elif n_sharp == 2:
      return False
    
  return False
  
if C < B:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C < D:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C > D:
  if reachable(B-1, D-1) and max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
x = input().split()
s = input()
n = int(x[0])
a = int(x[1])
b = int(x[2])
c = int(x[3])
d = int(x[4])
 
 
kome_flag = False
santen_flag = False
 
a_s = s[a:c]
b_s = s[b:d]
 
if c < d:
  santen_flag = True
if d < c:
  if '...' in s[b-1:d]:
    santen_flag = True
  
if not '##' in a_s and not '##' in b_s:
  kome_flag = True
    
if not '#' in a_s and not '#' in b_s:
	print('Yes')
else:
	if c < d:
		if kome_flag:
			print('Yes')
		else:
			print('No')
 
	if d < c:
		if kome_flag and santen_flag:
			print('Yes')
		else:
			print('No')

Submission status: Wrong Answer

Solution code:
import sys

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

S = input()

# ゴールまでに#の連続があるか
for i in range(A,max(C,D)):
    if S[i:i+2]  == '##':
        print('No')
        sys.exit()

# 追い越す必要がある場合
if C > D:
    for i in range(B,D):
        if S[i:i+3] == '...':
            print('Yes')
            sys.exit()
    else:
        print('No')
        sys.exit()

print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[43]:


N, A, B, C, D = map(int, input().split())
S = input()
"""
7 1 3 7 6
.#..#..
"""


# In[55]:


if '##' in S[A-1:C] or '##' in S[B-1:D]:
    print('No')
else:# A~C B~D間に##は無い
    if C<D: # ACBD or ABCD
        print('Yes')
    else: # ABDC
        if '...' in S[B-2:C+1]:
            print('Yes')
        else:
            print('No')

"""
if C<D: # C < D のとき、A~C、B~Dに#が2連続じゃなければYes
    shc = 0
    for s in S[A-1:C]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
        if s == '.':
            shc = 0
    shc = 0
    for s in S[B-1:D]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
        if s == '.':
            shc = 0
elif C>D: # C > Dのとき、順番入れ替えが必要, dotが3個以上並べば、入れ替えられる
    #print(1)
    shc = 0
    dc = 0
    mdc = 0
    for i, s in enumerate(S[A-1:C]): # A~Cで　#が二個以上あればアウト
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
            if dc>0:
                mdc = max(dc, mdc)
                dc = 0
        if s == '.':
            dc += 1
            shc = 0
        if i >= C-A:
            mdc = max(dc, mdc)
    if mdc >= 3:
        #print(2)
        pass
    elif mdc < 3: # A~Cに dotが3個以上並んでいないとき、
        #print(2)
        shc = 0
        for i, s in enumerate(S[0:A:-1]):
            if shc >1:
                l = A-i+1
                break
            if s == '#':
                shc += 1
            if s == '.':
                shc = 0
            if i >= A-1 and shc > 1:
                l = A-i+2
        else:
            l = 0
            
        shc = 0
        for i, s in enumerate(S[C:]):
            if shc >1:
                r = C+i-2
                break
            if s == '#':
                shc += 1
            if s == '.':
                shc = 0
            if i >= N-C-1 and shc > 1:
                r = C+i-2
        else:
            r = N
        
        #print(l, r)
        mdc = 0
        dc = 0
        for i, s in enumerate(S[l:r]):
            #print('{}: {}'.format(i, dc))
            if s == '#':
                if dc>0:
                    mdc = max(dc, mdc)
                    dc = 0
            if s == '.':
                dc += 1
            if i >= r-l-1:
                mdc = max(dc, mdc)
        if mdc < 3:
            ans = 'No'
print(ans)
"""


# In[ ]:

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, input().split())
s = input()
index = [(n+1) for n, v in enumerate(s) if s[n:n+3] == "..."]

if s.count("##")>=1:
    print("No")
    exit()

if C < D:
    print("Yes")

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

Submission status: Wrong Answer

Solution code:
#Python標準入出力

import numpy as np

# 1行に複数の文字列（数字）を取得，整数に直す
# 今回は2つ受け取って，足し算する

# 0 len root 1 sunuke 2 funuke 3 point1 4 point2 funuke
Masu = list(map(int, input().split()))
Root = input()

N = Masu[0]
A = Masu[1]
B = Masu[2]
C = Masu[3]
D = Masu[4]

S = Root

At = A-1
Bt = B-1
Ct = C-1
Dt = D-1

Judge = True

#Answer 1 パターン入れ込み

# Rock = []
# for i in range(Masu[0]):
#     if Root[i] == "#":
#         Rock.append(i+1)


threePoints = False

for k in range(N):
    if k < 1:
        gg = 0
    elif S[k] == "." and S[k-1] == "." and S[k-2] == ".":
        # print("roop{}".format(k))
        if D+1 > k > B:
            threePoints = True

# print(threePoints)

for j in range(Masu[0]):
    if S[j] == "#" and S[j-1] == "#":
        Judge = False

    if C == j+1 and D == j+1-1 and Root[j-2] == "#" and (not threePoints):
        Judge = False
    if C == j+1 and Root[j-1] == "#" and D == j+1-2 and (not threePoints):
        Judge = False

    # if Masu[3] == j+1:
    #     for p in range(j):
    #         if Masu[4] == p+1 and Root[p-1] == "#":
    #             Judge = False

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









#Answer 2 動かし

# Sunuke = At
# Funuke = Bt
# throuth = 0
#
#
# if C < D:
#     for i in range(N-Funuke):
#
#         ii = i+Bt
#
#         # print("current {0}: funuke: {1}".format(ii,Funuke))
#         if Funuke == Dt:
#             break
#
#         elif S[ii] == "#" and S[ii+1] == "#":
#             Judge = False
#             break
#
#         elif S[ii] == "#":
#             throuth = 0
#
#         elif S[ii+1] == ".":
#             Funuke = Funuke+1
#
#         elif S[ii+1] == "#":
#             Funuke = Funuke+2
#
#     #
#     # print("Funuke: {}".format(Funuke))
#     # print("Sunuke: {}".format(Sunuke))
#     # print(At)
#     if Judge:
#         for j in range(N-Sunuke):
#
#             jj = j+At
#             # print("current {0}: Sunuke: {1}".format(jj, Sunuke))
#
#             if Sunuke == Ct:
#                 break
#
#             elif S[jj] == "#" and jj + 1 == Funuke:
#                 Judge = False
#                 break
#
#             elif S[jj] == "#":
#                 throuth = 0
#
#             elif S[jj + 1] == ".":
#                 Sunuke = Sunuke + 1
#
#             elif S[jj + 1] == "#" or jj+1 == Funuke:
#                 Sunuke = Sunuke + 2
#
#     #
#     # print(Sunuke)
#     # print(Funuke)
#     #
#
# else:
#     Rock = []
#     for i in range(Masu[0]):
#         if Root[i] == "#":
#             Rock.append(i + 1)
#
#     threePoints = False
#
#     for k in range(N):
#         if k < 1:
#             gg = 0
#         elif S[k] == "." and S[k - 1] == "." and S[k - 2] == ".":
#             # print("roop{}".format(k))
#             if D+1 > k:
#                 threePoints = True
#
#     # print(threePoints)
#
#     for j in range(Masu[0]):
#         if S[j] == "#" and S[j - 1] == "#":
#             Judge = False
#
#         if C == j + 1 and D == j + 1 - 1 and Root[j - 2] == "#" and (not threePoints):
#             Judge = False
#         if C == j + 1 and Root[j - 1] == "#" and D == j + 1 - 2 and (not threePoints):
#             Judge = False
#
#             # if Masu[3] == j+1:
#             #     for p in range(j):
#             #         if Masu[4] == p+1 and Root[p-1] == "#":
#             #             Judge = False
#
# if Judge:
#     print("Yes")
# else:
#     print("No")

Submission status: Wrong Answer

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

if a < c and c < b and b < d:
    for i in range(a, min(c, n-1)):
        if s[i] == s[i+1] and s[i] == "#":
            print("No")
            exit()
    print("Yes")
    exit()
elif a < b and b < c and c < d:
    for i in range(a, min(d, n-1)):
        if s[i] == s[i+1] and s[i] == "#":
            print("No")
            exit()
    print("Yes")
    exit()

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

Submission status: Wrong Answer

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

s_cnt = 0
max_s_cnt = 0
pre_s = ''

goal = max(C, D)

if C < B:
  for i in range(A-1, C):
    if pre_s == "#":
      if S[i] == "#":
        print("No")
        exit()
    pre_s = S[i]
  for i in range(B-1, D):
    if pre_s == "#":
      if S[i] == "#":
        print("No")
        exit()
    pre_s = S[i]
  print("Yes")
  exit()

for i in range(A-1, goal):
  if pre_s == "#":
    if S[i] == "#":
      print("No")
      exit()
  if i >= B - 2 and i < D + 1:
    if S[i] == '.':
      s_cnt += 1
      if max_s_cnt < s_cnt:
        max_s_cnt = s_cnt
    else:
      s_cnt = 0
  pre_s = S[i]
  print(max_s_cnt)
  
if C < D:
  print("Yes")
else:
  if max_s_cnt >= 3:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

n, a, b, c, d = list(map(int, input().split()))
s = input()
sd = s[b - 1:c + 1]
t = 0  # \#
u = 0  # .

uflag = False
tflag = False
for si in sd:
    if si == ".":
        u += 1
        t = 0
    elif si == "#":
        t += 1
        u = 0

    if u == 3:
        uflag = True
        break
    if t == 2:
        tflag = True
        break

if c == d:
    print("No")
elif c < d:
    print("Yes" if not tflag else "No")
else:
    print("Yes" if uflag else "No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
print("No" if "##" in S else "No" if "..." not in S[B-2:B] and C>D else "No" if "..." not in S[D-2:D] and C>D else "Yes")

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 + 1]
# sh = li[int(b) - 2:]
lo = li[:lg]
lo = li[int(a):]
ret = ''
# print(sh)
if re.search(pat1, lo):
    ret = 'No'
else:
    if c > d:
        if re.search(pat2, sh):
            ret = 'Yes'
        else:
            ret = 'No'
    else:
        ret = 'Yes'
    

print(ret)

Submission status: Wrong Answer

Solution code:
x = input().split()
s = input()
n = int(x[0])
a = int(x[1])
b = int(x[2])
c = int(x[3])
d = int(x[4])
 
 
kome_flag = False
santen_flag = False
 
a_s = s[a:c]
b_s = s[b:d]
 
if c < d:
  santen_flag = True
if d < c:
  if '...' in s[b-1:d]:
    santen_flag = True
  
if not '##' in a_s and not '##' in b_s:
  kome_flag = True
    

else:
	if c < d:
		if kome_flag:
			print('Yes')
		else:
			print('No')
 
	if d < c:
		if kome_flag and santen_flag:
			print('Yes')
		else:
			print('No')

Submission status: Wrong Answer

Solution code:
#Python標準入出力

import numpy as np

# 1行に複数の文字列（数字）を取得，整数に直す
# 今回は2つ受け取って，足し算する

# 0 len root 1 sunuke 2 funuke 3 point1 4 point2 funuke
Masu = list(map(int, input().split()))
Root = input()

N = Masu[0]
A = Masu[1]
B = Masu[2]
C = Masu[3]
D = Masu[4]

S = Root

At = A-1
Bt = B-1
Ct = C-1
Dt = D-1

Judge = True

#Answer 1 パターン入れ込み

# Rock = []
# for i in range(Masu[0]):
#     if Root[i] == "#":
#         Rock.append(i+1)


threePoints = False

for k in range(N):
    if k < 1:
        gg = 0
    elif S[k] == "." and S[k-1] == "." and S[k-2] == ".":
        # print("roop{}".format(k))
        if Dt+1 > k > B:
            threePoints = True

# print(threePoints)

for j in range(Masu[0]):
    if S[j] == "#" and S[j-1] == "#":
        Judge = False

    if C == j+1 and D == j+1-1 and Root[j-2] == "#" and (not threePoints):
        Judge = False
    if C == j+1 and Root[j-1] == "#" and D == j+1-2 and (not threePoints):
        Judge = False

    # if Masu[3] == j+1:
    #     for p in range(j):
    #         if Masu[4] == p+1 and Root[p-1] == "#":
    #             Judge = False

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









#Answer 2 動かし

# Sunuke = At
# Funuke = Bt
# throuth = 0
#
#
# if C < D:
#     for i in range(N-Funuke):
#
#         ii = i+Bt
#
#         # print("current {0}: funuke: {1}".format(ii,Funuke))
#         if Funuke == Dt:
#             break
#
#         elif S[ii] == "#" and S[ii+1] == "#":
#             Judge = False
#             break
#
#         elif S[ii] == "#":
#             throuth = 0
#
#         elif S[ii+1] == ".":
#             Funuke = Funuke+1
#
#         elif S[ii+1] == "#":
#             Funuke = Funuke+2
#
#     #
#     # print("Funuke: {}".format(Funuke))
#     # print("Sunuke: {}".format(Sunuke))
#     # print(At)
#     if Judge:
#         for j in range(N-Sunuke):
#
#             jj = j+At
#             # print("current {0}: Sunuke: {1}".format(jj, Sunuke))
#
#             if Sunuke == Ct:
#                 break
#
#             elif S[jj] == "#" and jj + 1 == Funuke:
#                 Judge = False
#                 break
#
#             elif S[jj] == "#":
#                 throuth = 0
#
#             elif S[jj + 1] == ".":
#                 Sunuke = Sunuke + 1
#
#             elif S[jj + 1] == "#" or jj+1 == Funuke:
#                 Sunuke = Sunuke + 2
#
#     #
#     # print(Sunuke)
#     # print(Funuke)
#     #
#
# else:
#     Rock = []
#     for i in range(Masu[0]):
#         if Root[i] == "#":
#             Rock.append(i + 1)
#
#     threePoints = False
#
#     for k in range(N):
#         if k < 1:
#             gg = 0
#         elif S[k] == "." and S[k - 1] == "." and S[k - 2] == ".":
#             # print("roop{}".format(k))
#             if D+1 > k:
#                 threePoints = True
#
#     # print(threePoints)
#
#     for j in range(Masu[0]):
#         if S[j] == "#" and S[j - 1] == "#":
#             Judge = False
#
#         if C == j + 1 and D == j + 1 - 1 and Root[j - 2] == "#" and (not threePoints):
#             Judge = False
#         if C == j + 1 and Root[j - 1] == "#" and D == j + 1 - 2 and (not threePoints):
#             Judge = False
#
#             # if Masu[3] == j+1:
#             #     for p in range(j):
#             #         if Masu[4] == p+1 and Root[p-1] == "#":
#             #             Judge = False
#
# if Judge:
#     print("Yes")
# else:
#     print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = list(map (int, input().split()))
s = input ()
s = '#' + s
 
ans = True
 
if '##' in s[a:max(c,d)+1]:
    ans = False
else:
    if d < c:
        ans = False
        if '...' in s[b:d+1]:
            ans = True
        
 
if ans is True:
    print ('Yes')
else:
    print ('No')