Problem:


Score : 400 points

Problem Statement

There are N squares arranged in a row, numbered 1, 2, ..., N from left to right.
You are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.

In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.

You can repeat the following operation any number of times:

Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.

You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.

Determine whether this is possible.

Constraints

4 \leq N \leq 200\ 000

S is a string of length N consisting of . and #.

1 \leq A, B, C, D \leq N

Square A, B, C and D do not contain a rock.

A, B, C and D are all different.

A < B

A < C

B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

Print Yes if the objective is achievable, and No if it is not.

Sample Input 1

7 1 3 6 7
.#..#..

Sample Output 1

Yes

The objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)

A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB

Sample Input 2

7 1 3 7 6
.#..#..

Sample Output 2

No

Sample Input 3

15 1 3 15 13
...#.#...#.#...

Sample Output 3

Yes



Sample input:
7 1 3 6 7
.#..#..


Sample output:
Yes

Submission status: Wrong Answer

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

if '##' in s:
    print('No')
    exit()
else:
    if c<d:
        print('Yes')
    else:
        if '...' in s[b-1:d]:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if '##' in s:
    print('No')
    exit()
else:
    if c<d:
        print('Yes')
    else:
        if '...' in s:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

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

l = max(a,b)
r = min(c,d)
li = s[l:r-1]

flag,OK = True,False
for i in range(len(li)-1):
    if li[i]== "#" and li[i+1] == "#":
        flag = False
        
for i in range(len(li)-2):
    if li[i]== "." and li[i+1] == "." and li[i+2] == ".":
        OK = True

if c < d and a < b and flag:
    print("Yes")
    exit()
if (d < c or b < a) and OK and flag:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

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

if d<c:
  for i in range(a,c):
    if s[i]=='#':
      if s[i-1]=='#':
        ch+=1
  for j in range(b,d):
    if s[j]=='#':
      if s[j-1]=='#':
        ch+=1
    if s[j-1]=='.' and s[j]=='.' and s[j+1]=='.':
      ch1+=1
      
  if ch==0 and ch1>0:
    print('Yes')
  else:
    print('No')
    
else:
  for i in range(a,c):
    if s[i]=='#':
      if s[i-1]=='#':
        ch+=1
  for j in range(b,d):
    if s[j]=='#':
      if s[j-1]=='#':
        ch+=1
  if ch==0:
    print('Yes')
  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
t =input()
s = ["."]*n

for i in range(n):
  if t[i] == "#":
    s[i]="#"

#bを先に動かす
if d>c:  
  for i in range(b, d):
    if s[i]=="#":
      if s[i+1]=="#":
        print("No")
        quit()
  for i in range(a, c):
    if s[i]=="#":
      if s[i+1]=="#":
        print("No")
        quit()
  print("Yes")

else:
  flg = True
  for i in range(b, d):
    if s[i]=="#":
      if s[i+1]=="#":
        print("No")
        quit()
        
  for i in range(b, d):
    if s[i-1]==".":
      if s[i]==".":
        if s[i+1]==".":
          flg = False
          s[i]="#"
          temp = i
          break
  if flg:
    print("No")
    quit()
    
  for i in range(a, c):
    if s[i]=="#":
      if s[i+1]=="#":
        print("No")
        quit()   
          
  for i in range(temp+1, d):
    if s[i]=="#":
      if s[i+1]=="#":
        print("No")
        quit()   

  print("Yes")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
a-=1
b-=1
c-=1
d-=1
t =input()
s = ["."]*n

for i in range(n):
  if t[i] == "#":
    s[i]="#"

#bを先に動かす
if d>c:  
  for i in range(b, d):
    if s[i]=="#":
      if s[i+1]=="#":
        print("No")
        quit()
  for i in range(a, c):
    if s[i]=="#":
      if s[i+1]=="#":
        print("No")
        quit()
  print("Yes")

else:
  flg = True
  for i in range(b, d):
    if s[i]=="#":
      if s[i+1]=="#":
        print("No")
        quit()
        
  for i in range(b, d-1):
    if s[i-1]==".":
      if s[i]==".":
        if s[i+1]==".":
          flg = False
          s[i]="#"
          break
  if flg:
    print("No")
    quit()
    
  for i in range(a, c):
    if s[i]=="#":
      if s[i+1]=="#":
        print("No")
        quit()
  print("Yes")

Submission status: Wrong Answer

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

if "##" in S[A-1:C] or "##" in S[B-1:D]:
    print("No")
elif C < D:
    print("Yes")
elif "..." in S[B-2:D]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if "##" in S[A-1:C] or "##" in S[B-1:D]:
    print("No")
elif C < D:
    print("Yes")
elif "..." in S[B-1:D]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

last = "."
for i in range(a, max(c, d)):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]

if c < d:
    print("Yes")
else:
    length = 0
    for i in range(b-2, d):
        if s[i] == ".":
            length += 1

            if length == 3:
                print("Yes")
                exit()
        else:
            length = 0

    print("No")

Submission status: Wrong Answer

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

last = "."
for i in range(a, max(c, d)):
    if last == "#" and s[i] == "#":
        print("No")
        break
    last = s[i]

if c < d:
    print("Yes")
else:
    length = 0
    for i in range(b-2, c):
        if s[i] == ".":
            length += 1

            if length == 3:
                print("Yes")
                break
        else:
            length = 0

    print("No")

Submission status: Wrong Answer

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

if a > c or b > d:
    print("No")
elif s[c-1] == "#" or s[d-1] == "#":
    print("No")
else:
    #if d > c:
    last = "."
    for i in range(b, d):
        if last == "#" and s[i] == "#":
            print("No")
            exit()
        last = s[i]

    last = "."
    sol = True
    for i in range(a, c):
        if i == b-1:
            break

        if last == "#" and s[i] == "#":
            sol = False
            print("No")
            exit()

    if sol:
        if d > c:
            print("Yes")
        else:
            last = ""
            length = 0
            for i in range(b-2, n):
                if last == ".":
                    if s[i] == ".":
                        length += 1

                    if length == 3:
                        if (i-1 > b-1) or (i>c-1):
                            print("No")
                            exit()
                    else:
                        print("Yes")
                        exit()
                else:
                    last = s[i]
                    length = 1

            print("No")
    else:
        print("No")

Submission status: Wrong Answer

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

a = a-1
b = b-1
c = c-1
d = d-1

for i in range(a+1, d):
    if s[i-1] == '#' and s[i] == '#':
        print('No')
        exit()

if c < d:
    print('Yes')
    exit()

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

Submission status: Wrong Answer

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

a = a-1
b = b-1
c = c-1
d = d-1

cnt = 0
for i in range(a, d):
    if s[i] == '#':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        print('No')
        exit()

if c < d:
    print('Yes')
    exit()

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

Submission status: Wrong Answer

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

a = a-1
b = b-1
c = c-1
d = d-1

cnt = 0
for i in range(a+1, max(c, d)+1):
    if s[i] == '#':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        print('No')
        exit()

if c < d:
    print('Yes')
    exit()

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

Submission status: Wrong Answer

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

a = a-1
b = b-1
c = c-1
d = d-1

cnt = 0
for i in range(a+1, d+1):
    if s[i] == '#':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        print('No')
        exit()

if c < d:
    print('Yes')
    exit()

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

Submission status: Wrong Answer

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

a = a-1
b = b-1
c = c-1
d = d-1

cnt = 0
for i in range(a+1, d+1):
    if s[i] == '#':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        print('No')
        exit()

if c < d:
    print('Yes')
    exit()

cnt = 0
for i in range(b+1, d+1):
    if s[i] == '.':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        if s[i+1] == '.':
            print('Yes')
            exit()
print('No')

Submission status: Wrong Answer

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

a = a-1
b = b-1
c = c-1
d = d-1

cnt = 0
for i in range(a, max(c, d)):
    if s[i] == '#':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        print('No')
        exit()

if c < d:
    print('Yes')
    exit()

cnt = 0
for i in range(b+1, d+1):
    if s[i] == '.':
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

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

a = a-1
b = b-1
c = c-1
d = d-1

cnt = 0
for i in range(a, max(c, d)):
    if s[i] == '#':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        print('No')
        exit()

if c < d:
    print('Yes')
    exit()

cnt = 0
for i in range(b+1, d+1):
    if s[i] == '.':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        if s[i+1] == '.':
            print('Yes')
            exit()
print('No')

Submission status: Wrong Answer

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

a = a-1
b = b-1
c = c-1
d = d-1

cnt = 0
for i in range(a, max(c, d)):
    if s[i] == '#':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        print('No')
        exit()

cnt = 0
for i in range(b+1, d+1):
    if s[i] == '.':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        if i != d:
            if s[i+1] == '.':
                break

if i+1 == n:
    s = s[:i] + '#'
else:
    s = s[:i] + '#' + s[i+1:]

cnt = 0
if c < d:
    if i+1 != n:
        s = s[:i] + '.' + s[i+1:-1] + '#'
    for j in range(a+1, c):
        if s[j] == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            print('No')
            exit()
elif d < c:
    for j in range(a+1, c):
        if s[j] == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            print('No')
            exit()
print('Yes')

Submission status: Wrong Answer

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

a = a-1
b = b-1
c = c-1
d = d-1

cnt = 0
for i in range(b+1, d+1):
    if s[i] == '.':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        if i != d:
            if s[i+1] == '.':
                break

if i+1 == n:
    s = s[:i] + '#'
else:
    s = s[:i] + '#' + s[i+1:]

cnt = 0
if c < d:
    if i+1 != n:
        s = s[:i] + '.' + s[i+1:-1] + '#'
    for j in range(a+1, c):
        if s[j] == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            print('No')
            exit()
elif d < c:
    for j in range(a+1, c):
        if s[j] == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            print('No')
            exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = ['#']+list(input())
CanReach = True
CanChange = False
for i in range(A,C):
    if S[i] == '#' and S[i+1] == '#':
        CanReach = False
for i in range(B,D):
    if S[i] == '#' and S[i+1] == '#':
        CanReach = False
if C < D:
    CanChange = True
for i in range(B,D):
    if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.':
        CanChange = True
if CanReach and CanChange:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = ['#']+list(input())
CanReach = True
CanChange = False
for i in range(A,C):
    if S[i] == '#' and S[i+1] == '#':
        CanReach = False
for i in range(B,D):
    if S[i] == '#' and S[i+1] == '#':
        CanReach = False
if C < D:
    CanChange = True
for i in range(B,D-1):
    if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.':
        CanChange = True
if CanReach and CanChange:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = ['#']+list(input())
CanReach = True
CanChange = False
for i in range(A,C):
    if S[i] == '#' and S[i+1] == '#':
        CanReach = False
for i in range(B,D):
    if S[i] == '#' and S[i+1] == '#':
        CanReach = False
if C < D:
    CanChange = True
for i in range(B-1,D-1):
    if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
        CanChange = True
if CanReach and CanChange:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = ['#']+list(input())
CanReach = True
CanChange = False
for i in range(A,C):
    if S[i] == '#' and S[i+1] == '#':
        CanReach = False
for i in range(B,D):
    if S[i] == '#' and S[i+1] == '#':
        CanReach = False
if C < D:
    CanChange = True
for i in range(B,D-1):
    if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
        CanChange = True
if CanReach and CanChange:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = ['#']+list(input())
CanReach = True
CanChange = False
for i in range(A,C):
    if S[i] == '#' and S[i+1] == '#':
        Canreach = False
for i in range(B,D):
    if S[i] == '#' and S[i+1] == '#':
        Canreach = False
if C < D:
    CanChange = True
for i in range(B,D-1):
    if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
        CanChange = True
if CanReach and CanChange:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = ['#']+list(input())
CanReach = True
CanChange = False
for i in range(A,C):
    if S[i] == '#' and S[i+1] == '#':
        reach = False
for i in range(B,D):
    if S[i] == '#' and S[i+1] == '#':
        reach = False
if C < D:
    CanChange = True
for i in range(B,D-1):
    if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
        CanChange = True
if CanReach and CanChange:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

# A - Kenken Race
def can_goal(start, goal):
	global S

	way = S[start:goal+1]

	if not '##' in way:
		if way.endswith('.'):
			return True


def can_go_halfway(start, goal):
	global S

	way = S[start:goal+1]

	if way.find('...') > -1:
		return True


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

if C < D:
	if can_goal(B, D):
		if can_goal(A, C):
			print('Yes')
			exit()
else:
	if can_go_halfway(B, D):
		if can_goal(A, C):
			if can_goal(B, D):
				print('Yes')
				exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys

#	A	-	Kenken	Race
def	can_goal(start,	goal):
	global	S

	way	=	S[start:goal+1]

	if	not	'##'	in	way:
		if	way.endswith('.'):
			return	True


def	can_go_halfway(start,	goal):
	global	S

	way	=	S[start:goal+1]

	if way.find('...') > -1:
		return  True


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

if	C	<	D:
	if	can_goal(B,	D):
		if	can_goal(A,	C):
			print('Yes')
			exit()
else:
	if can_go_halfway(B, D):
		if	can_goal(A,	C):
			if can_goal(B, D):
				print('Yes')
				exit()

print('No')

Submission status: Wrong Answer

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

s = '#' + s + '#'

def can_reach(start, end):
    for i in range(start, end+1):
        if s[i] == '#' and s[i+1] == '#':
            return False
    return True

if not can_reach(a, b) and not can_reach(b, d):
    print('No')
    exit()

if c > d:
    can_over = False
    for i in range(b, d+1):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            can_over = True
    if not can_over:
        print('No')
        exit()

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

flg = True
ok = False
cnt = 0
for i in range(b, d):
    if s[i] == '#':
        cnt = 0
        if s[i+1] == '#':
            flg = False
    else:
        cnt += 1
        if cnt == 3:
            ok = True     
if cnt + 1 == 3:
    ok = True
    
for i in range(a, c):
    if s[i] == '#' and s[i+1] == '#':
        flg = False

if c < d:
    print('Yes' if flg else 'No')

else:
    print('Yes' if flg and ok else 'No')

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

flg = True
ok = False
cnt = 0
for i in range(b, d):
    if s[i] == '#':
        cnt = 0
        if s[i+1] == '#':
            flg = False
    else:
        cnt += 1
        if cnt == 3:
            ok = True     

for i in range(a, c):
    if s[i] == '#' and s[i+1] == '#':
        flg = False

if c < d:
    print('Yes' if flg else 'No')

else:
    print('Yes' if flg and ok else 'No')

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

flg = True
max_cnt = 0
cnt = 0
for i in range(b, d):
    if s[i] == '#':
        max_cnt = max(max_cnt, cnt)
        cnt = 0
        if s[i+1] == '#':
            flg = False
    if s[i] == '.':
        cnt += 1
if s[d] == '.':
    max_cnt = max(max_cnt, cnt + 1)
    
if max_cnt <= 2 and d < c:
    flg = False

for i in range(a, c):
    if s[i] == '#' and s[i+1] == '#':
        flg = False

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

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

flg = True
max_cnt = 0
cnt = 0
for i in range(b, d):
    if s[i] == '#':
        max_cnt = max(max_cnt, cnt)
        cnt = 0
        if s[i+1] == '#':
            flg = False
    if s[i] == '.':
        cnt += 1

if max_cnt <= 2 and d < c:
    flg = False

for i in range(a, c):
    if s[i] == '#' and s[i+1] == '#':
        flg = False

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

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

flg = True
max_cnt = 0
cnt = 0
for i in range(a, c):
    if s[i] == '#':
        max_cnt = max(max_cnt, cnt)
        cnt = 0
        if s[i+1] == '#':
            flg = False
    if s[i] == '.':
        cnt += 1

if max_cnt <= 2 and d < c:
    flg = False

for i in range(b, d):
    if s[i] == '#' and s[i+1] == '#':
        flg = False

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = list(input())
for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        quit()
if c < d:
    print("Yes")
elif c > d:
    for j in range(b-2,d-1):
        if s[j] == "." and s[j+1] == "." and s[j+2] == ".":
            print("Yes")
            quit()
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = list(input())
for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        quit()
if c < d:
    print("Yes")
elif c > d:
    for j in range(b-2,d):
        if s[j] == "." and s[j+1] == "." and s[j-1] == ".":
            print("Yes")
            quit()
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = list(input())
for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        quit()
if c < d:
    print("Yes")
elif c > d:
    for j in range(b-1,d):
        if s[j] == "." and s[j+1] == "." and s[j-1] == ".":
            print("Yes")
            quit()
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = list(input())
for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        quit()
if c < d:
    print("Yes")
elif c > d:
    for j in range(b-1,d-2):
        if s[j] == "." and s[j+1] == "." and s[j+2] == ".":
            print("Yes")
            quit()
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = list(input())
if s == ["."]*4:
    print("Yes")
    quit()
for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        quit()
if c < d:
    print("Yes")
elif c > d:
    for j in range(b-1,d-2):
        if s[j] == "." and s[j+1] == "." and s[j+2] == ".":
            print("Yes")
            quit()
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = list(input())
for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        quit()
if c < d:
    print("Yes")
elif c > d:
    for j in range(b-1,d-2):
        if s[j] == "." and s[j+1] == "." and s[j+2] == ".":
            print("Yes")
            quit()
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = list(input())
for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        print("No")
        quit()
if c < d:
    print("Yes")
elif c > d:
    for j in range(n-2):
        if s[j] == "." and s[j+1] == "." and s[j+2] == ".":
            print("Yes")
            quit()
    print("No")

Submission status: Wrong Answer

Solution code:
import sys

# A - Kenken Race
def can_goal(start, goal):
	global S

	way = S[start:goal+1]

	if not '##' in way:
		if way.endswith('.'):
			return True


def go_halfway(start, goal):
	global S
	global N

	way = S[start:goal+1]
	stop_pos = way.find('...') + 1

	if stop_pos > 0:
		if can_goal(start, stop_pos):
			#print(S[:start])
			#print(way.replace('...', '.#.', 1))
			#print(S[goal+1:])
		
			S = S[:start] + way.replace('...', '.#.', 1) + S[goal+1:]
			return  stop_pos

	return -1


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

if C < D:
	if can_goal(B, D):
		if can_goal(A, C):
			print('Yes')
			exit()
else:
	halfway = go_halfway(B, D)

	if halfway == D:
		if can_goal(A, C):
			print('Yes')
	elif halfway > -1:
		if can_goal(A, C):
			if can_goal(halfway, D):
				print('Yes')
				exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys

# A - Kenken Race
def can_goal(start, goal):
	global S

	way = S[start:goal+1]

	if not '##' in way:
		if way.endswith('.'):
			return True


def go_halfway(start, goal):
	global S
	global N

	way = S[start:goal+1]
	stop_pos = way.find('...') + 1

	if stop_pos > 0:
		if can_goal(start, stop_pos):
			#print(S[:start-1])
			#print(way.replace('...', '.#.', 1))
			#print(S[goal+1:])
		
			S = S[:start-1] + way.replace('...', '.#.', 1) + S[goal+1:]
			return  stop_pos

	return -1


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

if C < D:
	if can_goal(B, D):
		if can_goal(A, C):
			print('Yes')
			exit()
else:
	halfway = go_halfway(B, D)

	if halfway == D:
		if can_goal(A, C):
			print('Yes')
	elif halfway > -1:
		if can_goal(A, C):
			if can_goal(halfway, D):
				print('Yes')
				exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys

# A - Kenken Race
def can_goal(start, goal):
	global S

	way = S[start:goal+1]

	if not '##' in way:
		if way.endswith('.'):
			return True


def go_halfway(start, goal):
	global S
	global N

	way = S[start:goal+1]
	breakroom = way.find('...') + 1

	if breakroom > 0:
		if can_goal(start, breakroom):
			S = S[:breakroom-1] + '.#.' + S[breakroom+2:]
			return  breakroom

	return -1


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

if C < D:
	if can_goal(B, D):
		if can_goal(A, C):
			print('Yes')
			exit()
else:
	halfway = go_halfway(B, D)

	if halfway == D:
		if can_goal(A, C):
			print('Yes')
	elif halfway > -1:
		if can_goal(A, C):
			if can_goal(halfway, D):
				print('Yes')
				exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys

# A - Kenken Race
def can_goal(start, goal):
	global S

	way = S[start:goal+1]

	if not '##' in way:
		if way.endswith('.'):
			return True


def go_halfway(start, goal):
	global S
	global N

	way = S[start:goal+1]
	breakroom = way.find('...') + 1

	if breakroom > 0:
		if can_goal(start, breakroom):
			S = S[:breakroom-1] + '.#.' + S[breakroom+2]
			return  breakroom

	return -1


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

if C < D:
	if can_goal(B, D):
		if can_goal(A, C):
			print('Yes')
			exit()
else:
	halfway = go_halfway(B, D)

	if halfway == D:
		if can_goal(A, C):
			print('Yes')
	elif halfway > -1:
		if can_goal(A, C):
			if can_goal(halfway, D):
				print('Yes')
				exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys

# A - Kenken Race
def can_goal(start, goal):
	global S

	way = S[start:goal+1]

	if not '##' in way:
		if way.endswith('.'):
			return True


def go_halfway(start, goal):
	global S
	global N

	way = S[start:goal+1]
	breakroom = way.find('...') + 1

	if breakroom > -1:
		if can_goal(start, breakroom):
			S = S[:breakroom-1] + '.#.' + S[breakroom+2]
			return  breakroom

	return -1


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

if C < D:
	if can_goal(B, D):
		if can_goal(A, C):
			print('Yes')
			exit()
else:
	halfway = go_halfway(B, D)

	if halfway == D:
		if can_goal(A, C):
			print('Yes')
	elif halfway > -1:
		if can_goal(A, C):
			if can_goal(halfway, D):
				print('Yes')
				exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys

# A - Kenken Race
def can_goal(start, goal):
	global S

	way = S[start:goal+1]

	if not '##' in way:
		if way.endswith('.'):
			return True


def go_halfway(start, goal):
	global S
	global N

	way = S[start:goal+1]
	breakroom = way.find('...') + 1

	if breakroom > -1:
		if can_goal(start, breakroom):
			S = S[:breakroom] + '.#.' + S[breakroom+3]
			return  breakroom

	return -1


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

if C < D:
	if can_goal(B, D):
		if can_goal(A, C):
			print('Yes')
			exit()
else:
	halfway = go_halfway(B, D)

	if halfway == D:
		if can_goal(A, C):
			print('Yes')
	elif halfway > -1:
		if can_goal(A, C):
			if can_goal(halfway, D):
				print('Yes')
				exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys

# A - Kenken Race
def can_goal(start, goal):
	global S

	way = S[start:goal+1]

	if not '##' in way:
		if S[goal] == '.':
			return True


def go_halfway(start, goal):
	global S
	global N

	for i in range(start, goal + 1):
		if S[i] == S[i - 1] == S[i + 1] == '.':
			if can_goal(start, i):
				S = S[:i] + 'B' + S[i+1:]
				return i

	return -1


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

if C < D:
	if can_goal(B, D):
		if can_goal(A, C):
			print('Yes')
			exit()
else:
	halfway = go_halfway(B, D)

	if halfway == D:
		if can_goal(A, C):
			print('Yes')
	elif halfway > -1:
		if can_goal(A, C):
			if can_goal(halfway, D):
				print('Yes')
				exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys

# A - Kenken Race
def can_goal(start, goal):
	global S

	for i in range(start, goal):
		if S[i] != '.':
			if S[i + 1] != '.':
				return False

	if S[goal] == '.':
		return True
	else:
		return False


def go_halfway(start, goal):
	global S
	global N

	for i in range(start, goal + 1):
		if S[i] == S[i - 1] == S[i + 1] == '.':
			if can_goal(start, i):
				S = S[:i] + 'B' + S[i+1:]
				return i

	return -1


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

if C < D:
	if can_goal(B, D):
		if can_goal(A, C):
			print('Yes')
			exit()
else:
	halfway = go_halfway(B, D)

	if halfway == D:
		if can_goal(A, C):
			print('Yes')
	elif halfway > -1:
		if can_goal(A, C):
			if can_goal(halfway, D):
				print('Yes')
				exit()

print('No')

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
def can_goal(start, goal):
	global S
	
	for i in range(start, goal):
		if S[i] != '.':
			if S[i + 1] != '.':
				return False
	
	if S[goal] == '.':
		return True				
	else:
		return False

		
def go_halfway(start, goal):
	global S
	global N
				
	for i in range(start, goal + 1):
		if S[i] == S[i - 1] == S[i + 1] == '.':
			S = S[:i] + 'B' + S[i+1:]
			return i

	return -1


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

if C < D:
	if can_goal(B, D):
		if can_goal(A, C):
			print('Yes')
			exit()
else:
	halfway = go_halfway(B, D)
	
	if halfway == D:
		if can_goal(A, C):
			print('Yes')
	elif halfway > -1:
		if can_goal(A, C):
			if can_goal(halfway, D):
				print('Yes')
				exit()
			
print('No')

Submission status: Wrong Answer

Solution code:
import sys

# A - Kenken Race
def can_goal(start, goal):
	global S

	for i in range(start, goal):
		if S[i] != '.':
			if S[i + 1] != '.':
				return False

	if S[goal] == '.':
		return True
	else:
		return False


def go_halfway(start, goal):
	global S
	global N

	for i in range(start, goal):
		if S[i] == S[i - 1] == S[i + 1] == '.':
			S = S[:i] + 'B' + S[i+1:]
			return i

	return -1


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

if C < D:
	if can_goal(B, D):
		if can_goal(A, C):
			print('Yes')
			exit()
else:
	halfway = go_halfway(B, D)

	if halfway > -1:
		if can_goal(A, C):
			if can_goal(halfway, D):
				print('Yes')
				exit()

print('No')