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()
#ans = 'Yes'
if C<D:
    ans = 'Yes' 
else:
    if s[B-2:D].count('...')>0:
        ans = 'Yes'
#    elif D-B == 1:
#        ans = 'No'
#    elif D-B == 2: 
#        if s[B-2:D].count('#')!=0:
#            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())
a, b, c, d = a-1, b-1, c-1, d-1
s = input()
if "##" in s:
    print("No")
elif c < d:
    print("Yes")
elif "..." in s[b-1:d+2]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
length, a, b, c, d = [int(i) for i in input().split()]
road = input()

e = []
e.append(a)
e.append(b)
e.append(c)
e.append(d)

road = road[min(e) - 1:max(e) - 1]
roada = road[a-1:c]
roadb = road[b-1:d]
roadc = road[a-2:d+1]

if '##' in roada and '##' in roadb:
    print('No')
if d > c:
    print('Yes')
else:
    if '...' in roadc:
        print('Yes')
    else:
        print('No')

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 - 2):D]:
        print('Yes')
    else:
        print('No')

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.A, self.C) and self.__canClear(self.B, self.D)

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

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

    def __canClear(self, start, end):
        isDouble = False
        preObject = ""

        for i in range(start - 1, end):
            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.B - 2, 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:
# -*- coding: utf-8 -*-
# agc034/agc034_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, A, B, C, D = i2nn()
    S = i2s()
    if '##' not in S[B-1:D] and '##' not in S[A-1:C]:
        if C < D:
            print('Yes')
        elif  '...' in S[B-1:D+1]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
    return

main()

Submission status: Wrong Answer

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from copy import copy
import numpy as np
from numpy.fft import fft, ifft
from fractions import gcd


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


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


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

n, a, b, c, d = MAP()
s = list(input())

lis3  =[]
lis_iwa=[]

tmp3 = []
tmp_iwa=[]
for i in range(n):
    #print(s[i])
    if s[i] =='.':
        tmp3.append(i)
        if len(tmp_iwa) > 1:
            tmp1 = tmp_iwa.copy()
            lis_iwa.append(tmp1)
            
        tmp_iwa.clear()
    else:
        tmp_iwa.append(i)
        if len(tmp3) > 2:
            tmp=tmp3.copy()
            lis3.append(tmp)
               
        tmp3.clear()
    
    #print(tmp3)


if len(tmp3) > 2:
    lis3.append(tmp3)
if len(tmp_iwa) > 1:
    lis_iwa.append(tmp_iwa)

#print(lis3, lis_iwa)

flag = 0

lis3 = [x for x in lis3 if x[0] > a - 1 and x[-1] < min(c, d) - 1]

lis_iwa = [x for x in lis_iwa if x[0] > a - 1 and x[-1] < max(c,d) - 1]

if lis_iwa == []:
    if c < d:
        print('Yes')
    else:
        if lis3 != []:
            print('Yes')
        else:
            print('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] > b) or (i[1] > b and i[1] < d) or 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:
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 s[a-1:c-1].find("##")==-1 and s[b-1:d-1].find("##")==-1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
rock = 0
brank = 0
rfrag = 0
bfrag = 0
mrock = 0
mbrank = 0
rlist = []
blist = []
for i in range(n):
    if s[i] == "#":
        if bfrag == 1:
            if brank >= 3:
                blist.append(i-brank+1)
            if mbrank < brank:
                mbrank = brank
                brank = 0
            brank = 0
        rock += 1
        rfrag = 1
    if s[i] == ".":
        if rfrag == 1:
            if rock >= 2:
                rlist.append(i-rock+1)
            if mrock < rock:
                mrock = rock
                rock = 0
            rock = 0
        brank += 1
        bfrag = 1
if mrock < mbrank:
    if brank >= 3:
        blist.append(n-brank+1)
    if mbrank < brank:
        mbrank = brank
        brank = 0    
else:
    if mrock < rock:
        mrock = rock
        rock = 0

p = 0
for i in range(len(rlist)):
    if a < rlist[i] < c or b <  rlist[i] < d:
        print("No")
        p = 1
        break

y = 0 
if d < c and p == 0:
    x = 0
    for i in range(len(blist)):
        if b < blist[i] < d:
            x = 1            
    if x == 1:
        print("Yes")
        y = 1
    elif x == 0:
        print("No")
        y = 1
        
if p == 0 and y == 0:
    print("Yes")

Submission status: Wrong Answer

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

flag = 1

def main():
    for i in range(len(s[b:d-2])):
        if s[i:i+2] == "##":
            return "No"
    for i in range(len(s[a:c-2])):
        if s[i:i+2] == "##":
            return "No"

    if c < d:
        return "Yes"
    
    elif c > d:
        if s[b] == "#":
            for i in range(len(s[b:c-3])):
                if s[i:i+3] == "...":
                    return "Yes"            
            return "No"

        else: #s[d] == "."
            if s[b-1] == ".":
                return "Yes"
            else:
                for i in range(len(s[b:c-3])):
                    if s[i:i+3] == "...":
                        return "Yes"
            return "No"

print(main())

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.A, self.C) and self.__canClear(self.B, self.D)

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

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

    def __canClear(self, start, end):
        isDouble = False
        preObject = ""

        for i in range(start - 1, end):
            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.B - 2, 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()
v=0
for i in range(n-2):
    if c<d:
        if i>b and i<d and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break

    
    elif c>d:
        if i>b 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 c<d and v==0:
    print('Yes')
    
if c>d and v==0:
    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[4]):
        if S[i:i+2]=="##":
            ans="No"
            break
    #更にAも行かせてみる
    for i in range(lis[1],lis[4]):
        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:
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'

# 3つ以上の空間があれば順序を入れ替えられる
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'

# 連続して岩があるとき（＝解けない）
for i in range(N - 1):
        
    if ss[i] == 1  and ss[i+1] == 1 :
        ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
rock = 0
brank = 0
rfrag = 0
bfrag = 0
mrock = 0
mbrank = 0
rlist = []
blist = []
for i in range(n):
    if s[i] == "#":
        if bfrag == 1:
            if brank >= 3:
                blist.append(i-brank+1)
            if mbrank < brank:
                mbrank = brank
                brank = 0
            brank = 0
        rock += 1
        rfrag = 1
    if s[i] == ".":
        if rfrag == 1:
            if rock >= 2:
                rlist.append(i-rock+1)
            if mrock < rock:
                mrock = rock
                rock = 0
            rock = 0
        brank += 1
        bfrag = 1
if mrock < mbrank:
    if brank >= 3:
        blist.append(n-brank+1)
    if mbrank < brank:
        mbrank = brank
        brank = 0    
else:
    if mrock < rock:
        mrock = rock
        rock = 0

p = 0
for i in range(len(rlist)):
    if a < rlist[i] < c or b <  rlist[i] < d:
        print("No")
        p = 1
        break

y = 0 
if d < c and p == 0:
    x = 0
    for i in range(len(blist)):
        if b < blist[i] < d:
            x = 1            
    if x == 1:
        print("Yes")
        y = 1
    elif x == 0:
        print("No")
        y = 1
        
if p == 0 and y == 0:
    print("Yes")
print(blist, rlist)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# agc034/agc034_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, A, B, C, D = i2nn()
    S = i2s()
    if '##' not in S[B-1:D] and '##' not in S[A-1:C]:
        if C < D:
            print('Yes')
        elif  '...' in S[B:D+1]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
    return

main()

Submission status: Wrong Answer

Solution code:
import sys

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

S = input()

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

# 追い越す必要がある場合
p = 0
if A < B and C > D:
    p = 1

if C > D:
    for i in range(B,min(C,D)):
        if S[i:i+3] == '...':
            print('YES')
            sys.exit()

print('NO')

Submission status: Wrong Answer

Solution code:
length, a, b, c, d = [int(i) for i in input().split()]
road = input()

e = []
e.append(a)
e.append(b)
e.append(c)
e.append(d)

road = road[min(e) - 1:max(e) - 1]
roada = road[a-1:c]
roadb = road[b-1:d]
roadc = road[a-1:d]

if '##' in roada and '##' in roadb:
    print('No')
if d > c:
    print('Yes')
else:
    if '...' in roadb:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
a, b, c, d = a-1, b-1, c-1, d-1
s = input()
if "##" in s:
    print("No")
elif c < d:
    print("Yes")
elif "..." in s[b: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")
    exit()

if C > D:
    if "..." in S[B-2:D+2]:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import math
import numpy as np


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


def main():
    _, A, B, C, D = inputs()
    S = input()
    maxDst = max(C, D)
    courseA = S[A:C]
    courseB = S[B:D]
    cnt = 0
    ans = []
    for i in courseB:
        if i == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            ans.append(False)
            break
    else:
        ans.append(True)
    cnt = 0
    for i in courseA:
        if i == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            ans.append(False)
            break
    else:
        ans.append(True)
    if maxDst == C:
        cnt = 0
        for i in S[B-1:D+2]:
            if i == '.':
                cnt += 1
            if cnt == 3:
                ans.append(True)
                break
        else:
            ans.append(False)

    if all(ans):
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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(A - 1, B-3):D]:
        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")
    exit()

if C > D:
    if "..." in S[B-3:D+2]:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
if "##" in s[a:d]:
  print("No")
  exit()
elif c > d:
  if "..." in s[b:d-1]:
    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()
if '##' in S[a:c]:
	print('No')
elif d < c and not '...' in S[b-2:d+1]:
        print('No')
else:
    print('Yes')

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[4]):
        if S[i:i+2]=="##":
            ans="No"
            break
    #更にAも行かせてみる
    for i in range(lis[1],lis[4]):
        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]-1):
        if S[i:i+2]=="##":
            ans="No"
            break
    #先にBを行かせる。まず可能か判定
    if ans=="No":
        ans="Yes"
        for i in range(lis[2],lis[4]-1):
            if S[i:i+2]=="##":
                ans="No"
                break
        for i in range(lis[2],lis[4]-2):
            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]-1):
                if S[i:i+2]=="##":
                    ans="No"
                    break
        if memo==0:
            ans="No"
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

A -= 1
B -= 1
C -= 1
D -= 1

for i in range(A, max(C,D)):
    if S[i] == '#' and S[i+1] == '#':
        print('No')
        exit()
if C > D:
    for i in range(B, D):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.' and B <= i+1:
            print('Yes')
            exit()
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys

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

S = input()

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

# 追い越す必要がある場合
p = 0
if A < B and C > D:
    p = 1

if C > D:
    for i in range(B,min(C,D)):
        if S[i:i+3] == '...':
            print('YES')
            sys.exit()

print('NO')

Submission status: Wrong Answer

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

if "##" in S:
    print("No")
    exit()

if C > D:
    if "..." in S[B-2:D]:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

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

  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'

  return 'Yes'

print(main())

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())
 
ans = 'Yes'
if C < D:
    for i in range(A , C):
        if S[i] == '#' and S[i + 1] == '#':
            ans = 'No'
            break
    for i in range(B, D):
        if S[i] == '#' and S[i + 1] == '#':
            ans = 'No'
            break
else:
    for i in range(A, C):
        if S[i] == '#' and S[i + 1] == '#':
            ans = 'No'
            break
    for i in range(B, D):
        if S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
            break
    else:
        ans = 'No'
            
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
if "##" in s[a:d]:
  print("No")
  exit()
elif c > d:
  if "..." in s[b:d]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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] > b) or (i[1] > b and i[1] < d) or 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:
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[4]):
        if S[i:i+2]=="##":
            ans="No"
            break
    #更にAも行かせてみる
    for i in range(lis[1],lis[4]):
        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]):
            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:
# -*- coding: utf-8 -*-

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

if '##' in S[A:]:
    print('No')
elif C<D:
    print('Yes')
else:
    if '...' in S[B-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")
    exit()

if C > D:
    if "..." in S[B-2:D+1]:
        print("Yes")
    else:
        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):D]:
        print('Yes')
    else:
        print('No')