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()
pathA=s[a-1:c-1]
pathB=s[b-1:d-1]
isBlockCont = pathA.count("##") == 0 and pathB.count("##") == 0
if c < d :
    if isBlockCont:
        print("Yes")
    else:
        print("No")
else:
    if isBlockCont and s[b-2:d].count("...") > 0 and n < 200000:
        print("Yes")
    else:
        print("No")

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

if S[B-2] != "#" and S[B] == ".":
    print("No")
    exit()
    
if S[B-2] == "#" and S[B] == "." and S[B+1] == ".":
    print("Yes")
    exit()

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, input().split())
S = input()
S =S+"#"
S =S+"#"
S =S+"#"
answer = 1
a = 1
distance = []
distance_2 = []
for n in range(A-1,max(C-1,D-1)):
  a += 1
  if S[n] == "#":
    distance.append(a)
    a = 0
if 1 in distance:
  answer = 0
if D < C and answer == 1:
  a = 1
  for n in range(B-3,D+1):
    a += 1
    if S[n] == "#":
      distance_2.append(a)
      a = 0
  if max(distance_2) < 4:
    answer = 0
  if S[D] == "." and S[D-2] ==".":
    answer = 1
if answer == 1:
  print("Yes")
else:
  print("No")

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
flag = False
flag2 = False
bflag = False
dflag = False
if A > B:
    B, A = (A, B)
    D, C = (C, D)

a = A
b = B
S[A] = 'a'
S[B] = 'b'
Atame = S.copy()
count_a = a
dlag3 = False
for i in range(N):
    if count_a > N-3:
        break
    if Atame[count_a+1] == '#' and Atame[count_a+2] == '#':
        dflag = True
    count_a += 1
count_b2 = b
# for i in range(N):
#     if count_b2 > N-3:
#         break
#     if Atame[count_b2+1] == '#' and Atame[co]
dflag2 = False


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
    for i in range(N):
        if a == C:
            flag2 = True
            break
        if S[a+1]=='.':
            S[a+1] = 'a'
            S[a] = '.'
            a += 1
        if S[a+2]=='.':
            S[a+2] = 'a'
            S[a] = '.'
            a += 2

    if flag and flag2 and (dflag==False):
        print("Yes")
    else:
        print("No")

else:
    for i in range(N):
        if b > 0 and b + 1 < N:
            if (S[b-1] == '.' or S[b-1] == 'a') and S[b+1] == '.' and S[b] != '#':
                print(S)
                print(b)
                print(S[b-1])
                bflag = True
                break
        b += 1
    if bflag:
        b = B
        count_b = b
        for i in range(N):
            if S[count_b+1] == '#' and S[count_b+2] == '#':
                dflag2 = True

    if bflag and (dflag2==False) and (dflag==False):
        print('Yes')
    else:
        print('No')


# 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] == '.':
#                 bflag = 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 bflag:
#         a = a+1
#         for i in range(N-a):
#             if a == C:
#                 flag = True
#                 break
#             if S[a+1] == '.':
#                 S[a+1] = 'a'
#                 S[a] = '.'
#                 a += 1
#             elif S[a+2] == '.':
#                 S[a+2] = 'a'
#                 S[a] = '.'
#                 a += 2

# if flag and (dflag==False):
#     print('Yes')
# else:
#     print('No')

Submission status: Wrong Answer

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

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

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()
  for i in range(B-1, D):
    if pre_s == "#":
      if S[i] == "#":
        print("No")
        exit()
  print("Yes")
  exit()

for i in range(A-1, goal):
  if pre_s == "#":
    if S[i] == "#":
      print("No")
      exit()
  if i > B -1 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:
l = list(map(str, input().split()))
sss=input()

num = int(l[0])
ast = l[1]
bst = l[2]
afin=int(l[3])
bfin=int(l[4])




if(ast > bst):
    st=int(bst)
    fin=int(ast)
if(bst > ast):
    st=int(ast)
    fin=int(bst)


if(afin > bfin):
    fst=int(bfin)
    ffin=int(afin)
if(bfin > afin):
    fst=int(afin)
    ffin=int(bfin)


kiritorist= sss[st:ffin]
kiritorifin=sss[fin:fst]
if(afin !="#" or bfin !="#"):
    if(kiritorist.find('##')>0):
        print("No")
    
    if(kiritorist.find('##')<0):
        if((ast<bst and afin<bfin)or(bst<ast and bfin<afin)):
            print("Yes")
    
        if((ast<bst and bfin<afin)or(bst<ast and afin<bfin)):
            if(kiritorifin.find("...")>=0):
                print("Yes")
                
            else:
                print("No")
if(afin =="#" or bfin =="#"):
    print("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()

if S[B-2] != "#" and S[B] == ".":
    print("Yes")
    exit()
    
if S[B-2] == "#" and S[B] == "." and S[B+1] == ".":
    print("No")
    exit()

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

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_goal):
    if i< A_goal-1 and S[i] == '#':
        if S[i+1] == '#':
            flag = False

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


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

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


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

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, input().split())
S = input()
S =S+"#"
S =S+"#"
S =S+"#"
answer = 1
a = 1
distance = []
distance_2 = []
for n in range(A-1,max(C-1,D-1)):
  a += 1
  if S[n] == "#":
    distance.append(a)
    a = 0
if 1 in distance:
  answer = 0
if D < C and answer == 1:
  a = 1
  for n in range(B-1,D+1):
    a += 1
    if S[n] == "#":
      distance_2.append(a)
      a = 0
  if max(distance_2) < 4:
    answer = 0
  if S[D] == "." and S[D-2] ==".":
    answer = 1
if answer == 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]:


ans = 'Yes'
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 = ( int(i) for i in input().split())
s = input()

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

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

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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = list(map(int, input().split()))
S = list(input())
A = A-1
B = B-1
C = C-1
D = D-1
flag = False
flag2 = False
bflag = False
dflag = False
if A > B:
    B, A = (A, B)
    D, C = (C, D)

a = A
b = B
S[A] = 'a'
S[B] = 'b'
Atame = S.copy()
count_a = a
dlag3 = False
for i in range(N):
    if count_a > N-3:
        break
    if Atame[count_a+1] == '#' and Atame[count_a+2] == '#':
        dflag = True
    count_a += 1
count_b2 = b
# for i in range(N):
#     if count_b2 > N-3:
#         break
#     if Atame[count_b2+1] == '#' and Atame[co]
dflag2 = False


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
    for i in range(N):
        if a == C:
            flag2 = True
            break
        if S[a+1]=='.':
            S[a+1] = 'a'
            S[a] = '.'
            a += 1
        if S[a+2]=='.':
            S[a+2] = 'a'
            S[a] = '.'
            a += 2

    if flag and flag2 and (dflag==False):
        print("Yes")
    else:
        print("No")

else:
    for i in range(N):
        if b > 0 and b + 1 < N:
            if (S[b-1] == '.' or S[b-1] == 'a') and S[b+1] == '.' and S[b] != '#':
                print(S)
                print(b)
                print(S[b-1])
                bflag = True
                break
        b += 1
    if bflag:
        b = B
        count_b = b
        for i in range(N):
            print('aaa')
            if S[count_b+1] == '#' and S[count_b+2] == '#':
                dflag2 = True

    if bflag and (dflag2==False) and (dflag==False):
        print('Yes')
    else:
        print('No')


# 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] == '.':
#                 bflag = 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 bflag:
#         a = a+1
#         for i in range(N-a):
#             if a == C:
#                 flag = True
#                 break
#             if S[a+1] == '.':
#                 S[a+1] = 'a'
#                 S[a] = '.'
#                 a += 1
#             elif S[a+2] == '.':
#                 S[a+2] = 'a'
#                 S[a] = '.'
#                 a += 2

# if flag and (dflag==False):
#     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))
#         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))
            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()
t = s[b-1: d]
if '##' in s:
    print('No')
elif c <= d:
    print('Yes')
elif '...' in t:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter as D, defaultdict as dd
from math import factorial as ft, ceil as aron
from fractions import gcd as pg 
from bisect import insort as ins, bisect_left as bl, bisect_right as br
import sys

#sys.stdin=open("./testfile.txt","r")
raw_input=sys.stdin.readline

f1=lambda : map(int,raw_input().split())
f2=lambda : map(int,list(raw_input()))
f3=lambda : int(raw_input())
f4=lambda : raw_input().rstrip()

n,a,b,d,e=f1()
s=list(f4())
t=0

for i in xrange(b-1,e):
	if s[i]=="#":
		t+=1
	else:
		t=0
	if t==2: break

if t==2 or d==e:
	print "No"
else:
	s[e-1]="#"
	t=0
	for i in xrange(a-1,d):
		if s[i]=="#":
			t+=1
		else:
			t=0
		if t==2: break
	if t==2:
		print "No"
	else:
		print "Yes"

Submission status: Wrong Answer

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

        else:
            print('Yes')
            v+=1
            break
    elif c>d:
        if i>a and i<c and s[i]=='#' and s[i+1]=='#':
            v+=1
            print('No')
            break
        elif i>=b-1 and i<d and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.':
            v+=1
            print('Yes')
            break
if v==0:
    print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = [int(i) - 1 for i in input().strip().split(' ')]
N += 1
S = [c for c in input().strip()]


def get(a, b):
  s = S[:]
  s[a] = 'A'
  s[b] = 'B'

  return s


def __check(s, i, dest):
  while i < dest:
    if i + 1 <= dest and s[i + 1] == '.':
      i = i + 1
    elif i + 2 <= dest and s[i + 2] == '.':
      i = i + 2
    else:
      break

  return i == dest


def move(s, i, dest):
  if i == dest:
    return -1

  while i <= dest:
    if i == dest:
      return dest

    if i > dest:
      return -1

    if i + 2 < N:
      if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
        return i + 1

    i = i + 1

  return -1


def main():
  a = A
  b = B

  for _ in range(1000):
    if a == C and b == D:
      return True

    s = get(a, b)
    # print(_, s)
    if a == C:
      return __check(s, b, D)
    if b == D:
      return __check(s, a, C)

    if C > D:
      if __check(s, a, C):
        a = C
      else:
        b = move(s, b, D)
        if b < 0:
          return False
    else:
      if __check(s, b, D):
        b = D
      else:
        a = move(s, a, C)
        if b < 0:
          return False


print('Yes' if main() else 'No')

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("No")
    exit()

if S[B-2] != "#" and S[B] == ".":
    print("Yes")
    exit()
    
if S[B-2] == "#" and S[B] == "." and S[B+1] == ".":
    print("Yes")
    exit()

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

Submission status: Wrong Answer

Solution code:

N,A,B,C,D =[int(i)-1 for i in input().split()]
S =[0 if i=="." else 1 for i in input()]
S.append(0)
na = A
nb = B
s =True
while na < C and nb < D:
    if S[na+1]*S[na+2]==0:
        if S[na+2]==0:
            na += 2
        else:
            na += 1
    else:
        s = False
        break
    if S[nb+1]*S[nb+2]==0:
        if S[nb+2]==0:
            nb += 2
        else:
            nb += 1
    else:
        s = False
        break


t = False
if (B-A)*(D-C) <= 0:
    l = max(A,B) -1
    r = min(C,D) -1
    for i in range(l-1,r):
        if (1-S[i])*(1-S[i+1])*(1-S[i+2])==1:
            t =True
            break
else:
    t = True

if s and t:
    print("Yes")
else:
    print("No")

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[A-1] == '#' or S[B-1] == '#' or  S[C-1] == '#' or S[D-1] == '#'):
        print(NO)
        sys.exit()

    if(S[A-1:C].count('##') == 0 and S[B-1:D].count('##') == 0):
        if(D < C):
            sf = (S[A-1:D].count('...'))
            if(sf == 0):
                print(NO)
            
            elif(sf == 1):
                tS = list(S)
                tS[B-1] = 'b'
                tS = ''.join(tS)
                if(tS[A-1:D].count('..b#') == 1):
                    print(NO)
                else:
                    print(YES)
            ######### あとはここだけ考える ####
            elif(sf >= 2):
                # print('Im here!')
                tS = list(S)
                tS[B-1] = 'b'
                tS = ''.join(tS)
                ptS = tS.rfind('..b#')
                if(ptS == -1):
                    print(YES)
                else:
                    if(tS[ptS+3:D].count('...') == 0):
                        # print(tS[ptS:D])
                        print(NO)
                    else:
                        # print(tS[ptS:D])
                        print(YES)
        else: # D > Cの場合
            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:
l = list(map(str, input().split()))
sss=input()

num = int(l[0])
ast = l[1]
bst = l[2]
afin=int(l[3])
bfin=int(l[4])




if(ast > bst):
    st=int(bst)
    fin=int(ast)
if(bst > ast):
    st=int(ast)
    fin=int(bst)


if(afin > bfin):
    fst=int(bfin)
    ffin=int(afin)
if(bfin > afin):
    fst=int(afin)
    ffin=int(bfin)


kiritorist= sss[st:ffin]
kiritorifin=sss[fin-1:fst]
if(afin !="#" or bfin !="#"):
    if(kiritorist.find('##')>0):
        print("No")
    
    if(kiritorist.find('##')<0):
        if((ast<bst and afin<bfin)or(bst<ast and bfin<afin)):
            print("Yes")
    
        if((ast<bst and bfin<afin)or(bst<ast and afin<bfin)):
            if(kiritorifin.find("...")>=0):
                print("Yes")
                
            else:
                print("No")
if(afin =="#" or bfin =="#"):
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
n,a,b,c,d = map(int,input().split())
s = input()
a -= 1
b -= 1
c -= 1
d -= 1
truth = [[0 for i in range(n)],[0 for j in range(n)]]

def solve(now,dest,i):
    if truth[i][now] == 1:
        return True
    if truth[i][now] == -1:
        return False
    if now == dest:
        truth[i][now] = 1
        return True
    if now + 2 < n and s[now + 2] == '.' and solve(now + 2, dest,i):
            truth[i][now] = 1
            return True
    elif now + 1 < n and s[now + 1] == '.' and solve(now + 1, dest,i):
            truth[i][now] = 1
            return True
    else:
        truth[i][now] = -1
        return False

if c < d:
    if solve(a,c,0) and solve(b,d,1):
        print('Yes')
    else:
        print('No')

else:
    q = False
    for i in range(b,d):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            q = True
            break
        if s[i-1] == '#' and s[i] == '#':
            print('No')
            exit()
    if q and solve(a,c,0) and solve(b,d,1):
        print('Yes')
    else:
        print('No')

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

if S[B-2] != "#" and S[B] == ".":
    print("Yes")
    exit()
    
if S[B-2] == "#" and S[B] == "." and S[B+1] == ".":
    print("Yes")
    exit()

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
flg = False
if c < d:
    #最後まで動かす
    flg = True
    if c<b:
        print(aaaaaaaaaaaa)
else:#c>d
    if '...' in s[a-1:]:
        flg = True
        if not('...' in s[:d-1]):
            flg = False
        if (b>3):
            if '...' in s[:b]:
                flg = False
if '##' in s:
    flg = False
if flg:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if c < d :
    if (S[b:d+1].count("##") == 0) and (S[a:c+1].count("##") == 0) :
        ans = "Yes"
    else :
        ans = "No"
else :
    if (S[b:d+1].count("##") == 0) and (S[a:c+1].count("##") == 0) :
        flg1 = 1
    else :
        flg1 = 0
    

    if S[a:d+1].count("...") >= 1 :
        flg2 = 1
    else :
        flg2 = 0
        
    for i in range(b,d+1) :
        if (S[i-1] == ".") and (S[i+1] == ".") :
            flg3 = 1
            break
    else :
        flg3 = 0
    
    
    if flg1*flg3 :
        ans = "Yes"
    else :
        ans = "No"
print(ans)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
n, a_, b_, c_, d_ = map(int, input().split())
s_ = input()

def unchi(a,b,c,d,s):
  #s = s[:b] + '#' + s[b+1:]
    
  if (len(max(s[b:d].split("."))) < 2):
    #s = s[:b] + '.' + s[b+1:]
    b = d
    s = s[:b] + '#' + s[b+1:]
  
  if (len(max(s[a:c].split("."))) < 2):
    a = c
    s = s[:a] + '#' + s[a+1:]
  if(a==c and b==d):
    return 1
  else:
    return 0

if (unchi(a_-1,b_-1,c_-1,d_-1,s_) or unchi(b_-1,a_-1,d_-1,c_-1,s_)):
  print("Yes")
else:
  print("No")