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, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

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

def cango(a, b):
	for i in range(a, b):
		if S[i] == "#" and S[i+1] == "#":
			return False
			break
	else:
		return True

if C < D:
	if cango(A-1, C-1) and cango(B-1, D-1):
		print("Yes")
	else:
		print("No")

else:
	for i in range(B-2, D-2):
		if S[i] == S[i+1] == S[i+2] == ".":
			S[i+1] = "#"
			break
	else:
		print("No")
		exit()

	if cango(A-1, C-1):
		print("Yes")
	else:
		print("No")

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

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

def cango(a, b):
	for i in range(a, b):
		if S[i] == "#" and S[i+1] == "#":
			return False
			break
	else:
		return True

if C < D:
	if cango(A-1, C-1) and cango(B-1, D-1):
		print("Yes")
	else:
		print("No")

else:
	for i in range(B-1, D-2):
		if S[i] == S[i+1] == S[i+2] == ".":
			S[i+1] = "#"
			break
	else:
		print("No")
		exit()

	if cango(A-1, C-1):
		print("Yes")
	else:
		print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=list(s)
cnts=0
cnti=0
space=0
iwa=0
temp=0
next=0
if c<d:
  for i in range(a-1,d):
    if s[i]==".":
      cnts=cnts+1
      space=max(space,cnts)
      cnti=0
    else:
      cnti=cnti+1
      iwa=max(iwa,cnti)
      cnts=0
  if iwa>1:
    print("No")
  else:
    print("Yes")
else:
  for i in range(a-1,c):
    if s[i]==".":
      cnts=cnts+1
      if i<=b-2:
        cnts=0
      space=max(space,cnts)
      cnti=0
    else:
      cnti=cnti+1
      iwa=max(iwa,cnti)
      cnts=0
    if i==d-1:
      temp=space
      if s[i-1]=="." and s[i+1]==".":
        next=1
  if iwa>1:
    print("No")
  elif temp<3 and next==0:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=list(s)
cnts=0
cnti=0
space=0
iwa=0
temp=0
next=0
if c<d:
  for i in range(a-1,d):
    if s[i]==".":
      cnts=cnts+1
      space=max(space,cnts)
      cnti=0
    else:
      cnti=cnti+1
      iwa=max(iwa,cnti)
      cnts=0
  if iwa>1:
    print("No")
  else:
    print("Yes")
else:
  for i in range(a-1,c):
    if s[i]==".":
      cnts=cnts+1
      if i<=c-2:
        cnts=0
      space=max(space,cnts)
      cnti=0
    else:
      cnti=cnti+1
      iwa=max(iwa,cnti)
      cnts=0
    if i==d-1:
      temp=space
      if s[i-1]=="." and s[i+1]==".":
        next=1
  if iwa>1:
    print("No")
  elif temp<3 and next==0:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=list(s)
cnts=0
cnti=0
space=0
iwa=0
temp=0
next=0
if c<d:
  for i in range(a-1,d):
    if s[i]==".":
      cnts=cnts+1
      space=max(space,cnts)
      cnti=0
    else:
      cnti=cnti+1
      iwa=max(iwa,cnti)
      cnts=0
  if iwa>1:
    print("No")
  else:
    print("Yes")
else:
  for i in range(a-1,c):
    if s[i]==".":
      cnts=cnts+1
      space=max(space,cnts)
      cnti=0
    else:
      cnti=cnti+1
      iwa=max(iwa,cnti)
      cnts=0
    if i==d-1:
      temp=space
      if s[i-1]=="." and s[i+1]==".":
        next=1
  if iwa>1:
    print("No")
  elif temp<3 and next==0:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=list(s)
cnts=0
cnti=0
space=0
iwa=0
temp=0
next=0
if c<d:
  for i in range(a-1,max(c,d)):
    if s[i]==".":
      cnts=cnts+1
      space=max(space,cnts)
      cnti=0
    else:
      cnti=cnti+1
      iwa=max(iwa,cnti)
      cnts=0
  if iwa>1:
    print("No")
  else:
    print("Yes")
else:
  for i in range(a-1,max(c,d)):
    if s[i]==".":
      cnts=cnts+1
      space=max(space,cnts)
      cnti=0
    else:
      cnti=cnti+1
      iwa=max(iwa,cnti)
      cnts=0
    if i==d-1:
      temp=space
      if s[i-1]=="." and s[i+1]==".":
        next=1
  if iwa>1:
    print("No")
  elif temp<3 and next==0:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=list(s)
cnts=0
cnti=0
space=0
iwa=0
temp=0
next=0
if c<d:
  for i in range(a-1,max(c,d)):
    if s[i]==".":
      cnts=cnts+1
      space=max(space,cnts)
      cnti=0
    else:
      cnti=cnti+1
      iwa=max(iwa,cnti)
      cnts=0
  if iwa>1:
    print("No")
  else:
    print("Yes")
else:
  for i in range(a-1,max(c,d)):
    if i==d-1:
      temp=space
      if s[i-1]=="." and s[i+1]==".":
        next=1
    if s[i]==".":
      cnts=cnts+1
      space=max(space,cnts)
      cnti=0
    else:
      cnti=cnti+1
      iwa=max(iwa,cnti)
      cnts=0
  if iwa>1:
    print("No")
  elif temp<3 and next==0:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=list(s)
cnts=0
cnti=0
space=0
iwa=0
temp=0
next=0
if c<d:
  for i in range(a-1,min(c,d)):
    if s[i]==".":
      cnts=cnts+1
      space=max(space,cnts)
      cnti=0
    else:
      cnti=cnti+1
      iwa=max(iwa,cnti)
      cnts=0
  if iwa>1:
    print("No")
  else:
    print("Yes")
else:
  for i in range(a-1,min(c,d)):
    if i==d:
      temp=space
      if s[i-1]=="." and s[i+1]==".":
        next=1
    if s[i]==".":
      cnts=cnts+1
      space=max(space,cnts)
      cnti=0
    else:
      cnti=cnti+1
      iwa=max(iwa,cnti)
      cnts=0
  if iwa>1:
    print("No")
  elif temp<3 and next==0:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=list(s)
cnts=0
cnti=0
space=0
iwa=0
for i in range(a-1,max(c,d)):
  if s[i]==".":
    cnts=cnts+1
    space=max(space,cnts)
    cnti=0
  else:
    cnti=cnti+1
    iwa=max(iwa,cnti)
    cnts=0
if iwa>1:
  print("No")
elif c>d and space<3:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

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

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

if c < d:
	bad = 0
	for i in range(b, d+1):
		if l[i] == '#':
			bad+=1
		else:
			bad = 0
		if bad == 2:
			print('No')
			exit()
	bad = 0
	for i in range(a, c+1):
		if l[i] == '#':
			bad+=1
		else:
			bad = 0
		if bad == 2:
			print('No')
			exit()
	print('Yes')
else:
	cons = 0
	bad = 0
	flag = False
	if not (l[b+1] == '.' and l[b-1] == '.'):
		for i in range(b, d+1):
			if l[i] == '.':
				cons+=1
				bad = 0
			else:
				cons = 0
				bad+=1
			if bad == 2:
				print('No')
				exit()
			if cons == 3:
				flag = True
				break
	if not flag:
		print('No')	
		exit()

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

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

Submission status: Wrong Answer

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

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

if c < d:
	bad = 0
	for i in range(b, d+1):
		if l[i] == '#':
			bad+=1
		else:
			bad = 0
		if bad == 2:
			print('No')
			exit()
	bad = 0
	for i in range(a, c+1):
		if l[i] == '#':
			bad+=1
		else:
			bad = 0
		if bad == 2:
			print('No')
			exit()
	print('Yes')
else:
	cons = 0
	bad = 0
	flag = False
	if not (l[b+1] == '.' and l[b-1] == '.'):
		for i in range(b, d+1):
			if l[i] == '.':
				cons+=1
				bad = 0
			else:
				cons = 0
				bad+=1
			if bad == 2:
				print('No')
				exit()
			if cons == 3:
				flag = True
				break
	if not flag:
		print('No')	
		exit()

	bad = 0
	for i in range(a, c+1):
		if l[i] == '#':
			bad+=1
		else:
			bad = 0
		if bad == 2:
			print('No')
			exit()
	print('Yes')

Submission status: Wrong Answer

Solution code:
import re
n, a, b, c, d = map(int, input().split())
road = input()
if c < d:
    if re.search('##', road[a:]) is None:
        print('Yes')
    else:
        print('No')

elif c > d:
    if re.search('##', road[a:]) is None and re.search('\.\.\.', road[b-2:d+1]) is not None:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import re
n, a, b, c, d = map(int, input().split())
road = input()
if c < d:
    if re.search('##', road[a:]) is None:
        print('Yes')
    else:
        print('No')

elif c > d:
    if re.search('##', road[a:]) is None and re.search('\.\.\.', road[b-2:]) is not None:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import re
n, a, b, c, d = map(int, input().split())
road = input()
if c < d:
    if re.search('##', road[a:]) is None:
        print('Yes')
    else:
        print('No')

elif c > d:
    if re.search('##', road[a:]) is None and re.search('\.\.\.', road[b:]) is not None:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

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

    ret = 'No'
    if C<D:
        pathBtoD=S[B:D]
        pathAtoC=S[A:C]
        if pathBtoD.find('##')==-1 and pathAtoC.find('##')==-1:
            ret = 'Yes'
    else:
        pathBtoD=S[B:D]
        pathAtoC=S[A:C]
        pathBtoD2 = S[B-1:D]
        if pathBtoD.find('##')==-1 and pathAtoC.find('##')==-1:
            if pathBtoD2.find('...')!=-1:
                ret = 'Yes'
    print(ret)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

    ret = 'No'
    if C<D:
        pathBtoD=S[B:D]
        pathAtoC=S[A:C]
        if pathBtoD.find('##')==-1 and pathAtoC.find('##')==-1:
            ret = 'Yes'
    else:
        pathBtoD=S[B:D]
        pathAtoC=S[A:C]
        if pathBtoD.find('##')==-1 and pathAtoC.find('##')==-1:
            pathBtoD2 = S[B-1:D+1]
            if pathBtoD2.find('...')!=-1:
                ret = 'Yes'
    print(ret)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(lambda x:int(x)-1,input().split())
n+=1
s = input()

import sys
sys.setrecursionlimit(10**8)

def solve(a,b,c,d):
    if a==c and b==d:
        print('Yes')
        sys.exit()
    elif a>c or b>d:
        return
    else:
        if a+1<len(s):
            if s[a+1]=='.':
                solve(a+1,b,c,d)
        if a+2<len(s):
            if s[a+2]=='.':
                solve(a+2,b,c,d)
        if b+1<len(s):
            if s[b+1]=='.':
                solve(a,b+1,c,d)
        if b+2<len(s):
            if s[b+2]=='.':
                solve(a,b+2,c,d)
solve(a,b,c,d)
print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
if C<D:
    if "##" not in S[A-1:D]:
        print("Yes")
    else:
        print("No")
elif D<C:
    if "##" not in S[A-1:C] and "..." 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 C<D:
    if "##" not in S[A-1:D-1]:
        print("Yes")
    else:
        print("No")
elif D<C:
    if "##" not in S[A-1:C-1] and "..." in S[B-1:D-1]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
if S[A-1]!="#" and S[B-1]!="#" and S[C-1]!="#" and S[D-1]!="#":
    if "##" not in S:
        if D<C:
            if "..." in S:
                print("Yes")
            else:
                print("No")
        else:
            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()

from sys import exit

# check
goal = max(C, D)
if "##" in S[A-1:goal]:
    print("No")
    exit()

if C < D:
    # Bから先に動く
    print("Yes")

else:
    # 入れ替わる必要がある

    # cehck : 初期値で入れ替えられる
    if "..." in S[B-2:D]:
    # if ('...' in S[B-1:D]) or ('...' in S[B-2:B+1]) or ('...' in S[D-2:D+1]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

from sys import exit

# check
goal = max([C, D])
if "##" in S[:goal]:
    print("No")
    exit()

if C < D:
    # Bから先に動く
    print("Yes")

else:
    # 入れ替わる必要がある

    # cehck : 初期値で入れ替えられる
    # if "..." in S[B-2:D]:
    if ('...' in S[B-1:D]) or ('...' in S[B-2:B+1]) or ('...' in S[D-2:D+1]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

from sys import exit

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

if C < D:
    # Bから先に動く
    print("Yes")

else:
    # 入れ替わる必要がある

    # cehck : 初期値で入れ替えられる
    # if "..." in S[B-2:D]:
    if ('...' in S[B-1:D]) or ('...' in S[B-2:B+1]) or ('...' in S[D-2:D+1]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

from sys import exit

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

if C < D:
    # Bから先に動く
    print("Yes")

else:
    # 入れ替わる必要がある

    # cehck : 初期値で入れ替えられる
    if "..." in S[B-2:D]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

from sys import exit

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

if C < D:
    # Bから先に動く
    print("Yes")

else:
    # 入れ替わる必要がある

    # cehck : 初期値で入れ替えられる
    if (A+1 == B and S[B] == ".") or (S[B] == "." and S[B-2] == "."):
        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()

from sys import exit

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

if C < D:
    # Bから先に動く
    print("Yes")

else:
    # 入れ替わる必要がある

    # cehck : 初期値で入れ替えられる
    if (A+1 == B and S[B] == ".") or (S[B] == "." and S[B-2] == "."):
        print("Yes")
    else:
        if "..." in S[B:D]:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

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

from sys import exit

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

if C < D:
    # Bから先に動く
    print("Yes")

else:
    # 入れ替わる必要がある

    # cehck : 初期値で入れ替えられる
    if (A+1 == B and S[B] == ".") or (S[B] == "." and S[B-2] == "."):
        print("Yes")
    else:
        if ".." in S[B:D]:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

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

from itertools import groupby 

gr = groupby(s)

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

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


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

Submission status: Wrong Answer

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

from itertools import groupby 

gr = groupby(s)

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

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


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

Submission status: Wrong Answer

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

from itertools import groupby 

gr = groupby(s)

for k ,v in gr:
    if k=='#' and len(list(v))>=2:
        print('No')
        exit(0)

if c<b:
    print('Yes')
else:
    if c<d:
        print('Yes')
    else:
        flg =0
        for i in range(b-1,d-2):
            if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
                flg=1
            else:
                if flg==1:
                    continue
                else:
                    flg=0
        
        if flg==1:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

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

def move(a,s):
    ar = a
    while(ar<n-2):
        if(s[ar+2]=='.'):
            ar += 2
        elif(s[ar+1]=='.'):
            ar +=1
        else:
            break
    if(ar!=n-1):
        ar+=(s[ar+1]=='.')
    return ar

def pr_end(x):
    if(x):
        print('Yes')
    else:
        print('No')
    exit()

ar = move(a,s)
br = move(b,s)

if(c<d):
    if(c<=ar)&(d<=br):
        pr_end(1)
    else:
        pr_end(0)

if(ar!=br):
    pr_end(0)

for i in range(b-1,d-1):
    if(s[i:i+3] =='...'):
        if(c<=ar)&(d<=br):
            pr_end(1)
        else:
            pr_end(0)

pr_end(0)

Submission status: Wrong Answer

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

def move(a,s):
    ar = a
    while(ar<n-2):
        if(s[ar+2]=='.'):
            ar += 2
        elif(s[ar+1]=='.'):
            ar +=1
        else:
            break
    if(ar!=n-1):
        ar+=(s[ar+1]=='.')
    return ar

def pr_end(x):
    if(x):
        print('Yes')
    else:
        print('No')
    exit()

ar = move(a,s)
br = move(b,s)

if(c<d):
    if(c<=ar)&(d<=br):
        pr_end(1)
    else:
        pr_end(0)

for i in range(b-1,d-1):
    if(s[i:i+3] =='...'):
        if(c<=ar)&(d<=br):
            pr_end(1)
        else:
            pr_end(0)

pr_end(0)

Submission status: Wrong Answer

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

def move(al,ar,s):
    while(al>1):
        if(s[al-2]=='.'):
            al -= 2
        elif(s[al-1]=='.'):
            al-=1
        else:
            break
    if(al!=0):
        al-=(s[al-1]=='.')
    while(ar<n-2):
        if(s[ar+2]=='.'):
            ar += 2
        elif(s[ar+1]=='.'):
            ar +=1
        else:
            break
    if(ar!=n-1):
        ar+=(s[ar+1]=='.')
    return al,ar

def pr_end(x):
    if(x):
        print('Yes')
    else:
        print('No')
    exit()

al,ar = move(a-1,a-1,s)
bl,br = move(b-1,b-1,s)

# print(al,ar,bl,br,c,d)

if(c<d):
    if(al<=c-1<=ar)&(bl<=d-1<=br):
        pr_end(1)
    else:
        pr_end(0)

if(al!=bl):
    pr_end(0)

for i in range(al,ar-1):
    if(s[i:i+3] =='...'):
        if(al<=c-1<=ar)&(bl<=d-1<=br):
            pr_end(1)
        else:
            pr_end(1)

pr_end(0)

Submission status: Wrong Answer

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

def move(al,ar,s):
    while(al>1):
        if(s[al-2]=='.'):
            al -= 2
        elif(s[al-1]=='.'):
            al-=1
        else:
            break
    if(al!=0):
        al-=(s[al-1]=='.')
    while(ar<n-2):
        if(s[ar+2]=='.'):
            ar += 2
        elif(s[ar+1]=='.'):
            ar +=1
        else:
            break
    if(ar!=n-1):
        ar+=(s[ar+1]=='.')
    return al,ar

def pr_end(x):
    if(x):
        print('Yes')
    else:
        print('No')
    exit()

al,ar = move(a-1,a-1,s)
bl,br = move(b-1,b-1,s)

# print(al,ar,bl,br,c,d)

if(c<d):
    if(al<=c-1<=ar)&(bl<=d-1<=br):
        pr_end(1)
    else:
        pr_end(0)

if(al!=bl):
    pr_end(0)

for i in range(al,ar-1):
    if(s[i:i+3] =='...'):
        if(al<=c-1<=ar)&(bl<=d-1<=br):
            pr_end(0)
        else:
            pr_end(1)

pr_end(0)

Submission status: Wrong Answer

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

def move(al,ar,s):
    while(al>1):
        if(s[al-2]=='.'):
            al -= 2
        elif(s[al-1]=='.'):
            al-=1
        else:
            break
    if(al!=0):
        al-=(s[al-1]=='.')
    while(ar<n-2):
        if(s[ar+2]=='.'):
            ar += 2
        elif(s[ar+1]=='.'):
            ar +=1
        else:
            break
    if(ar!=n-1):
        ar+=(s[ar+1]=='.')
    return al,ar

def pr_end(x):
    if(x):
        print('Yes')
    else:
        print('No')
    exit()

al,ar = move(a-1,a-1,s)
bl,br = move(b-1,b-1,s)

# print(al,ar,bl,br,c,d)

if(c<d):
    if(al<=c-1<=ar)&(bl<=d-1<=br):
        pr_end(1)
    else:
        pr_end(0)

if(al!=bl):
    pr_end(0)

for i in range(al,ar-1):
    if(s[i:i+3] =='...'):
        if(al<=c-1<=ar)&(bl<=d-1<=br):
            pr_end(1)
        else:
            pr_end(0)

pr_end(0)

Submission status: Wrong Answer

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

def move(al,ar,s):
    while(al>1):
        if(s[al-2]=='.'):
            al -= 2
        elif(s[al-1]=='.'):
            al-=1
        else:
            break
    if(al!=0):
        al-=(s[al-1]=='.')
    while(ar<n-2):
        if(s[ar+2]=='.'):
            ar += 2
        elif(s[ar+1]=='.'):
            ar +=1
        else:
            break
    if(ar!=n-1):
        ar+=(s[ar+1]=='.')
    return al,ar

al,ar = move(a-1,a-1,s)
bl,br = move(b-1,b-1,s)

if(c<d):
    if(al<=c-1<=ar)&(bl<=d-1<=br):
        print('Yes')
    else:
        print('No')
    exit()

if(al!=bl):
    print('No')
    exit()

for i in range(al,ar-1):
    if(s[i:i+3] =='...'):
        if(al<=c-1<=ar)&(bl<=d-1<=br):
            print('Yes')
        else:
            print('No')
        exit()

print('No')

Submission status: Wrong Answer

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

def move(al,ar,s):
    while(al>1):
        if(s[al-2]=='.'):
            al -= 2
        elif(s[al-1]=='.'):
            al-=1
        else:
            break
    if(al!=0):
        al-=(s[al-1]=='.')
    while(ar<n-2):
        if(s[ar+2]=='.'):
            ar += 2
        elif(s[ar+1]=='.'):
            ar +=1
        else:
            break
    if(ar!=n-1):
        ar+=(s[ar+1]=='.')
    return al,ar

al,ar = move(a-1,a-1,s)
bl,br = move(b-1,b-1,s)

print(al,ar,bl,br,c,d)

if(c<d):
    if(al<=c-1<=ar)&(bl<=d-1<=br):
        print('Yes')
    else:
        print('No')
    exit()

if(al!=bl):
    print('No')
    exit()

for i in range(al,ar-1):
    if(s[i:i+3] =='...'):
        if(al<=c-1<=ar)&(bl<=d-1<=br):
            print('Yes')
        else:
            print('No')
        exit()

print('No')

Submission status: Wrong Answer

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

def move(al,ar,s):
    while(al>1):
        if(s[al-2]=='.'):
            al -= 2
        elif(s[al-1]=='.'):
            al-=1
        else:
            break
    if(al!=0):
        al-=(s[al-1]=='.')
    while(ar<n-2):
        if(s[ar+2]=='.'):
            ar += 2
        elif(s[ar+1]=='.'):
            ar +=1
        else:
            break
    if(ar!=n-1):
        ar+=(s[ar+1]=='.')
    return al,ar

al,ar = move(a-1,a-1,s)
bl,br = move(b-1,b-1,s)

if(c<d):
    if(al<=c-1<=ar)&(bl<=d-1<=br):
        print('Yes')
    else:
        print('No')
    exit()

if(al!=bl):
    print('No')
    exit()

for i in range(al,ar+1):
    if(s[i:i+3] =='...'):
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############
N,A,B,C,D = IL()
S = S()

dA = [0 for i in range(N)]
dB = [0 for i in range(N)]

dA[A-1] = 1
dB[B-1] = 1

q = deque([A-1])
while q:
  x = q.pop()
  for i in [-2,-1,1,2]:
    nx = x+i
    if 0<=nx<N:
      if dA[nx] == 0 and S[nx]==".":
        dA[nx] = 1
        q.append(nx)

q = deque([B-1])
while q:
  x = q.pop()
  for i in [1,2]:
    nx = x+i
    if 0<=nx<N:
      if dB[nx] == 0 and S[nx]==".":
        dB[nx] = 1
        q.append(nx)

if dA[C-1] == dB[D-1] == 1:
  if C<D:
    print("Yes")
  else:
    count = 0
    MAX = 0
    prev = 0
    for c in dB[B-2:min(D+1,N-1)]:
      if c == 1:
        if prev == 1:
          count += 1
          MAX = max(MAX,count)
        else:
          count = 1
      prev = c
    if MAX >= 3:
      print("Yes")
    else:
      print("No")
else:
  print("No")