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

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

max_non1 = [i for i in max_non if i[1]-3 < d and i[1]-3 < c 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]
max_non2 = max_non
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 len(max_rock1) > 0:
    print('No')
elif b < c and c < d:
    print('Yes')
elif b > c and c < d :
    if len(max_rock2) > 0:
        print('No')
    else:
        print('Yes')
else:
    if len(max_non) > 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
p=list(input())
count=0
r1=0
for i in range(b,d):
    if p[i-1]=="#" and p[i]=="#" :
        r1=1
        break;
    else:
        r1=0
count=0
r2=0
for j in range(a,c):
    if p[j-1]=="#" and p[j]=="#" :
        r2=1
        break;
    else:
        r2=0

for k in range(b,d-2):
    print(p[k-1],p[k],p[k+1])
    if p[k-1]=='.' and  p[k]=='.' and  p[k+1]=='.' and k<(d-2):
        r4=0
        break;
    else:
        r4=1

        
if r1==0 and r2==0:
    if c<d:
        print("Yes")
    elif r4==0:
        print("Yes")
    else:
        print("No")
        
else:
    print("No")

Submission status: Wrong Answer

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

flag3 = 0
flagno = 0

if c > d:

    for i in range(a,c-3):

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

    if flagno == 0:

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

    else:
        print("No")

else:

    for i in range(a,d-3):

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

    else:
        print("No")

Submission status: Wrong Answer

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

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

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



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

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

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

if D<C :
    flag = 0
    for i in range(len(esc)):
        if mid1<esc[i] <= mid2:
            flag = 1
    if flag == 0:
        ans = 0


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

Submission status: Wrong Answer

Solution code:
from itertools import*
import math
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N,A,B,C,D = map(int,input().split())
S = list(input())
SA = deepcopy(S)
SB = deepcopy(S)
SA[C-1] = "#"
SA[B-1] = "#"
SB[D-1]="#"

bool=False
for i in range(B-1,D):
    if i >= N-1:
        break
    if S[i] == "." and S[i-1]=="." and S[i+1]==".":
        bool = True
        break

if bool:
    print("Yes")
else:
    bool1,bool2,bool3 = True,True,True
    for i in range(A,C):
        if SB[i-1]=="#" and SB[i]=="#":
            bool1 = False
            break
    for i in range(A,C):
        if SA[i-1]=="#" and SA[i]=="#":
            bool2 = False
            break
    SA[B-1]="."
    for i in range(B,D):
        if SA[i-1]=="#" and SA[i]=="#":
            bool3 = False
            break
    if bool1 or(bool2 and bool3):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
print("YES")

Submission status: Wrong Answer

Solution code:
# coding:utf-8


def main():
    N, A, B, C, D = map(int, input().split())
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    iwa = "#"
    S = input()
    ans = True
    canexchange = False

    exchagable_list = []
    for i in range(N-2):
        temps = S[i:i+3]
        if temps == "...":
            exchagable_list.append(i)

    if len(exchagable_list) > 0:
        for i in exchagable_list:
            if i >= B and i+1 <= min(C, D):
                canexchange = True
    # print(canexchange)
    for i in range(N-1):
        if S[i] == iwa and S[i+1] == iwa:
            if not (i+1 < A or i > max(C, D)):
                ans = False

    if ans:
        if C < D:
            ans = True
        elif C > D and canexchange:
            ans = True
        elif C > D and not canexchange:
            if S[D-1] == iwa or S[D+1] == iwa:
                ans = False
            else:
                ans = True

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


if __name__ == "__main__":
    main()

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-1].count("...") > 0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

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

def solveSimple(s, a, b, c, d):
    if b > d:
        b, d = d, b
    if a > c:
        a, c = c, a
        
    if '##' in s[b-1:d]:
        return False 
    if '##' in s[a-1:c]:
        return False
    return True

import re
def solveDifficult(s, a, b, c, d):
    center = (a+b)//2
    spot = [m.start() for m in re.finditer('\.\.\.', s)]
        
    if len(spot) == 0:
        return False

    for i, it in enumerate(spot):
        if it > center:
            break

    exchange = []
    if i == 0:
        exchange.append(i)
    else:
        exchange.append(i)
        exchange.append(i-1)

    for it in exchange:
        if solveSimple(s, a, b, it, it+1) and solveSimple(s, it, it+1, c, d):
            return True
    return False

# simple 
if c < d:
    ans = solveSimple(s, a, b, c, d)
    
# solveDifficult
else:
    ans = solveDifficult(s, a, b, c, d)
    
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from sys import stdin
def main():
    N,A,B,C,D = map(int, stdin.readline().rstrip().split())
    S = stdin.readline().rstrip()
    Slist = list(S)
    A = A-1
    B = B-1
    C = C-1
    D = D-1
    
    # 前提 A Bはゴールよりも右にいると不可能
    if (C < A or D < B):
      print("No")
      return
    
    # 連続岩チェック
    index = -1
    while True:
      index = S.find('##', index + 1)
      if (index == -1) or (C < index and D < index):
        break
      if (A < index and index < C) or (B < index and index < D):
        print('No')
        return
    
    # 初期位置チェック
    if D-B==2 and Slist[B+1] =='#' and A < B and D < C:
        print('No')
        return
    if C-A==2 and Slist[A+1] =='#' and B < A and C < D:
        print('No')
        return
    if (B < A) and (Slist[C-1] =='#' and (A == C-2 or (A==C-3 and Slist[C-4]=="#") or (A==C-5 and Slist[C-4]=="#"))):
        print("No")
        return
    if (A < B) and (Slist[D-1] =='#' and (B == D-2 or (B==D-3 and Slist[D-4]=="#") or (B==D-5 and Slist[D-4]=="#"))):
        print("No")
        return
                                          
    print('Yes')

input = lambda: stdin.readline()
main()

Submission status: Wrong Answer

Solution code:
from collections import deque

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 == '#']
flag = False

que = deque([(A, B)])
while que:
    A, B = que.popleft()
    if (A, B) == (C, D):
        flag = True
        break
    for i in [1, 2]:
        if B <= D and A + i <= C and (A + i) not in blocks:
            que.append((A+i, B))
        if A <= C and B + i <= D and (B + i) not in blocks:
            que.append((A, B+i))

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
flag=0
span=0
buf=-5
if(c<d):
    for i in range(a-1,d):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
else:
    for i in range(a-1,c):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
        elif s[i]=='#' :
            buf=max([span,buf])
            span=0
        elif b-1<i<d:
            span+=1
    if buf<=2:
        flag=1
        #print(buf)
print('No' if flag==1 else 'Yes')

Submission status: Wrong Answer

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

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
flg = True
if S[C - 1] == '#' or S[D - 1] == '#': flg = False
for i in range(A, int(max(C, D))):
    if S[i] == '#' and S[i + 1] == '#':
        flg = False
        break

if C == D: flg = False
if C > D:
    threeFlg = True
    # /B./../ or B/../
    if not S[B-2] == '#' or S[B] == '#':
        threeFlg =False
    # ../../
    for k in range(B - 1, D - 3):
        if S[k] == '#':
            if not S[k + 3] == '#':
                threeFlg = False
                break
    # ../.D/ or ../.D
    if threeFlg:
        if (D - 1 - S.find('#', B - 1)) % 3 == 2:
            if D == N or S[D] == '#':
                flg = False
        else:
            flg = False

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

Submission status: Wrong Answer

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

    s.insert(0, '.')

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

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

    print("Yes")

test()

Submission status: Wrong Answer

Solution code:
class KenkenRace:
    def __init__(self):
        N, A, B, C, D = map(int, input().split())
        S = [str(c) for c in input()]

        self.N = N
        self.A = A
        self.B = B
        self.C = C
        self.D = D
        self.S = S

    def main(self):
        result = False

        # C < D のとき
        if self.C < self.D:
            # クリアできるか確かめる
            result = self.__canClear__(self.D)

        # D < C のとき
        else:
            # 追い越せるかどうかを確かめる and クリアできるか確かめる
            result = self.__canClear__(self.C) and self.__canOvertake__(self.D)

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

    def __canClear__(self, higher):
        isDouble = False
        preObject = ""
        for i in range(self.A - 1, higher):
            c = self.S[i]
            if c == "#" and preObject == "#":
                isDouble = True
                break
            else:
                preObject = c

        return not isDouble

    def __canOvertake__(self, lower):
        isTriple = False
        objectCount = 0
        severalCount = 0

        for i in range(self.A - 1, lower):
            c = self.S[i]
            objectCount += 1

            # 何もない箇所が何連続目か, カウント
            if c == ".":
                severalCount += 1
            else:
                severalCount = 0

            if objectCount == lower:
                # この位置 or 次の位置で3連続でない場合, 追い越せない
                if severalCount < 2:
                    break
                elif severalCount == 2 and self.S[i + 1]:
                    isTriple = True
                    break

            # 3連続で何もなければ追い越し可能か
            if severalCount == 3:
                isTriple = True
                break

        return isTriple


kenkenRace = KenkenRace()
kenkenRace.main()

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-2,D+2):
    a += 1
    if S[n] == "#":
      distance_2.append(a)
      a = 0
  if max(distance_2) < 4:
    answer = 0
if answer == 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, a, b, c, d = map(int, input().split())
s = input()
grid = []
for rock in s:
    grid.append(rock == '#')

if grid[c-1] or grid[d-1]:
    print('No')

max_none_count = 0
max_rock_count = 0
none_count = 0
rock_count = 0
if c < d:
    for i in range(a-1, d):
        if grid[i]:
            none_count = 0
            rock_count += 1
        else:
            rock_count = 0

        max_none_count = max(max_none_count, none_count)
        max_rock_count = max(max_rock_count, rock_count)

    if max_rock_count >= 2:
        print('No')
    else:
        print('Yes')
elif c > d:
    max_rock_count = 0
    rock_count = 0
    # Dの位置は岩として考える
    grid[d-1] = True
    canSkip = False
    for i in range(a-1, c):
        if grid[i]:
            rock_count += 1
        else:
            if b - 1 <= i and i <= c - 2 and not grid[i-1] and not grid[i] and not grid[i+1]:
                canSkip = True
            rock_count = 0

        max_rock_count = max(max_rock_count, rock_count)

    if max_rock_count <= 1 and canSkip:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
# sample code

v = list(map(int, input().split()))
n, a, b, c, d = v[0], v[1], v[2], v[3], v[4]
s = input()

ac_cnt_1, ac_max_1 = 0, 0
bd_cnt_1, bd_max_1 = 0, 0
bd_cnt_0, bd_max_0 = 0, 0

for i in range(c-a-1):
	j = i+a
	if s[j] == '#':
		ac_cnt_1 += 1
		if ac_max_1 < ac_cnt_1:
			ac_max_1 = ac_cnt_1
	else:
		ac_cnt_1 = 0
for i in range(d-b-1):
	j = i+b
	if s[j] == '#':
		bd_cnt_0 = 0
		bd_cnt_1 += 1
		if bd_max_1 < bd_cnt_1:
			bd_max_1 = bd_cnt_1
	else:
		bd_cnt_0 += 1
		bd_cnt_1 = 0
		if bd_max_0 < bd_cnt_0:
			bd_max_0 = bd_cnt_0

if c < b:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1):
		print('Yes')
	else:
		print('No')
elif c < d:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1):
		print('Yes')
	else:
		print('No')
else:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1) and (bd_max_0 >= 3):
		print('Yes')
	else:
		print('No')

Submission status: Wrong Answer

Solution code:
import sys
import copy

def solve(n, a, b, c, d, s):
    if c < d:
        if b < c:
            width = [(a-1, d-1)]
        else:
            width = [(a-1, c-1), (b-1, d-1)]

        for left, right in width:
            for i in range(left, right):
                if s[i] == "#" and s[i+1] == "#":
                    return "No"
                else:
                    return "Yes"
    else:
        for i in range(a-1, c-1):
            if s[i] == "#" and s[i+1] == "#":
                return "No"
            elif b - 2 <= i <= d - 2 and s[i] == "." and s[i+1] == "." and  s[i+2] == "." :
                return "Yes"
        return "No"


if __name__ == '__main__':

    n, a, b, c, d = map(int, sys.stdin.readline().strip().split(" "))
    s = sys.stdin.readline().strip()
    print solve(n, a, b, c, d, s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

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

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

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

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

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

print('No')
sys.exit()

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
A -= 1
B -= 1
C -= 1
D -= 1
S = list(input())
if (A < B < D < C):
    cnt = 0
    cntl = [0]
    for i in range(A+1,C):
        if (S[i] == '.') & (S[i+1] == '.'):
            cnt += 1
            if i == C-1:
                cntl.append(cnt)
        elif (S[i] == '.') & (S[i+1] == '#'):
            cntl.append(cnt)
            cnt = 0
    if max(cntl) < 2:
        print('No')
    else:
        cnt = 0
        cntL = [0]
        for i in range(B+1,D-1):
            if (S[i] == '#') & (S[i+1] == '#'):
                cnt += 1
                if i == C-1:
                    cntL.append(cnt)
            elif (S[i] == '#') & (S[i+1] == '.'):
                cntL.append(cnt)
                cnt = 0
        if max(cntL) >= 1:
            print('No')
        else:
            if (S[D+1] == '.')&(S[D-1] == '.'):
                if (S[B+1] == '.')&(S[B-1] == '.'):
                    print('Yes')
                else:
                    x = 0
                    xl = [0]
                    for i in range(B+1,D-1):
                        if (S[i] == '.') & (S[i+1] == '.'):
                            x += 1
                            if x == D-2:
                                xl.append(x)
                        elif (S[i] == '.') & (S[i+1] == '#'):
                            xl.append(x)
                    if max(xl) >= 2:
                        print('Yes')
                    else:
                        print('No')
            elif S[D-1] == '#':
                x = 0
                xl = [0]
                for i in range(B-1,D-2):
                    if (S[i] == '.') & (S[i+1] == '.'):
                        x += 1
                        if i == D-3:
                            xl.append(x)
                    elif (S[i] == '.') & (S[i+1] == '#'):
                        xl.append(x)
                if max(xl) >= 2:
                    print('Yes')
                else:
                    print('No')
            else:
                x = 0
                xl = [0]
                for i in range(B-1,D-1):
                    if (S[i] == '.') & (S[i+1] == '.'):
                        x += 1
                        if x == D-2:
                            xl.append(x)
                    elif (S[i] == '.') & (S[i+1] == '#'):
                        xl.append(x)
                if max(xl) >= 2:
                    print('Yes')
                else:
                    print('No')
else:
    cnt = 0
    cntl = [0]
    for i in range(A+1,C):
        if (S[i] == '#') & (S[i+1] == '#'):
            cnt += 1
            if i == C-1:
                cntl.append(cnt)
        elif (S[i] == '#') & (S[i+1] == '.'):
            cntl.append(cnt)
            cnt = 0
    if max(cntl) >= 1:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
s = list(input())
k = 1
cnt = 0
while k ==1:
  k = 0
  for i in range(len(s)-2):
    if s[i:(i+3)] == ['A','B','C']:
      s[i:(i+3)] = ['B','C','A']
      cnt += 1
      k = 1
print(cnt)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict


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


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

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

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

Submission status: Wrong Answer

Solution code:
#!/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):
            print(YES)
            sys.exit()
        
        if(D < C and S[B-1:D].count('...') == 0):
            print(NO)
        # elif()
        else:
            print(YES)
    else:
        print(NO)
    return


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

S = list(input().split()[0])

result = "Yes"

if C < D:
    for i in range(B, D - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
else:
    for i in range(B, C - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
print(result)

Submission status: Wrong Answer

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

flag3 = 0
flagno = 0

if c > d:

    for i in range(a,c-3):

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

    if flagno == 0:

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

    else:
        print("No")

else:

    for i in range(a,d-3):

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

    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = list(map(int,input().split()))
s = input()
check = [[0]*(n+1) for _ in range(n+1)]
check[a][b] = 1

for i in range(a,n+1):
    for j in range(b, n+1):
        # A, Bは同じ場所に入れない
        if i == j:
            continue
        # 岩がある場所には入れない
        if s[i-1] == '#' and s[j-1] == '#':
            continue
        # 遷移元があればtrue
        if check[i-1][j] or check[i-2][j] or check[i][j-1] or check[i][j-2]:
            check[i][j] = 1
print('YES' if check[c][d]==1 else 'NO')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
S = input()
slist = list(S)
buf = "".join(slist[A:max(C,D)-1])
#print(N, A, B, C, D)
#print(S)

judge = buf.find("##")
#print(judge)

#print(slist[A::])
#print(judge)
if judge != -1:
  print("No")
else:
  if C < D:
    print("Yes")
  else:
    s_change= "".join(slist[A:C-1])
    #print(s_change)
    judge = s_change.count("..")
    #print(judge)
    if judge > 1:
      print("Yes")
    else:
      print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if '##' in S:
    print("No")
    quit()

if C > D:
    if '...' not in S[B:C]:
        print("No")
        quit()
    if S[B:C].count('...') % 2 == 1:
        print("No")
        quit()
    if C - D == 2 and S[C - 2] == '#' and S[D - 2] == '#':
        print("No")
        quit()

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] == "." and S[B+1] == ".":
    print("Yes")

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

print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = [int(i) for i in input().split()]
S = input()

def solve():
    ac, bd = S[A - 1:C], S[B - 1:D]
    if A < B < D < C:
        return ("..." in ac and "##" not in ac)
    else:
        return ("##" not in ac and "##" not in bd)

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

Submission status: Wrong Answer

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

for k in range(min(A,B)-1,max(C,D)-1):
    if S[k] == S[k+1] == "#":
        print("No")
        exit(0)

if C < D:
    print("Yes")
    exit(0)
for k in range(max(A,B)-1,N-2):
    if S[k] == S[k+1] == S[k+2] == ".":
        if k+2 <= D and k+3 <= C:
            print("Yes")
            exit(0)
print("No")
exit(0)

Submission status: Wrong Answer

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

def checker(start, end, S):
    check_rock = 0
    check_emp = 0
    M = "Only"
    for i in range(start, end):
        if S[i] == ".":
            check_emp += 1
            check_rock = 0
            if check_emp == 3:
                M = "Yes"
        else:
            check_rock += 1
            check_emp = 0
            if check_rock == 2:
                return "No"
    return M


checkB = checker(B, D, S)
checkA = checker(A, C, S)

if C > D:
    if checkA == "No" or checkB == "No" or (checkB == "Only" and S[B-2] == "#"):
        print("No")
    else:
        print("Yes")
else:
    if checkA == "No" or checkB == "No":
        print("No")
    else:
        print("Yes")