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 itertools as it
import collections as col
import heapq
import sys
sys.setrecursionlimit(10**9)

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

for i in range(A,max(C,D)):
    if S[i] == '#' and S[i+1] == '#':   
        print('No')
        exit()

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

X=[-1]*N
X[A] = 0 if S[A] == '#' else 1
for i in range(A+1,D):
    X[i] = 0 if S[i] == '#' else (X[i-1] + 1)
    if X[i] >= 3:   
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

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

ans = ''

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

if D > C:
    ans = ans

elif D < C:
    if ans == 'Yes':
        ans = 'No'
        for i in range(D - B):
            i = i + B
            if ss[i-1] == 0 and ss[i] == 0 and ss[i+1] == 0 :
                ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, input().split())
s = input()
x = min(a, b, c, d)
y = max(a, b, c, d)


if c < d:
    for i in range(y-x-1):
        if s[i+x] == "#" and s[i+x+1] == "#":
            print("No")
            break
    print("Yes")

else:
    for i in range(y-x-1):
        if s[i+x] == "#" and s[i+x+1] == "#":
            print("No")
            break

    for i in range(d-b-2):
        if s[i+b] == "." and s[i+b+1] == "." and s[i+b+2] == ".":
            print("Yes")
            sys.exit()
    print("No")

Submission status: Wrong Answer

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

ans = "No"
if "##" in s[a-1:c] or "##" in s[b-1:d]: pass
else:
    if c<d: ans = "Yes"
    else:
        if "..." in s[b-2:d]: ans = "Yes"


print(ans)

Submission status: Wrong Answer

Solution code:
def main():
	n,a,b,c,d = map(int,input().split())
	a-=1
	b-=1
	c-=1
	d-=1
	s = input()
	if '##' in s[a:c+1] or '##' in s[b:d+1]:
		print('No')
		return

	if c<d:
		print('Yes')
		return
	else:
		if d!=0 and d!=n-1 and s[d-1] == s[d+1] == '.':
			print('Yes')
		else:
			print('No')
		return
main()

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 = ''

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

if D > C:
    ans = ans

elif D < C:
    if ans == 'Yes':
        ans = 'No'
        for i in range(D - B):
            i = i + B
            if ss[i-1] == 0 and ss[i] == 0 and ss[i+1] == 0 :
                ans = 'Yes'
                print(i)

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


def reachable_and_three(start, end):
    now = start
    three = False
    while now <= end:
        nex = now
        while nex <= end and S[now] == S[nex]:
            nex += 1
        if S[now] == '#' and nex - now >= 2:
            return False, False
        if S[now] == '.' and nex - now >= 3:
            three = True
        now = nex
    return True, three


a_reach, a_three = reachable_and_three(A, C)
b_reach, b_three = reachable_and_three(B, D)

if not a_reach or not b_reach:
    print("No")
elif C < D or b_three:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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"
    
    else:

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

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

moziretu = S  # 保持しておく

# Bの人から動かす
zenhann = True
hoge = S[B+1]
for i in range(B+2, D):
    if hoge == S[i] and hoge == '#':
        zenhann = False
        break
    else:
        hoge = S[i]


if zenhann:
    str_list = list(S)
    str_list[D] = '#'
    S = "".join(str_list)

    hoge = S[A+1]
    for i in range(A+2, C):
        if hoge == S[i] and hoge == '#':
            zenhann = False
            break
        else:
            hoge = S[i]


kouhann = True
# Aの人から動かす
str_list = list(moziretu)
str_list[B] = '#'
moziretu = "".join(str_list)

hantei = moziretu[B+1]
for i in range(B+2, C):
    if hantei == moziretu[i] and moziretu[i+1] == '#' and moziretu[i+2] == '#':
        kouhann = False
        break
    else:
        hantei = moziretu[i]

if kouhann:
    fuga = moziretu[A+1]
    for i in range(A+2, C):
        if fuga == moziretu[i] and fuga == '#':
            kouhann = False
            break
        else:
            fuga = S[i]
    if kouhann:
        str_list = list(moziretu)
        str_list[C] = '#'
        moziretu = "".join(str_list)

        fuga = moziretu[B+1]
        for i in range(B+2, D):
            if fuga == moziretu[i] and fuga == '#':
                kouhann = False
                break
            else:
                fuga = moziretu[i]

if zenhann or kouhann:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, input().split())
s = input()
x = min(a, b, c, d)
y = max(a, b, c, d)


if c < d:
    for i in range(y-x-1):
        if s[i+x] == "#" and s[i+x+1] == "#":
            print("NO")
            break
    print("YES")

else:
    for i in range(y-x-1):
        if s[i+x] == "#" and s[i+x+1] == "#":
            print("NO")
            break

    for i in range(d-b-2):
        if s[i+b] == "." and s[i+b+1] == "." and s[i+b+2] == ".":
            print("YES")
            sys.exit()
    print("NO")

Submission status: Wrong Answer

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

if c<d:
    s = list(s)
    h = s[b:d]
    for i in range(1,len(h)):
        if "##" in h:
            print("No")
            break
    else:
        hh = s[a:c]
        for i in range(1,len(hh)):
            if "##" in hh:
                print("No")
                break
        else:
            print("Yes")
else:
    if "..." in s[a:d]:
        h = s[a:c]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            hh = s[b:d]
            for i in range(1,len(hh)):
                if hh[i]==hh[i-1] and hh[i]=="#":
                    print("No")
                    break
            else:
                print("Yes")
    else:
        s = list(s)
        h = s[b:d]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
class Kenken():
	def __init__(self,n,a,b,c,d,s):
		self.n = n
		self.a = a-1
		self.b = b-1
		self.c = c-1
		self.d = d-1
		self.s = s
		self.s = self.s[:a-1] + "A" + self.s[a:]
		self.s = self.s[:b-1] + "B" + self.s[b:]

	def str_replace(self,i,k,S):
		if k == 1:
			self.s = self.s[:i] + "." + S + self.s[i+2:]
		else:
			self.s = self.s[:i] + "." + self.s[i+1] + S + self.s[i+3:]

	def check_stone(self,i):
		if i < self.n:
			if self.s[i] == ".":
				return True
		return False

	def check_goal(self):
		if self.a == self.c and self.b == self.d:
			return False
		else:
			return True

	def left(self,target,i):
		if target == "a":
			self.str_replace(self.a,i,"A")
			self.a += i
		else:
			self.str_replace(self.b,i,"B")
			self.b += i
	
	def get_space(self,S):
		if S == "a":
			return self.a
		elif S == "b":
			return self.b
		elif S == "c":
			return self.c
		elif S == "d":
			return self.d

	def print_all(self):
		print(self.s)

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

over = 0

if c > d:
	if s.find("...") == -1:
		print("No")
		exit()
	else:
		over = 1
ken = Kenken(n,a,b,c,d,s)
flag=0

if over == 0:
	for i in range(n):
		if ken.get_space("b") != ken.get_space("d"):
			if ken.check_stone(ken.get_space("b")+1):
                        	ken.left("b",1)
			elif ken.check_stone(ken.get_space("b")+2):
				ken.left("b",2)
			else:
				print("No")
				exit()
		else:
			break
	for i in range(n):
		if ken.get_space("a") != ken.get_space("c"):
			if ken.check_stone(ken.get_space("a")+1):
                        	ken.left("a",1)
			elif ken.check_stone(ken.get_space("a")+2):
				ken.left("a",2)
			else:
				print("No")
				exit()
		else:
			print("Yes")
			break
else:		
	while ken.check_goal():
		if (ken.check_stone(ken.get_space("b")+1) and ken.check_stone(ken.get_space("b")-1)) or (ken.get_space("a")+1 == ken.get_space("b") and ken.check_stone(ken.get_space("b")+1)): 
			if ken.check_stone(ken.get_space("a")+1) and ken.get_space("a") != ken.get_space("c"):
				ken.left("a",1)
			elif ken.check_stone(ken.get_space("a")+2) and ken.get_space("a") != ken.get_space("c"):
				ken.left("a",2)
			if ken.check_stone(ken.get_space("b")+1) and ken.get_space("b") != ken.get_space("d"):
				ken.left("b",1)
			elif ken.check_stone(ken.get_space("b")+2) and ken.get_space("b") != ken.get_space("d"):
				ken.left("b",2)
			else:
				print("No")
				exit()
		else:
			if ken.check_stone(ken.get_space("b")+1) and ken.get_space("b") != ken.get_space("d"):
				ken.left("b",1)
			elif ken.check_stone(ken.get_space("b")+2) and ken.get_space("b") != ken.get_space("d"):
				ken.left("b",2)
			elif ken.check_stone(ken.get_space("a")+1) and ken.get_space("a") != ken.get_space("c"):
				ken.left("a",1)
			elif ken.check_stone(ken.get_space("a")+2) and ken.get_space("a") != ken.get_space("c"):
				ken.left("a",2)
			else:
				print("No")
				exit()
	print("Yes")

Submission status: Wrong Answer

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

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

    tmp_s = 0
    for s in S[A-1:C]:
        if s == '#' and tmp_s>0 :
            A_clear = False
            break
        elif s == '#':
            tmp_s += 1
        else: 
            tmp_s = 0
    if A_clear == True and B_clear == True:
        print('Yes')
    else:
        print('No')
    
elif D<C:
    # A
    tmp_s = 0
    for s in S[A-1:C]:
        if s == '#' and tmp_s>0 :
            A_clear = False
            break
        elif s == '#':
            tmp_s += 1
        else:
            tmp_s = 0
    if A_clear==True:
        # B
        tmp_s = 0
        tmp_d = 0
        A_clear = False
        for s in S[B-1:D]:
            if ( s == '.' and tmp_d>=2 ) or D-B==1:
                tmp_s += 1
                A_clear = True
            elif s == '.' and tmp_s>=0:
                tmp_d += 1
                tmp_s = 0
            elif s == '#' and tmp_d>=0:
                tmp_s += 1
                tmp_d = 0
            elif s == '#' and tmp_s>0 :
                B_clear = False
                break
        if A_clear == True and B_clear == True:
            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()
v=0
x=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-1 and i<d+1 and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.' :
            x=1
            break
if x==1:
    for i in range(n-2):
        if i>b and i<c and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break
    
if c>d and v==0:
    print('Yes')
if c<d and v==0:
    print('Yes')

Submission status: Wrong Answer

Solution code:
m, a, b, c, d = [int(i) for i in input().split()]
s = input()
if(c<d):
  print("YES")
else:
  if('...' in s[b-2:d+1]) == 1 and ('##' in s[b-2:d]) == 0:
    print("YES")
  else:
    print("NO")

Submission status: Wrong Answer

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

two_sharp = False
three_point = False

short_str = S[A-1:max(C, D)-1]

n = len(short_str)
S = short_str
for j in range(n-2):
  if S[j] == '.' and S[j+1] == '.' and S[j+2] == '.':
    three_point = True

  if S[j] == '#' and S[j+1] == '#':
    two_sharp = True

if two_sharp:
  print 'No'
elif D > C:
  print 'Yes'
elif C > D:
  if three_point:
    print 'Yes'
  else:
    print 'No'

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = (int(i) for i in input().split())  
s = input()
e = 0
if c<d:
  if s[a:c+1].count("##")==0 and s[b:d+1].count("##")==0:
    print("Yes")
  else:
    print("No")
else:
  if s[a:c+1].count("##")==0 and s[b:d+1].count("##")==0:
    for i in range(b,d+1):
      if s[i-1:i+2]=="..." :
        e = 1 
    if e == 1:
      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 # ##がないとTrue
santen_flag = False # ... があればTrue
 
a_s = s[a:c]
b_s = s[b:d]
 
 
if d < c:
  if '...' in s[b-1:d]:
    santen_flag = True
kome_flag = True
if '##' in a_s or '##' in b_s:
  kome_flag = False
    
#if not '#' in a_s and not '#' in b_s:
#	print('Yes')
if True:
	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:
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[3]):
        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もしくはDに岩を置いてAについて検討
        if ans=="Yes":
            #print(S)
            if memo>0:
                a=S[:memo]
                b=S[memo+1:]
                S=a+"#"+b
            else:
                a=S[:lis[4]-1]
                b=S[lis[4]:]
                S=a+"#"+b
            #print(S)
            a=S[:lis[2]-1]
            b=S[lis[2]:]
            S=a+"."+b
            #print(S,memo)
            for i in range(lis[1],lis[3]):
                if S[i:i+2]=="##":
                    ans="No"
                    break
    print(ans)

Submission status: Wrong Answer

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

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"
    
    else:

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

print(main())

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()
    ans = []
    if '##' in S[A:C]:
        ans.append(True)
    else:
        ans.append(False)
    if '##' in S[B:D]:
        ans.append(True)
    else:
        ans.append(False)
    if D < C:
        if '...' in S[B-2: D+1]:
            ans.append(True)
        else:
            ans.append(False)

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

import sys
import re

s= sys.stdin.readline().strip()
s= s.replace("BC","D")
s= re.sub("[BC]+"," ",s).split()

t= 0
for seg in s:
    while True:
        i=seg.find("D")
        if i<=0: break
        a= len(seg[:i])
        if a==0: continue
        #
        d= 1
        for j in range(i+1,len(seg)):
            if seg[j]!="D": break
            d+= 1
        t+= a*d
        seg= ("A"*a) + seg[i+d:]
#
print( t )

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
	n,a,b,c,d = map(int,input().split())
	a-=1
	b-=1
	c-=1
	d-=1
	s = input()
	for i in range(a,max(c,d)):
		if s[i]==s[i+1]=='#':
			print('No')
			return
	if c<d:
		print('Yes')
		return
	else:
		if d!=0 and d!=n-1 and s[d-1] == s[d+1] == '.':
			print('Yes')
		else:
			print('No')
		return

main()

Submission status: Wrong Answer

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

out1 = '##'
good1 = '...'
if c<d:
    if out1 in s:
        print("No")
    else:
        print("Yes")

else:
    if out1 in s:
        print("No")
    else:
        if good1 in s:
            if good1 in s[3:n]:
              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()

ans = "No"
if "##" in s[a-1:c] or "##" in s[b-1:d]: pass
else:
    if c<d: ans = "Yes"
    else:
        if "..." in s[b-1:d]: ans = "Yes"
        else: pass


print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int, input().split())
s=input()
v=0
x=[]
for i in range(n-2):
    if c<d:
        if i>a and i<d and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break

    
    elif c>d:
        if  i>=b-1 and i<d+1 and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.' :
            x=='Yes'
            break
if x=='Yes':
    for i in range(n-2):
        if i>b and i<c and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break
    
if c>d and v==0:
    print('Yes')
if c<d and v==0:
    print('Yes')

Submission status: Wrong Answer

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

if "##" in S[A:max(C, D)]:
    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:
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 = ''

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

if D > C:
    ans = ans

elif C < D:
    if ans == 'Yes':
    
        for i in range(D - B):
            i = i + B
            if ss[i-1] == 0 and ss[i] == 0 and ss[i+1] == 0 :
                ans = 'Yes'

print(ans)

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 # ##がないとTrue
santen_flag = False # ... があればTrue
 
a_s = s[a-1:c]
b_s = s[b-1:d]
 
 
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 a_s and not '#' in b_s:
#	print('Yes')
if True:
	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 = [int(i) - 1 for i in input().strip().split(' ')]
N += 1
S = [c for c in input().strip()]


def get(a, b):
  s = S[:]
  s[a] = 'A'
  s[b] = 'B'

  return s


def check(s, i, dest):
  while i < dest:
    i += 1
    if i <= dest and s[i] == '.':
      continue
    i += 1
    if i <= dest and s[i] == '.':
      continue

    return False

  return i == dest


def move(s, i, dest):
  if i == dest:
    return -1

  while i < dest:
    i = i + 1
    if i + 1 < N:
      if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
        return i

  return i if i == dest else -1


def main():
  a = A
  b = B

  for _ in range(1000):
    s = get(a, b)
    is_a = check(s, a, C)
    is_b = check(s, b, D)

    if is_a and is_b:
      return True
    if not is_a and not is_b:
      return False

    if C > D:
      if is_a:
        a = C
      else:
        b = move(s, b, D)
        if b < 0:
          return False
    else:
      if is_b:
        b = D
      else:
        a = move(s, a, C)
        if a < 0:
          return False


print('Yes' if main() else 'No')

Submission status: Wrong Answer

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

if c<d:
    s = list(s)
    h = s[b:d]
    for i in range(1,len(h)):
        if h[i]==h[i-1] and h[i]=="#":
            print("No")
            break
    else:
        hh = s[a:c]
        for i in range(1,len(hh)):
            if hh[i]==hh[i-1] and hh[i]=="#":
                print("No")
                break
        else:
            print("Yes")
else:
    if "..." in s[b-1:d+1]:
        h = s[a:c]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            hh = s[b:d]
            for i in range(1,len(hh)):
                if hh[i]==hh[i-1] and hh[i]=="#":
                    print("No")
                    break
            else:
                print("Yes")
    else:
        s = list(s)
        h = s[b:d]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            s[d-1]="#"
            hh = s[a:c]
            for i in range(1,len(hh)):
                if hh[i]==hh[i-1] and hh[i]=="#":
                    print("No")
                    break
            else:
                print("Yes")

Submission status: Wrong Answer

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

out1 = '##'
good1 = '...'
if c<d:
    if out1 in s:
        print("No")
    else:
        print("Yes")

else:
    if out1 in s:
        print("No")
    else:
        if good1 in s:
            if good1 in s[b-1: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()

ans = "No"
if "##" in s[a-1:c] or "##" in s[b-1:d]: pass
else:
    if c<d: ans = "Yes"
    else:
        if "..." in s[b:d-1]: ans = "Yes"
        else: pass


print(ans)

Submission status: Wrong Answer

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

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"
    
    else:

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

print(main())

Submission status: Wrong Answer

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

a, b, c, d = a - 1, b - 1, c - 1, d - 1
if s[c] == '#' or s[d] == '#':
    ans = 'No'
elif s.find('##', b, d + 1) != -1 or s.find('##', a, c + 1) != -1:
    ans = 'No'
elif c < d:
    ans = 'Yes'
elif s.find('...', b - 1, d) != -1:
    ans = 'Yes'
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:
    print("No")
    exit()

if C > D:
    if "..." in S[B-1:D]:
        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 c<d:
    s = list(s)
    h = s[b:d]
    for i in range(1,len(h)):
        if h[i]==h[i-1] and h[i]=="#":
            print("No")
            break
    else:
        hh = s[a:c]
        for i in range(1,len(hh)):
            if hh[i]==hh[i-1] and hh[i]=="#":
                print("No")
                break
        else:
            print("Yes")
else:
    if "..." in s[b-1:d]:
        h = s[a:c]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            hh = s[b:d]
            for i in range(1,len(hh)):
                if hh[i]==hh[i-1] and hh[i]=="#":
                    print("No")
                    break
            else:
                print("Yes")
    else:
        s = list(s)
        h = s[b:d]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            s[d-1]="#"
            hh = s[a:c]
            for i in range(1,len(hh)):
                if hh[i]==hh[i-1] and hh[i]=="#":
                    print("No")
                    break
            else:
                print("Yes")

Submission status: Wrong Answer

Solution code:
def count_renzoku_char(s, char):
    max_len = 0
    current_len = 0
    for c in s:
        if c == char:
            current_len += 1
        else:
            if max_len < current_len:
                max_len = current_len
            current_len = 0
 
    return max_len
 
if __name__ == "__main__":
    N, A, B, C, D = [int(x) for x in input().split()]
    S = input()
 
    def main():
        if C < D:
            raw_sharp = count_renzoku_char(S[B+1: D], '#')
            if raw_sharp >= 2:
                print('No')
                return
 
            raw_sharp = count_renzoku_char(S[A+1: C], '#')
            if raw_sharp >= 2:
                print('No')
                return
            else:
                print('Yes')
                return
        else:
            raw_sharp = count_renzoku_char(S[A+1: C], '#')
            if raw_sharp >= 2:
                print('No')
                return
 
            raw_space = count_renzoku_char(S[B-1: D+2], '.')
            if raw_space >= 3:
                print('Yes')
                return
            else:
                print('No')
                return
 
    main()

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

Submission status: Wrong Answer

Solution code:
def main():
	n,a,b,c,d = map(int,input().split())
	a-=1
	b-=1
	c-=1
	d-=1
	s = input()
	for i in range(a,max(c,d)):
		if s[i]==s[i+1]=='#':
			print('NO')
			return
	if c<d:
		print('YES')
		return
	else:
		if d!=0 and d!=n-1 and s[d-1] == s[d+1] == '.':
			print('YES')
		else:
			print('NO')
		return

main()

Submission status: Wrong Answer

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

a, b, c, d = a - 1, b - 1, c - 1, d - 1
if s[c] == '#' or s[d] == '#':
    ans = 'No'
elif s.find('##', b, d + 1) != -1 or s.find('##', a, c + 1) != -1:
    ans = 'No'
elif c < d:
    ans = 'Yes'
elif s.find('...', b - 1, d + 1) != -1:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
if C < D:
    if S[A-1:C].count('##') > 0 or S[B-1:D].count('##') > 0:
        print('No')
    else:
        print('Yes')
else:
    if S[A-1:C].count('##') == 0 and S[B-1:D].count('##') == 0 and S[B-1:D].count('...') > 0:
        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 # ##がないとTrue
santen_flag = False # ... があればTrue
 
a_s = s[a:c]
b_s = s[b:d]
 
 
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 a_s and not '#' in b_s:
#	print('Yes')
if True:
	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')