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:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

n,a,b,c,d = m();
ss = list(input())
if c < d:
	k = s(ss[b-1:d])
	for i in range(len(k)):
		if k[i][0] == "#" and k[i][1] >= 2:
			print("No")
			exit()
	k = s(ss[a-1:c])
	for i in range(len(k)):
		if k[i][0] == "#" and k[i][1] >= 2:
			print("No")
			exit()
	print("Yes")
	exit()
else:
	# c > d
	count = 0
	k = s(ss[b-1:d])
	for i in range(len(k)):
		if k[i][0] == "#" and k[i][1] >= 2:
			print("No")
			exit()
		if k[i][0] == "." and k[i][1] >= 3:
			count = 1
	if count == 1:
		print("Yes")
		exit()
	else:
		ss[d-1] = "#"
		k = s(ss[a-1:c])
		for i in range(len(k)):
			if k[i][0] == "#" and k[i][1] >= 2:
				print("No")
				exit()
		print("Yes")
		exit()

Submission status: Wrong Answer

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

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

cnt_0, cnt_1 = 0, 0 # #
max_0, max_1 = 0, 0 # .

for moji in s:
	if moji == '#':
		cnt_0 = 0
		cnt_1 += 1
		if max_1 < cnt_1:
			max_1 = cnt_1
	else:
		cnt_0 += 1
		cnt_1 = 0
		if max_0 < cnt_0:
			max_0 = cnt_0

if c < d:
	if max_1 <= 1:
		print('Yes')
	else:
		print('No')
else:
	if (max_1 <= 1) and (max_0 >= 3):
		print('Yes')
	else:
		print('No')

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a, b, c, d = LI_()
    s = S()
    flg = False
    if c > d:
        for i in range(b+1,d-1):
            if s[i] == "." and s[i + 1] == "." and s[i - 1] == ".":
                flg = i
                break
        if not flg:
            print("No")
            return
    for i in range(a+1, max(c,d)-1):
        if s[i] == "#" and s[i + 1] == "#":
            print("No")
            return
    print("Yes")
    
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()

Submission status: Wrong Answer

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

if S.count('##') > 0:
    print('No')
else:
    if C < D:
        print('Yes')
    else:
        if S.count('...') > 0:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
def getlist():
	return map(int, input().split())

N, A, B, C, D = getlist()
S = list(input())

a = A - 1
b = B - 1
c = C - 1
d = D - 1

if c < b:
	judge1 = "YES"
	j = 0
	val = 0
	for i in range(a, c):
		if S[i] == ".":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j >= 2:
		judge1 = "NO"

	judge2 = "YES"
	j = 0
	val = 0
	for i in range(b, d):
		if S[i] == ".":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j >= 2:
		judge2 = "NO"

	if judge1 == "YES" and judge2 == "YES":
		print("Yes")
	else:
		print("No")


elif c < d:
	judge = "Yes"
	j = 0
	val = 0
	for i in range(a, d):
		if S[i] == ".":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j >= 2:
		judge = "No"
	print(judge)

else:
	judge1 = "YES"
	j = 0
	val = 0
	for i in range(a, c):
		if S[i] == ".":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j >= 2:
		judge1 = "NO"

	judge2 = "YES"
	j = 0
	val = 0
	for i in range(b, d + 1):
		if S[i] == "#":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j <= 2:
		judge2 = "NO"

	if judge1 == "YES" and judge2 == "YES":
		print("Yes")
	else:
		print("No")

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,a,b,c,d = na()
s = ns()

a-=1
b-=1
c-=1
d-=1
fla = 0
flb = 0
dou = True
tri = False if d < c else True

for i in range(a+1,max(c,d)+1):
    if s[i] == '.':
        fla = 0
        flb += 1
    else:
        fla += 1
        flb = 0
    if fla == 2:
        dou = False
    if flb == 3 and i <= d+1:
        tri = True

if dou and tri:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

i=0
j=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=b-1
    nnt=1
    while i!=n:

        if s[i]==".":
            j=j+1
        else:
            j=0
        if j==3:
            nnt=0
            break
        i=i+1
if nnt==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# A問題
N, A, B, C, D = map(int, input().split())
S = input()
flag = False

if C < D:   # AがBを飛び越えない時
    if S.count("##") > 0:
        flag = False
    else:
        flag = True
else:   # AがBを飛び越えるとき
    if S.count("##") > 0:
        flag = False
    else:
        if S.count("...") > 0:
            flag = True
        else:
            if S[D] == "#" or S[D-2] == "#":
                flag = False
            else:
                flag = True
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if c > b:
  if c < d:
    if "##" in s[a+1:d]:
      print('No')
    else:
      print('Yes')
  else:
    if (('##' in s[a+1:c]) or not('...' in s[b+1:d])):
      print('No')
    else:
      print('Yes')
else:
  if (('##' in s[a+1:c]) or ('##' in s[b+1:d])):
    print('No')
  else:
    print('Yes')

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 f():
    can_over = False

    prev_2 = ""
    prev_1 = ""
    for i in range(A, max(D, C) + 1):
        now = S[i]
        if prev_1 == "#" and now == "#":
            return False

        if prev_1 == prev_2 == now == ".":
            can_over = True

        prev_2, prev_1 = prev_1, now

    return can_over if D < C else True

print("Yes" if f() else "No")

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 :
            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')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
A-=1
B-=1
C-=1
D-=1
S=input()
l=[0]*N
r=[0]*N
stack=[A]
dx=[-2,-1,1,2]
while(stack):
    x=stack.pop()
    l[x]=1
    for d in dx:
        X=x+d
        if X<0 or N<=X or l[X]==1 or S[X]=="#":
            continue
        stack.append(X)
stack=[B]
dx=[1,2]
while(stack):
    x=stack.pop()
    r[x]=1
    for d in dx:
        X=x+d
        if X<0 or N<=X or r[X]==1 or S[X]=="#":
            continue
        stack.append(X)
if C>D:
    t=False
    for i in range(N-3):
        if S[i:i+3]=="..." and l[i]==1 and r[i+1]==1:
            t=True
            break
    if t:
        if l[C]==1 and r[D]==1:
            print("Yes")
            quit()
    print("No")
else:
    if l[C]==1 and r[D]==1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

ans = True

dp = [False]*n
dp[b-1] = True
# b→d
for i in range(b-1, d):
    if s[i] != ".":
        continue
    for j in range(1,3):
        if i+j < n:
            if s[i+j] != ".":
                continue
            if not dp[i+j]:
                dp[i+j] = dp[i]
if not dp[d-1]:
    ans = False


dp = [False]*n
dp[a-1] = True
# a→c
for i in range(a-1, c):
    if s[i] != ".":
        continue
    for j in range(1,3):
        if i+j < n:
            if s[i+j] != ".":
                continue
            if not dp[i+j]:
                dp[i+j] = dp[i]
if not dp[a-1]:
    ans = False

if d < c:
    l = max(b-2, 0)
    r = min(d-2, n-1)
    if "..." not in s[l:r+1]:
        ans = False

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

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(LEFT_A,RIGHT_A):
            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:
def solve():
    n, a, b, c, d = map(int, input().split())
    s = input()
    if c<d:
        for i in range(d-1):
            if s[i]=='#' and s[i+1]=='#':
                return False
        if s[c-1]=='#' or s[d-1]=='#':
            return False
        return True
    elif c==d:
        return False
    else:
        flag = False
        for i in range(b-1, c-1):
            if s[i]=='#' and s[i+1]=='#':
                return False
            if s[i-1]=='.' and s[i]=='.' and s[i+1]=='.' and i<=d-1:
                flag = True
        if s[c-1]=='#' or s[d-1]=='#':
            return False
        if not flag:
            return False
    return True
if solve():
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


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

    for i in range(n - 1):
        if s[i + 1] == s[i] == '#':
            print('No')
            return

    if d > c:
        print('Yes')
        return

    for i in range(b - 1, d):
        if s[i - 1] == s[i] == s[i + 1] == '.':
            print('Yes')
            return

    print('No')
    return


# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

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


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), 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", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


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

# endregion

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int, input().split())
S = input()
SA = S[a-1:c]
SB = S[b-1:d]
if "##" in SA or "##" in SB:
    print("No")
else:
    if c < d:
        print("Yes")
    else:
        if "..." in SB:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
st = input()
if C == D :
  print("No")
elif C < D:#連続で岩が置かれていなければおっけー
  flag = 0
  st1 = st[A:C+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B:D+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
  if flag :
    print("No")
  else:
    print("Yes")
    
else:#入れ替わりを行う必要がある
  flag = 0
  irekaeble = 0
  st1 = st[A:C+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B:D+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B-1:D+2]
  for i in range(len(st1)-2):
    if st1[i:i+3] == "...":
      irekaeble = 1
  
  if flag or irekaeble == 0:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    split = input().split(' ')
    n = int(split[0])
    a = int(split[1])
    b = int(split[2])
    c = int(split[3])
    d = int(split[4])
    s = input()
    isOK = False
    if c < d:
        isOK = not ('##' in s[a:c] or '##' in s[b:d])
    else:
        isOK = (not ('##' in s[a:c] or '##' in s[b:d])) and ('...' in s[b:d])
    print('Yes' if isOK else 'No')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)

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

def x(s):
    try:
        s.index("##")
    except:
        return True
    else:
        return False

n,a,b,c,d=intinput()
s=input()
if c<d:
    if x(s):
        print("Yes")
    else:
        print("No")
else:
    try:
        s.index("...")
    except:
        print("No")
        sys.exit()
    else:
        if x(s):
            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]=="#":
            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:
I=lambda:map(int,input().split())
N,A,B,C,D=I()
S=input()
cross=True if C-A-D+B==0 or 0<=(B-A)/(C-A-D+B)<=1 else False
if not(cross):
    ac = [i for i in range(min(A,C)-1,max(A,C)) if S[i]=='#']
    bd = [i for i in range(min(B,D)-1,max(B,D)) if S[i]=='#']
    f=True
    for i in range(len(ac)-1):
        if ac[i]+1==ac[i+1]:f=False
    for i in range(len(bd)-1):
        if bd[i]+1==bd[i+1]:f=False
    print('Yes' if f else 'No')
else:
    ac = [i for i in range(min(A,C)-1,max(A,C)) if S[i]=='#']
    bd = [i for i in range(min(B,D)-1,max(B,D)) if S[i]=='#']
    ins = False
    for i in range(len(ac)-1):
        if ac[i+1]-ac[i]>=4:
            ac = ac[:i+1]+[ac[i]+2]+ac[i+1:]
            ins=True
    if not(ins):
        for i in range(len(bd)-1):
            if bd[i+1]-bd[i]>=4:
                bd = bd[:i+1]+[bd[i]+2]+bd[i+1:]
                ins=True
    if not(ins):
        print('No')
    else:
        f=True
        for i in range(len(ac)-1):
            if ac[i]+1==ac[i+1]:f=False
        for i in range(len(bd)-1):
            if bd[i]+1==bd[i+1]:f=False
        print('Yes' if f else 'No')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int,input().split())
s = input()
judgesharp = False
judgepass = False
threepoint = 0
aOver = 0
if c < d:
  for i in s:
    if aOver < a:
      aOver += 1
    elif i == "#":
      if judgesharp == True:
        print("No")
        sys.exit()
      else:
        judgesharp = True
    else:
      judgesharp = False
  print("Yes")
else:
  for i in s:
    if aOver < a:
      aOver += 1
    elif i == "#":
      threepoint = 0
      if judgesharp == True:
        print("No")
        sys.exit()
      else:
        judgesharp = True
    else:
      threepoint += 1
      judgesharp = False
    if threepoint == 3:
      judgepass = True
  if judgepass:
    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, 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:
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
        else:
            span+=1
    if buf<=2:
        flag=1
        #print(buf)
print('NO' if flag==1 else 'YES')

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 == 'E':
    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-1:D]:
      print('Yes')
      exit()
print('No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import math

def main():
    n,a,b,c,d = map(int, raw_input().split())
    s = list(raw_input())
    chk = True
    cnt = 1
    hurdleA = 0
    hurdleB = 0
    three = 0
    threeChk = False
    for i in s:
        if i == '.':
            three += 1
        else:
            three = 0
        if three >= 3:
            threeChk = True
        if cnt > a and cnt < c:
            if i == '#':
                hurdleA += 1
            else:
                hurdleA = 0
            if hurdleA >= 2:
                chk = False
                break
        if cnt > b and cnt < d:
            if i == '#':
                hurdleB += 1
            else:
                hurdleB = 0
            if hurdleB >= 2:
                chk = False
                break
        cnt += 1
    if c > d and (s[d-2] == '#' or s[d] == '#') and threeChk == False:
        print "No"
    elif chk == False:
        print "No"
    else:
        print "Yes"

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

seq=0
tri=0
if c<d:
    seq=s[a:d].count("##")
    if seq==0:
        print("Yes")
    else:
        print("No")
else:
    seq=s[a:c].count("##")
    tri=s[b:d].count("...")
    if seq==0:
        if tri!=0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Submission status: Wrong Answer

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

gyaku = 0
if C > D:
    gyaku = 1

flag = 0
renzoku = 0
irekae = 0
for i in range(N):
    if S[i] == '#':
        renzoku = 0
        if flag == 1:
            if A < i < C-1 or B < i < D-1:
                print('No')
                exit()
        flag = 1

    else:
        flag = 0
        renzoku += 1
        if renzoku == 3:
            irekae = 1

    if gyaku:
        if i == D-1:
            if S[i-1] == '#':
                if irekae == 0:
                    print('No')
                    exit()

print('Yes')

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:]):
        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:
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 + 1] and not "##" in S[A:C]:
    print("Yes")
  else:
    print("No")
else:
  if not "##" in S[B:D + 1] and not "##" in S[A:C] and ("..." in S[B if A + 1 != B else A:C + 1]):
    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 or "##" in s[:d-1]:
    print("No")
elif c < d:
    print("Yes")
else:
    if "..." in s[: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[a:d]:
  print("No")
  exit()
elif c > d:
  if "..." in s[b:c-1]:
    print("Yes")
  else:
    print("No")
else:
  print("Yes")

Submission status: Wrong Answer

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

def check_cont_rock(s, e):
  use_road = road[s:e]
  return "##" in use_road

def check_cont_road(s, e):
  use_road = road[s:e]
  return "..." in use_road

if D > C:
  if check_cont_rock(A-1, D-1):
    print("No")
  else:
    print("Yes")
else:
  if check_cont_rock(A-1, C-1):
    print("No")
  else:
    if check_cont_road(B-2, D-2):
      print("Yes")
    else:
      print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()+"#"*2
e,f=True,False
for i in range(n):
    if s[i]+s[i+1]=="#"*2:
        if a<i<max(c,d):
            print("No")
            break
    else:
        if s[i]+s[i+1]+s[i+2]=="."*3:
            if b<=i+1<=d:
                f=True
else:
    if c<d:
        print("Yes")
    else:
        if f:
            print("Yes")
        else:
            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
    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:
            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:
import sys
#import numpy as np

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() 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()

    s1 = S[A:C-1]
    s2 = S[B:D-1]
    if s1.find('##') >= 0 or s2.find('##') >= 0:
        print('No')
        return

    if C < D:
        print('Yes')
        return
    else:
        s3 = S[B-2:C+1]
        if s3.find('...') >= 0:
            print('Yes')
            return
        print('No')
        return

main()

Submission status: Wrong Answer

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

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

if S[A - 1] == '#' or S[B - 1] == '#' or S[C - 1] == '#' or S[D - 1] == '#':
    print('No')
    sys.exit()

ans = ans_cand = 'No'
cnt_o = cnt_x = 0
for pos in range(A - 1, max(C, D)):
    Si = S[pos]
    if Si == '#':
        cnt_o = 0
        cnt_x += 1
        if cnt_x > 1: break
    else:
        cnt_x = 0
        if pos < (B - 1): continue
        cnt_o += 1
        if cnt_o > 2: ans_cand = 'Yes'
else:
    if C < D:
        ans = 'Yes'
    else:
        ans = ans_cand

print(ans)

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()
    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, max(c,d)-2):
            if s[i]=='.' and s[i+1] == '.' and s[i+2]=='.':
                has_3_consecu = 1
                break
        
        if has_3_consecu:
            print('Yes')
            return
    
    print('No')




solve()

Submission status: Wrong Answer

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

if S.count('##') > 0:
    print('No')
else:
    if C < D:
        print('Yes')
    else:
        if S.count('...') > 0:
            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]

need_swap = False
can_swap = False

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

print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  _, s_s, f_s, s_e, f_e = map(int, input().split())
  n = input().strip()

  if '##' in n[s_s:s_e] or '##' in n[f_s:f_e]:
    print('No')
  elif s_e < f_e:
    print('Yes')
  elif '...' in n[f_s - 1:f_e + 2]:
    print('Yes')
  else:
    print('No')


if __name__ == '__main__':
  main()