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=list(input())

i=0
j=0
gg=0
nnt=0
if c<d:
    i=a-1
    while i!=n:
        if s[i]=="#":
            j=j+1
        else:
            j=0
        if j==2:
            nnt=1
            break
        i=i+1

else:
    i=a-1
    nnt=1
    while i!=n:

        if s[i]==".":
            gg=gg+1
        else:
            gg=0
        if gg==3:
            if i>b:
                nnt=0
                break


        if s[i]=="#":
            j=j+1
        else:
            j=0
        if j==2:
            nnt=1
            break

        i=i+1
if nnt==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
s2=s[min(a,b)-1:max(c,d)]
n2=len(s2)
if c<d:
    for i in range(n2-1):
        if s2[i]=="#" and s2[i+1]=="#" and not(c-1<i and i<b-1):
            print("No")
            import sys
            sys.exit()
    print("Yes")
else:
    p=0
    for i in range(n2-2):
        if s2[i]=="." and s2[i+1]=="." and s2[i+2]==".":
            p=1
        if s2[i]=="#" and s2[i+1]=="#":
            print("No")
            import sys
            sys.exit()
    if p==1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys

fin = sys.stdin.readline
N, A, B, C, D = [int(elem) for elem in fin().split()]
cell_list = fin().split()[0]

init_max = max(A, B)
init_min = min(A, B)
end_max = max(C, D)
end_min = min(C, D)

after_min_cells = cell_list[init_min:end_max-1]
after_max_cells = cell_list[init_max:end_min]
# 途中に#が2つ連続しないか
if '##' in after_min_cells:
    result = 'No'
# 入れ替えが必要かどうか
elif (A-B) * (C-D) < 0:
    # 途中に.が3つ連続するかどうか（＝入れ替えが可能かどうか）
    if '...' in after_max_cells:
        result = 'Yes'
    else:
        result = 'No'
else:
    result = 'Yes'

print(result)

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):
    A -=1
    B -=1
    C-=1
    D -=1
    
    S_original = S
    S = list(S_original)

    flag = False
    # case1
    S[C] = '#'
    S[B] = '#'

    S = ''.join(S)
    if '##' in S[A+1:C]:
        pass
    elif '##' in S[B+1:D]:
        pass
    else:
        flag = True

    # case2
    S = list(S_original)

    S[D] = '#'
    S[A] = '#'

    S = ''.join(S)
    if '##' in S[A+1:C]:
        pass
    elif '##' in S[B+1:D]:
        pass
    else:
        flag = True


    # case 3
    S = list(S_original)

    S = ''.join(S)
    if '...' in S[B:C]:
        if '##' in S[A+1:C]:
            pass
        elif '##' in S[B+1:D]:
            pass
        else:
            flag = True
    

    if flag == True:
        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 = input()
ans = ""
if c > b:
    if "##" in s[a-1:]:
        ans = "No"
    elif c > d and not("..." in s[b-2:d]):
        ans = "No"
    else:
        ans = "Yes"
else:
    if "##" in s[a-1:c-1]:
        ans = "No"
    elif "##" in s[b-1:d-1]:
        ans = "No"
    else:
        ans = "Yes"

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
#n=int(input())
n,a,b,c,d=map(int,input().split())
#a=[int(i) for i in input().split()]
s='_'+input()
ai=0
ans=['Yes','No']

#print(s,n,a,b,c,d)

def CanGo(x,y):
    cnt=0
    root=s[x:y]
    for c in root:
        if c=='#':
            cnt+=1
        elif c=='.':
            if cnt>2:
                return False
            cnt=0
    return True


def CanPass(x,y):  #(b,d)
    root=s[x:y+1]
    q=s[x:x+4]
    #print(root,len(root)-4)
    for i in range(len(root)-4):
        if q=='..#.' or  q=='.#..':
            return True
        q=q[1:4]+s[x+4+i]
    return False
        


if c<d:
    if CanGo(b,d) and CanGo(a,c):
        ai=0
    else:
        ai=1
elif c>d:
    if CanGo(b,d) and CanGo(a,c) and CanPass(b,d):
        ai=0
    else:
        ai=1
    
    

print(ans[ai])

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
a= input()
f = 0
s = 0
d = 1
t = []
k = []

f1 = 0
s1 = 0
d1 = 1
t1 = []
k1 = []


for i in a[A-1:]:
    if i == "." and f ==1:
        k.append(d)
        s = 1
        f = 0
    elif i == ".":s+=1
    
    elif i == "#" and f==0:
        t.append(s)
        d = 1
        f = 1
    elif i == "#":d+=1
else:
    if f==1:
        k.append(d)
    else:
        t.append(s)
for i in a[B-1:]:
    if i == "." and f1 ==1:
        k1.append(d1)
        s1 = 1
        f1 = 0
    elif i == ".":s1+=1
    
    elif i == "#" and f1==0:
        t1.append(s1)
        d1 = 1
        f1 = 1
    elif i == "#":d1+=1
else:
    if f1==1:
        k1.append(d1)
    else:
        t1.append(s1)
# print(t,k)
# print(t1,k1)
if C < D :
    if len(k) == sum(k):
        print("Yes")
    else:
        print("No")
else:
    if len(k) == sum(k) and any([i > 2 for i in t1]):
        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:
    if '##' in s:
        print('No')
    else:
        print('Yes')
else:
    if a>b:#これはない
        if '##' in s:
            print('No')
        else:
            print('Yes')
    else:
        if b-1<0:
            print('No')
        else:
            if '...' in s[b-2:d]:
                if '##' in s:
                    print('No')
                else:
                    print('Yes')
            else:
                print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
left = min(A,B)-1
right = max(C,D)-1
l = max(A,B)-1
r = min(C,D)-1

if '##' in S[left:right]:
  print('No')
else:
  if C < D:
  	print('Yes')
  else:
    if '...' in S[l:r]:
      print('Yes')
    else:
      print('No')

Submission status: Wrong Answer

Solution code:
number_of_masu, firstsunuke, firstfunuke, lastsunuke, lastfunuke = map(int, input().split())
s = str(input())
tobenaiflag = 0
nukaseruflag = 0

for i in range(min(firstsunuke, firstfunuke), max(lastsunuke, lastfunuke)-1):
    if s[i] == '#' and s[i+1] == '#':
        tobenaiflag += 1
        break
if lastfunuke < lastsunuke:
    for j in range(max(firstsunuke, firstfunuke)-1, min(lastsunuke, lastfunuke)-1-1):
        if s[j] == '.' and s[j+1] == '.' and s[j+2] == '.':
            nukaseruflag += 1
            break
else:
    nukaseruflag += 1
if tobenaiflag == 0 and nukaseruflag == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

import sys

N, A, B, C, D = map(int, input().rstrip().split())
S = [x for x in input()]

if A < B and B < D and D < C:
    chain_rock = 0
    chain_empty = 0
    max_chain_empty = 0
    for i in range(B-1, D):
        if S[i] == '.':
            chain_empty += 1
            chain_rock = 0
        else:
            chain_empty = 0
            chain_rock += 1
            
        max_chain_empty = max(max_chain_empty, chain_empty)
        if chain_rock >= 2:
            print('No')
            sys.exit()
            
    if max_chain_empty < 3:
        print('No')
        sys.exit()
            
    chain_rock = 0
    for i in range(A, C):
        if S[i] == '#':
            chain_rock += 1
        else:
            chain_rock = 0
            
        if chain_rock >= 2:
            print('No')
            sys.exit()
            
else:
    chain_rock = 0
    for i in range(A, C):
        if S[i] == '#':
            chain_rock += 1
        else:
            chain_rock = 0
            
        if chain_rock >= 2:
            print('No')
            sys.exit()
            
    chain_rock = 0
    for i in range(B, D):
        if S[i] == '#':
            chain_rock += 1
        else:
            chain_rock = 0
            
        if chain_rock >= 2:
            print('No')
            sys.exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,a,b,c,d = f()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = input()

    has_2_consecu = 0
    for i in range(a+1, max(c,d)-1):
        if s[i]=='#' and s[i+1] == '#':
            has_2_consecu = 1
            break



    if has_2_consecu:
        print('No')
        return

    if d>c:
        print('Yes')
        return
    else:
        has_3_consecu = 0
        for i in range(b+1, d):
            if s[i]=='.' and s[i+1] == '.' and s[i+2]=='.':
                has_3_consecu = 1
                break
        
        if has_3_consecu:
            print('Yes')
            return
        
        if a+1 == b and s[b+1] == '.':
            print('Yes')
            return
    
    print('No')




solve()

Submission status: Wrong Answer

Solution code:
N,A,B,C,D =map(int,input().split())
S = input()[min(A,B):max(C,D) + 1]

if C < D:
  if not "##" in S[B:D] and not "##" in S[A:C]:
    print("Yes")
  else:
    print("No")
else:
  if not "##" in S[B:D] and not "##" in S[A:C] and ("..." in S[B if A + 1 != A else A:D + 1]):
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin

n, a, b, c, d = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()

# A..C 二つの岩 あったらだめ
# B..D二つの岩 あったらだめ
# D < Cのとき、 AがBを追い越せななかったらだめ

ans = "YES"

rock = 0
for i in range(a, c):
    if '#' == s[i-1]:
        rock += 1
        if rock >= 2:
            ans = "NO"
            break
    else:
        rock = 0

rock = 0
for i in range(b, d):
    if '#' == s[i-1]:
        rock += 1
        if rock >= 2:
            ans = "NO"
            break
    else:
        rock = 0


space = 0
if d < c:
    ok = 0
    for i in range(b, d):
        if '.' == s[i-1]:
            space += 1
            if space >= 3:
                ok = 1
    if '.' == s[d-1-1] and '.' == s[d+1-1]:
        ok = 1
    if 0 == ok:
        ans = "NO"

print(ans)

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):
    ret = YES
    if '##' in S[A - 1:C] or '##' in S[B - 1:D]:
        ret = NO
    else:
        if D < C:
            #if S[B - 2:B] == '..' or S[B - 1:B + 1] == '..':
            if not '...' in S[B - 2:D + 2]:
                ret = NO
    print(ret)
    return


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:
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    n, a, b, c, d = read_int_array()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = read() + b'###'
    if s[d] == '#' or s[c] == '#':
        print('NO')
    else:
        if c < d:
            while b < d:
                if b + 1 == d:
                    b += 1
                elif s[b+2] == '.':
                    b += 2
                elif s[b+1] == '.':
                    b += 1
                else:
                    print('NO')
                    return
            while a < c:
                if a + 1 == c:
                    a += 1
                elif s[a+2] == '.':
                    a += 2
                elif s[a+1] == '.':
                    a += 1
                else:
                    print('NO')
                    return
            print("YES")
        else:
            while a < c:
                if a + 1 == c:
                    if a + 1 == b:
                        if b + 1 == d:
                            b += 1
                        elif s[b + 2] == '.':
                            b += 2
                        elif s[b + 1] == '.':
                            b += 1
                        else:
                            print('NO')
                            return
                    a += 1
                elif s[a+1] == '.' and b != a + 1:
                    a += 1
                elif s[a+2] == '.' and b != a + 2:
                    a += 2
                elif a + 1 == b:
                    if s[a+2] == '.':
                        a += 2
                    elif s[a+3] == '.':
                        b += 2
                    else:
                        print("NO")
                        return
                elif a + 2 == b:
                    if s[a+3] == '.':
                        b += 1
                        a += 2
                    elif s[a+4] == '.':
                        b += 2
                        a += 2
                    else:
                        print("NO")
                        return
                else:
                    print('NO')
                    return
            if b > d:
                print("NO")
                return
            while b < d:
                if b + 1 == d:
                    b += 1
                elif s[b+2] == '.':
                    b += 2
                elif s[b+1] == '.':
                    b += 1
                else:
                    print('NO')
                    return
            print("YES")


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")


def read():
    return input()


def read_array(sep=None, maxsplit=-1):
    return read().split(sep, maxsplit)


def read_int():
    return int(read())


def read_int_array(sep=None, maxsplit=-1):
    return [int(a) for a in read_array(sep, maxsplit)]

# endregion

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

def check():
	for i in range(A + 1, C - 1):
		if S[i] == S[i + 1] == "#":
			return False

	for i in range(B + 1, D - 1):
		if S[i] == S[i + 1] == "#":
			return False
	
	if D < C:
		for i in range(B + 1, D + 1):
			if S[i - 1] == S[i] == S[i + 1] == ".":
				return True
		return False
	else:
		return True

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

Submission status: Wrong Answer

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

if not '##' in S[A:D]:
    if D<C:
        if '...' in S[B:C+1]:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bisectL

N, A, B, C, D = map(int, input().split())
S = input()
walls = []
prev = ''
for i, c in enumerate(S):
  if prev == '#' and c == '#':
    walls.append(i)
  prev = c

if bisectL(walls, A-1) == bisectL(walls, C-1) and bisectL(walls, B-1) == bisectL(walls, D-1):
  if C < D:
    print('Yes')
    exit()
  else:
    if '...' in S[B-2:D]:
      print('Yes')
      exit()
print('No')

Submission status: Wrong Answer

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

if(max([len(item) for item in s.split('.')])>1):
	print('No')
elif(c==d):
	print('No')
elif((a-b)*(c-d)>0):
	print('Yes')
else:
	if(max([len(item) for item in s.split('#')])>2):
		print('Yes')
	else:
		print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

import sys
import re

_,a,b,c,d = [ int(x)-1 for x in sys.stdin.readline().split() ]
m = sys.stdin.readline().strip()
if m[c]!="." or m[d]!=".":
    print( "NO" )
    exit()
#
loc= []
for match in re.finditer( "##",m ): loc.append( match.start() )
if c>d:
    if m[b+1:d+1].find("..")<0:
        print( "NO" )
        exit()
#
# check b->d
flag= False
ii= b+1
jj= d-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
if flag:
    print( "NO" )
    exit()
#
# check a->c
ii= a+1
jj= c-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
#
if flag:
    print( "NO" )
    exit()
#
print( "YES" )

Submission status: Wrong Answer

Solution code:
def inverse(a):
    return pow(a, mod - 2, mod)

def main():
    n,a,b,c,d = map(int, input().split())
    a -=1
    b -=1
    c -=1
    d -=1

    s = input()

    a_r = a
    cnt = 0
    for i in range(a, n):
        if s[i] == '#':
            cnt += 1
        else:
            cnt = 0
        a_r = i
        if cnt == 2:
            a_r = i - 2
            break

    b_r = a
    cnt = 0
    for i in range(b, n):
        if s[i] == '#':
            cnt += 1
        else:
            cnt = 0
        b_r = i
        if cnt == 2:
            b_r = i - 2
            break
    if a_r < c or b_r < d:
        print('No')
        return
    if c < d:
        print('Yes')
        return
    cnt = 0
    for i in range(b, c+1):
        if s[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt > 2:
            print('Yes')
            return

    if s[b-1] == '.' and s[b+1]:
        print('Yes')
    if d < n-1 and s[d-1] == '.' and s[d+1]:
        print('Yes')

    print('No')


main()

Submission status: Wrong Answer

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

if S.count('##') > 0:
    print('No')
else:
    if C < D:
        print('Yes')
    else:
        if S[B-2:D+1].count('...') > 0:
            print('Yes')
        else:
            print('No')

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):
        if i == 0:
            pass
        else:
            if Slist[i] == "#":
                Rock+=1
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0
    now = A-1
    Rock = 0
    for i in range(C-A):
        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):
        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
    aflag = 0
    for i in range(C-A):
        if i+now == D:
            aflag = 1
        if i == 0:
            mass+=1
        else:
            if Slist[i] == "#":
                Rock+=1
                if aflag < 2:
                    Maxmass = max(Maxmass,mass)
                    if aflag == 1:
                        aflag = 2
                mass = 0
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0
                mass+=1

    if Maxmass <= 2:
        flag = 1
    
    if flag == 1:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, input().split())
s = str(input())
if C < D:
    if "##" in s[A:C] or "##" in s[B:D]:
        print("No")
    else:
        print("Yes")
else:
    if "##" in s[A:C] or "##" in s[B:D]:
        print("No")
    else:
        if "..." in s[B:D+1]:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,sunke,hunke,Gs,Gh = IL()
s = S()

f = 0
for i in range(min(sunke,hunke)-1,max(Gs,Gh)):
    if f == 0:
        if s[i]=="#":
            f = 1
    else:
        if s[i]=="#":
            print("No")
            exit()
        else:
            f = 0

cnt = 0
cntf = 0
for i in range(max(sunke,hunke)-1,min(Gs,Gh)+1):
    if s[i]=="#":
        cnt = 0
    else:
        cnt += 1
    if cnt == 3:
        cntf = 1
        break

if (sunke < hunke) and (Gs > Gh):
    if cntf == 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()
bn=b-1
bflg=False
while True:
    if bn==d-1:
        bflg=True
        break
    if s[bn+1]=='.':
        bn+=1
        continue
    elif s[bn+2]=='.':
        bn+=2
        continue
    else:
        break
if not bflg:
    print('No')
    exit()

if c>d:
    if s[b:bn].count('..')==0:
        if s[b-2]=='#' or s[b]=='#':
            print('No')
            exit()

an=a-1
aflg=False
while True:
    if an==c-1:
        aflg=True
        break
    if s[an+1]=='.':
        an+=1
        continue
    elif s[an+2]=='.':
        an+=2
        continue
    else:
        break
if not aflg:
    print('No')
    exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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

BLOCK=[0]*N
OPEN=[0]*N

for i in range(1,N):
    if S[i]=="#" and S[i-1]=="#":
        BLOCK[i]=1

for i in range(2,N):
    if S[i]==S[i-1]==S[i-2]==".":
        OPEN[i]=1

LEFT_A=0
for i in range(A,-1,-1):
    if BLOCK[i]==1:
        LEFT_A=i
        break

RIGHT_A=N-1
for i in range(A,N):
    if BLOCK[i]==1:
        RIGHT_A=i
        break
        
LEFT_B=0
for i in range(B,-1,-1):
    if BLOCK[i]==1:
        LEFT_B=i
        break

RIGHT_B=N-1
for i in range(B,N):
    if BLOCK[i]==1:
        RIGHT_B=i
        break

if LEFT_A+1<=C<=RIGHT_A+1 and LEFT_B+1<=D<=RIGHT_B+1:
    if LEFT_A==LEFT_B and RIGHT_A==RIGHT_B:
        for j in range(B+1,min(C,D)):
            if OPEN[j]==1:
                print("Yes")
                sys.exit()
        else:
            if A<B and C<D:
                print("Yes")
            elif A>B and C>D:
                print("Yes")
            else:
                print("No")

    else:
        print("Yes")

else:
    print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
# import re
import sys
# print(S.count("##"))
if S.count("##"):
    print("No")
    sys.exit()
if (A < B) and (C > D):
    if not S[B:D-1].count("..."):
        print("No")
        sys.exit()
if (A > B) and (C < D):
    if not S[A:C-1].count("..."):
        print("No")
        sys.exit()
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:c-1]:
    return 'No'
  if '##' in s[b:d-1]:
    return 'No'
  
  if d<c:
    if '...' not in s[a:c]:
      return 'No'

  return 'Yes'

print(main())

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input().strip()
for i in s:
  if i=='.':
    i=0
  else:
    i=1
cst=0
ans=0
for j in range(n):
    i=s[j]
    if i==0:
        if s[j-2]*s[j-1]==1:
            cst=1
    else:
        if s[j-1]==1:
            ans=1
if ans==1:
    print('No')
elif c>d and cst==0:
    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 A > B and C < D:
    p = 1

if p == 1:
    for i in range(max(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 = str(input())

if '##' in S:
    print('No')
elif (D < C) and ('...' not in S):
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
if C<D:
    for i in range(A-1,D-2):
        if S[i]=='#' and S[i+1]=='#':
            print('No')
            exit()
    print('Yes')
    exit()
elif C>D:
    for j in range(A-1,D-2):
        if S[j]=='#' and S[j+1]=='#':
            print('No')
            exit()
    if any(S[k-1]=='.' and S[k]=='.' and S[k+1]=='.' for k in range(B-1,D-1)):
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
def main():
    inp = input()
    st = inp.split()
    n = int(st[0])
    a = int(st[1])
    b = int(st[2])
    c = int(st[3])
    d = int(st[4])
    inp = input()
    # 2 rocks
    max_cd = c if c > d else d
    continuous_count = 0
    nothing_count = 0
    nothing_3 = False
    if inp[b-1] == '.':
        nothing_count += 1
    for i in range(b, max_cd):
        if inp[i] == '#':
            continuous_count += 1
            nothing_count = 0
        elif inp[i] == '.':
            continuous_count = 0
            nothing_count += 1
        if continuous_count == 2:
            print("No")
            return
        if nothing_count == 3 and i < d + 1:
            nothing_3 = True

    # c < d
    if c < d or nothing_3:
        print("Yes")
    else:
        print("No")
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n , a0 , b0 , c0 , d0 = map(int,input().split())
s = input()

# a < b に変換する
if a0 > b0 : # 入れ替える
    a = b0
    b = a0
    c = d0
    d = c0
else : # 入れ替えない
    a = a0
    b = b0
    c = c0
    d = d0

right = max(c,d)

for i in range(n-1) :
    if s[i] == '#' and s[i+1] == '#' : # 岩が2個連続である場合
        if i <= right - 2 :
            print('No')
            break
else :
    if c < d :
        print('Yes')
    else :
        for i in range(n-2) :
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' : # 入れ替え可能
                if i < d - 1 :
                    print('Yes')
                    break
        else :
            print('No')