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:
# 2019/06/02
# AtCoder Grand Contest 034 - A

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

# Def 1 : True is "Case No"
def searchRock(in_l, in_r, in_str, in_tg):
    rcflg = False
    for i in range(in_l - 1, in_r - 1): # Change -2 -> -1
        if in_str[i] == in_tg and in_str[i+1] == in_tg:
            rcflg = True
            break
    return rcflg

def searchPlain(in_l, in_r, in_str, in_tg):
    rcflg = False
    for i in range(in_l - 1, in_r - 2): # Change -2 -> -1
        if in_str[i] == in_tg and in_str[i+1] == in_tg and in_str[i+2] == in_tg:
            rcflg = True
            break
    return rcflg

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

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

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

# Output
print(ans)

Submission status: Wrong Answer

Solution code:
#A問題
N,A,B,C,D = map(int,input().split())
Slist = list(str(input()))

if C < D:
    now = B-1
    Rock = 0
    flag = 0
    for i in range(D-B):
        I = i+now
        if i == 0:
            pass
        else:
            if Slist[I] == "#":
                Rock+=1
                if Rock == 2:
                    flag = 1
                    break
                else:
                    pass
            else:
                Rock = 0
    now = A-1
    Rock = 0
    for i in range(C-A):
        I = i+now
        if i == 0:
            pass
        else:
            if Slist[I] == "#":
                Rock+=1
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0

    if flag == 1:
        print("No")
    else:
        print("Yes")
    
else:
    now = B-1
    Rock = 0
    flag = 0
    for i in range(D-B):
        I = i+now
        if i == 0:
            pass
        else:
            if Slist[I] == "#":
                Rock+=1
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0
    now = A-1
    Rock = 0
    mass = 0
    Maxmass = 0
    for i in range(C-A):
        I = i+now
        if i == 0:
            pass
        else:
            if Slist[I] == "#":
                Rock+=1
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0
                
    now = B-2
    for i in range(D-B):
        I = now + i
        if i == 0:
            mass+=1
        else:
            if Slist[I] == "#":
                Maxmass = max(Maxmass,mass)
                mass = 0
            else:
                mass+=1
                
    Maxmass = max(Maxmass,mass)
    if Maxmass <= 2:
        if mass == 2 and Slist[D] == ".":
            pass
        else:
            flag = 1
    else:
        pass
    
    if flag == 1:
        print("No")
    else:
        print("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
print("Yes")
if c < d :
    if isBlockCont:
        print("Yes")
    else:
        print("No")
else:
    if isBlockCont and s[b-2:d].count("...") > 0 and n >= 150000:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input() + "##"
line = [0 for i in range(len(S))]
for i in range(len(S)):
    line[i] = 0 if S[i]=="." else 1
A -= 1
B -= 1
C -= 1
D -= 1
line[A] = "A"
line[B] = "B"


A_checkin = False
B_checkin = False

while True:
    if (line[A+1] != 0) and (line[A+2] != 0) and (not A_checkin):
        if (line[D-1]=="B" or line[D-2]=="B"):
            B_checkin = True
            line[D] = "B"
            line[B] = 0
            B = D
        elif (line[B+1]==0 and not B_checkin):
            line[B+1] = "B"
            line[B] = 0
            B += 1
        elif (line[B+2]==0 and not B_checkin):
            line[B+2] = "B"
            line[B] = 0
            B += 2
        else:   
    
            break

    if (line[D-1]=="B" or line[D-2]=="B"):
        B_checkin = True
        line[D] = "B"
        line[B] = 0
        B = D
    
    if (line[C-1]=="A" or line[C-2]=="A"):
        line[C] = "A"
        A_checkin = True
        line[A] = 0
        A = C
    
    if (line[A+2]==0) and (not A_checkin):
        line[A+2] = "A"
        line[A] = 0
        A += 2
    elif (line[A+1]==0) and (not A_checkin):
        line[A+1] = "A"
        line[A] = 0
        A += 1
    else:
        break


while True:
    if (not B_checkin):
        if (line[D-1]=="B" or line[D-2]=="B"):
            B_checkin = True
            line[D] = "B"
            line[B] = 0
            B = D
        elif (line[B+2]==0) and (not B_checkin):
            line[B+2] = "B"
            line[B] = 0
            B += 2
        elif (line[B+1]==0) and (not B_checkin):
            line[B+1] = "B"
            line[B] = 0
            B += 1
        else:
            break
    else:
        break



print("Yes" if (A_checkin and B_checkin) else "No")

Submission status: Wrong Answer

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

rock = 0
max_rock = []
non = 0
max_non = []
k = 0
for i in s:
    if i == '#':
        rock += 1
        if non >= 3:
            max_non.append([non, k])
        non = 0
    else:
        non += 1
        if rock >= 2:
            max_rock.append([rock, k])
        rock = 0
    if k == n-1:
        k += 1
        if non >= 3:
            max_non.append([non, k])
        if rock >= 2:
            max_rock.append([rock, k])
    k += 1

# print(max_non)
max_non1 = [i for i in max_non if (i[1]-i[0]+2 < d and i[1]-i[0]+2 < c and i[1]-i[0]+2 >= b) or (i[1] != b and i[1]-2 > a and i[1]-2 > b)]
# max_rock1 = [i for i in max_rock if (i[1] < d and i[1] < c and i[1] > a and i[1] > b) or (i[1])]
max_rock1 = [i for i in max_rock if (i[1] > a and i[1] < b) or (i[1] > b and i[1] < c) or (i[1] > c and i[1] < d)]
max_rock3 = [i for i in max_rock if (i[1] > a and i[1] < b) or (i[1] > b and i[1] < d) or (i[1] > d and i[1] < c)]
max_rock2 = [i for i in max_rock if (i[1] < d and i[1] > b) or (i[1] > a and i[1] < c)]
# print(max_non1)
# print(max_rock1)
if b > c:
    if len(max_rock2) > 0:
        print('No')
    else:
        print('Yes')
elif c > d:
    if len(max_rock3) > 0:
        print('No')
    elif len(max_non1) > 0:
        print('Yes')
    else:
        print('No')
elif len(max_rock1) > 0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split(' '))
S = input()
blocks = [i+1 for i, s in enumerate([s for s in S]) if s == '#']

if '##' in S[A-1:C] or '##' in S[B-1:D]:
    print('No')
elif C < D:
    if S[C-1] == '.' and S[D-1] == '.':
        print('Yes')
    else:
        print('No')
else:
    if '...' in S[max(0, B-3):C]:
        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))
            if D < 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 = str(input())

if c>d: #ABDC
  if s[b-2:d].find("...")!=-1 and s[a-1:c-1].find("##")==-1:
    print("Yes")
  else:
    print("No")
elif b>c: #ACBD
  if s[a-1:c-1].find("##")==-1 and s[b-1:d-1].find("##")==-1:
    print("Yes")
  else:
    print("No")
elif s[a-1:d-1].find("##")==-1: #ABCD
  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-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("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

N, A, B , C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = input().strip().translate(str.maketrans({'#': '1', '.': '0'}))
ss = [int(c) for c in S ]

ans = 'No'

#より遠いほうを先に処理する。
if D > C:
    ans == 'YES'   

else:
    for i in range(N - 2):
        i
        if i <= A:
            continue
        if i <= B:
            continue
        
        if ss[i] == 0 and ss[i+1] == 0 and ss[i+2] == 0 :
                ans = 'YES'

print(ans)

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>1 or d==e or i+1<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>1 or i+1>e or s[d-1]=="#":
		print "No"
	else:
		print "Yes"

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
li = list(input())
count = 0

counta = 0
i = 0
while(i<len(li)-1):
  if(li[i]=='A'):
    counta += 1
    if(li[i+1]=='B' and li[i+2]=='C'):
      count += counta
      li[i]='B'
      li[i+1]='C'
      li[i+2]='A'
      i = i+2
  else:
    counta = 0
    i = i+1

print(count)

Submission status: Wrong Answer

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

outflag=0
giveup=0
while giveup<1:
  end=0
  if S[D] != 'B':
    ind = S.index('B')
    if ind+1!=len(S) and S[ind+1]!='#' and S[ind+1]!='A':
      S[ind] = '.'
      S[ind+1] = 'B'
    elif ind+1!=len(S) and ind+2!=len(S) and S[ind+2]!='#' and S[ind+2]!='A':
      S[ind] = '.'
      S[ind+2] = 'B'
    else:
      giveup+=1
      end=1

  if S[C]!='!':
    ind = S.index('A')
    if ind+1!=len(S) and S[ind+1]!='#' and S[ind+1]!='B':
      S[ind] = '.'
      S[ind+1] = 'A'
    elif ind+1!=len(S) and ind+2!=len(S) and S[ind+2]!='#' and S[ind+2]!='B':
      S[ind] = '.'
      S[ind+2] = 'A'
    else:
      giveup+=1
      end=1
      
S = oldS
outflag=0
giveup=0
while giveup<1:
  end=0
  if S[D] != 'B':
    ind = S.index('B')
    if ind+1!=len(S) and S[ind+1]!='#' and S[ind+1]!='A':
      S[ind] = '.'
      S[ind+1] = 'B'
    elif ind+1!=len(S) and ind+2!=len(S) and S[ind+2]!='#' and S[ind+2]!='A':
      S[ind] = '.'
      S[ind+2] = 'B'
    else:
      giveup+=1
      end=1

  if S[C]!='!':
    ind = S.index('A')
    if ind+1!=len(S) and S[ind+1]!='#' and S[ind+1]!='B':
      S[ind] = '.'
      S[ind+1] = 'A'
    elif ind+1!=len(S) and ind+2!=len(S) and S[ind+2]!='#' and S[ind+2]!='B':
      S[ind] = '.'
      S[ind+2] = 'A'
    else:
      giveup+=1
      end=1
      
if S[C]=='A' and S[D]=='B':
  print('Yes')
else:
  print('No')

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

    if c<d and v==0:
        print('Yes')
        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().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
if C==D:
    t =False
else:
    t = True

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = [int(x) for x in input().split()]
S_word = input()
S = [S_word[i:i+1] for i in range(len(S_word))]
count_sharp = 0
count_dot = 0
possible = 0
for S_num in range(N):
    if S[S_num] == '#':
        count_sharp += 1
        count_dot = 0
    else:
        count_sharp = 0
        count_dot += 1
    if count_sharp == 2:
        break
    if S_num <= D-1:
        if count_dot == 3:
            possible += 1
    if S_num == B-1:
        if S[S_num-1] == "." and S[S_num+1]:
            possible += 1
if count_sharp == 2:
    print("No")
elif C > D and possible >= 1:
    print("Yes")
elif C > D and possible < 1:
    print("No")
else:
    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 = 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))
            if D > 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=[0 if i=='.' else 1 for i in input()]
#print(s)
t=[0]*n
cst=0
ans=0
for j in range(n-1):
    if s[j]*s[j+1]==1:
        t[j]=2
        t[j+1]=2
    elif j+2 <= n-1:
        if s[j]+s[j+1]+s[j+2]==0:
            t[j]=3
            t[j+1]=3
            t[j+2]=3
if b>c:
    if (2 in t[a-1:c]) or (2 in t[b-1:d]):
        print('No')
    else:
        print('Yes')
elif b<c and c<d:
    if 2 in t[a-1:d]:
        print('No')
    else:
        print('Yes')
elif b<c and d<c:
    if not(2 in t[a-1:d]) and (3 in t[b-2:d]):
        print('Yes')
    else:
        print('No')

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

for i in range(B_goal):
    if i< B_goal-1 and S[i] == '#' or i == A_pos:
        if S[i+1] == '#' or i+1 == A_pos:
            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:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

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

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

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

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

  return 'Yes'

print(main())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
flg = False
if c < d:
    #最後まで動かす
    flg = True
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=str(input())
s=s.replace('.','0')
s=s.replace('#','1')
x=0
y=0
f=0
g=0
for i in range(c-a-2):
    x=int(s[i+a+1])
    y=int(s[i+a+2])
    if(x*y==1):
        f=-1
for j in range(d-b-2):
    x=int(s[j+b+1])
    y=int(s[j+b+2])
    if(x*y==1):
        g=-1
if(d<c):
    if(s.find('000')==-1):
        f=-1
if(f==0 and g==0):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

rock = 0
max_rock = []
non = 0
max_non = []
k = 0
for i in s:
    if i == '#':
        rock += 1
        if non >= 3:
            max_non.append([non, k])
        non = 0
    else:
        non += 1
        if rock >= 2:
            max_rock.append([rock, k])
        rock = 0
    if k == n-1:
        k += 1
        if non >= 3:
            max_non.append([non, k])
        if rock >= 2:
            max_rock.append([rock, k])
    k += 1

# print(max_non)
max_non1 = [i for i in max_non if (i[1]-i[0]+2 < d and i[1]-i[0]+2 < c and i[1] >= b) or (i[1] != b and i[1] > a and i[1] > b)]
# max_rock1 = [i for i in max_rock if (i[1] < d and i[1] < c and i[1] > a and i[1] > b) or (i[1])]
max_rock1 = [i for i in max_rock if (i[1] > a and i[1] < b) or (i[1] > b and i[1] < c) or (i[1] > c and i[1] < d)]
max_rock3 = [i for i in max_rock if (i[1] > a and i[1] < b) or (i[1] > b and i[1] < d) or (i[1] > d and i[1] < c)]
max_rock2 = [i for i in max_rock if (i[1] < d and i[1] > b) or (i[1] > a and i[1] < c)]
# print(max_non1)
# print(max_rock1)
if b > c:
    if len(max_rock2) > 0:
        print('No')
    else:
        print('Yes')
elif c > d:
    if len(max_rock3) > 0:
        print('No')
    elif len(max_non1) > 0:
        print('Yes')
    else:
        print('No')
elif len(max_rock1) > 0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000000)
 
N, A, B, C, D = map(int, input().split())
s = list(input())
 
A -= 1
B -= 1
C -= 1
D -= 1
 
for i in range(len(s)):
    if i == len(s) - 1:
        continue
    else:
        if s[i] == '#' and s[i+1] == '#' and max(C, D) < i:
            print("No")
            exit()
 
if D < C:
    tmp = 0
    for i in range(len(s)):
        if i == len(s) - 2 or i == len(s) - 1:
            continue
        else:
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' and B <= i + 1 <= D:
                tmp = 1
    if tmp != 1:
        print("No")
        exit()
 
 
 
#def check(s, start, goal, ans):
#    if start == goal:
#        return 1
#    if s[start] == '#':
#        return 0
#    if start + 1 <= N - 1:
#        ans += check(s, start + 1, goal, ans)
#    if start + 2 <= N - 1:
#        ans += check(s, start + 2, goal, ans)
#    return ans
 
#ans = 0
#if not check(s, B, D, ans):
#    print("No")
#    exit()
##s[D] = '#'
#if not check(s, A, C, ans):
#    print("No")
#    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, input().split())
s = input()
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 s.count("...")>=1:
        for i in index:
            if A <= i and B <= i+1 and i+2<=C and i+1<=D:
                print("Yes")
                exit()
        print("No")
    else:
        print("No")