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:
#bin/usr/env python3

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

for i in s:
    s_li.append(i)

last = c
reach = True

if last < d:
    last = d

if c < d:
    for i in range(a-1,last-1):
        if(s_li[i] == "#" and s_li[i+1] == "#"):
            reach = False
            break

elif d < c:
    for i in range(a,last-1):
        if(s_li[i] == "#" and s_li[i+1] == "#"):
            reach = False
            break
        reach = False

        if(s_li[i-1] == "." and s_li[i] == "." and s_li[i+1] == "."):
            reach = True
            break

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

Submission status: Wrong Answer

Solution code:
#bin/usr/env python3

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

for i in s:
    s_li.append(i)

last = c
reach = True

if last < d:
    last = d

if c < d:
    for i in range(a-1,last-1):
        if(s_li[i] == "#" and s_li[i+1] == "#"):
            reach = False
            break

elif d < c:
    for i in range(a-1,last-1):
        if(s_li[i] == "#" and s_li[i+1] == "#"):
            reach = False
            break
        reach = False

        if(s_li[i-1] == "." and s_li[i] == "." and s_li[i+1] == "."):
            reach = True
            break

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

Submission status: Wrong Answer

Solution code:
def sai():
  n,a,b,c,d=map(int,input().split())
  s=input()
  for i in range(min(a,b),max(c,d)-1):
    if s[i]=='#' and s[i+1]=='#':
      return("NO")
  if (c>d):
    for i in range(min(a,b),max(c,d)-2):
      if s[i]=='.' and s[i+1]=="." and s[i+2]=='.':
        return("YES")
  else:
    return("YES")
  return("NO")

Submission status: Wrong Answer

Solution code:
def sai():
  n,a,b,c,d=map(int,input().split())
  s=input()
  for i in range(min(a,b),max(c,d)):
    if s[i]=='#' and s[i+1]=='#':
      return("NO")
  if (a<b and c>d) or(c<a and d>c):
    for i in range(min(a,b),max(c,d)-1):
      if s[i]=='.' and s[i+1]=="." and s[i+2]=='.':
        return("YES")
  else:
    return("YES")
  return("NO")

Submission status: Wrong Answer

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

max1 = 0
max2 = 0
count = 0

for i in s[a-1:max(c,d)]:
    if i == '#':
        count += 1
    else:
        max1 = max(max1,count)
        count = 0

count = 0

for i in s[b-2:d+1]:
    if i == '.':
        count += 1
    else:
        max2 = max(max2,count)
        count = 0

if max1 > 1:
    print('No')
else:
    if c > d:
        if max2 <= 2:
            print('No')
        else:
            print('Yes')
    else:
        print('Yes')

Submission status: Wrong Answer

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

max1 = 0
max2 = 0
count = 0

print(s[a-1:max(c,d)])
for i in s[a-1:max(c,d)]:
    if i == '#':
        count += 1
    else:
        max1 = max(max1,count)
        count = 0

count = 0

print(s[b-2:d+1])
for i in s[b-2:d+1]:
    if i == '.':
        count += 1
    else:
        max2 = max(max2,count)
        count = 0

if max1 > 1:
    print('No')
else:
    if c > d:
        if max2 <= 2:
            print('No')
        else:
            print('Yes')
    else:
        print('Yes')

Submission status: Wrong Answer

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

max1 = 0
max2 = 0
count = 0

for i in s:
    if i == '#':
        count += 1
    else:
        max1 = max(max1,count)
        count = 0

count = 0

for i in s[b-2:d+1]:
    if i == '.':
        count += 1
    else:
        max2 = max(max2,count)
        count = 0

if max1 > 1:
    print('No')
else:
    if c > d:
        if max2 <= 2:
            print('No')
        else:
            print('Yes')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
if '##' in S[A:C-1:] or '##' in S[B:D-1:]:
    print("No")
    exit()
swap = True if '...' in S[A-1:C:] and '...' in S[B-1:D:] else False
if S[B-2:B+1:] == '...':
    swap = True
if C > D and not swap:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
if '##' in S[A:C-1:] or '##' in S[B:D-1:]:
    print("No")
    exit()
swap = True if '...' in S[A:C:] and '...' in S[B:D:] else False
if C > D and not swap:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
if '##' in S[A:C-1:] or '##' in S[B:D-1:]:
    print("No")
    exit()
swap = True if '...' in S[A:C-1:] and '...' in S[B:D-1:] else False
if C > D and not swap:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split(" "))
e = input()
r = 0
n = 0
if "##" in e:
    print("No")
    exit()
if c < d:
    print("Yes")
else:
    f = e[b-1:c]
    if "..." in f:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split(" "))
e = input()
r = 0
n = 0
if "##" in e:
    print("No")
    exit()
if c < d:
    print("Yes")
else:
    f = e[b-1:d]
    if "..." in f:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split(" "))
ar = list(input())
r = 0
n = 0
for i in range(n):
    if ar[i] == "#":
        r += 1
    else:
        r = 0
    if r == 2:
        print("No")
        exit()
if c < d:
    print("Yes")
else:
    for i in range(b-1,d):
        if ar[i] == ".":
            n += 1
        else:
            n = 0
        if n == 3:
            print("Yes")
            exit()
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split(" "))
ar = list(input())
r = 0
n = 0
sw = ""
for i in range(n):
    if ar[i] == "#":
        r += 1
    else:
        r = 0
    if r == 2:
        print("No")
        exit()
if c < d:
    print("Yes")
else:
    for i in range(b,d+1):
        if ar[i] == ".":
            n += 1
        else:
            n = 0
        if n == 3:
            print("Yes")
            exit()
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split(" "))
ar = list(input())
r = 0
n = 0
sw = ""
sw2 = "OFF"
for i in ar:
    if i == "#":
        sw = "R"
    else:
        sw = "N"
    if sw == "R":
        r += 1
        n = 0
    else:
        n += 1
        r = 0
    if r == 2:
        print("No")
        exit()
    if n == 3:
        sw2 = "ON"
if c < d:
        print("Yes")
else:
    if sw2 == "ON":
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split(" "))
ar = list(input())
r = 0
n = 0
sw = ""
sw2 = "OFF"
for i in ar:
    if i == "#":
        sw = "R"
    else:
        sw = "N"
    if sw == "R":
        r += 1
        n = 0
    else:
        n += 1
        r = 0
    if r == 2:
        print("No")
        exit()
    if n == 3:
        sw2 = "ON"
if sw2 == "ON":
    print("Yes")
else:
    if c < d:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
from copy import*
n,a,b,c,d=map(int,input().split())
s=input()
if "##" in s[a-1:c] or "##" in s[b-1:d]:
    print("No")
else:
    if c<d:
        print("Yes")
    else:
        if "..." in s[b-1:d]:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
from copy import*
n,a,b,c,d=map(int,input().split())
s=input()
if "##" in s[a-1:c] or "##" in s[b-1:d]:
    print("No")
else:
    if c<d:
        print("Yes")
    else:
        if "..." in s[max(a,b):d]:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = [int(x) for x in input().split()]
s = ''.join(['#',input(),'#'])
if '##' in s[a:c+1] or '##' in s[b:d+1]:
	print("No")
else:
	if c<d:
		print("Yes")
	else:
		if '...' in s[b:d+2]:
			print("Yes")
		else:
			print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = [int(x) for x in input().split()]
s = ''.join(['#',input(),'#'])
if '##' in s[a:c+1] or '##' in s[b:d+1]:
	print("No")
else:
	if c<d:
		print("Yes")
	else:
		if '...' in s[b:d+1]:
			print("Yes")
		else:
			print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = [int(x) for x in input().split()]
s = ''.join(['.',input()])
if '##' in s[a:c+1] or '##' in s[b:d+1]:
	print("No")
elif c<d:
	print("Yes")
elif c>d:
	if '...' in s[b:d+1]:
		print("Yes")
	else:
		print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = [int(x) for x in input().split()]
s = ''.join(['.',input()])
if '##' in s[a:c] or '##' in s[b:d]:
	print("No")
elif c<d:
	print("Yes")
elif c>d:
	if '...' in s[b:d+1]:
		print("Yes")
	else:
		print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = [int(x) for x in input().split()]
s = ''.join(['.',input()])
rtb = True
if '###' in s[a:c] or '###' in s[b:d]:
	print("No")
	exit(0)
if c<d:
	print("Yes")
	exit(0)
elif c>d:
	if '...' in s[b:d+1]:
		print("Yes")
	else:
		print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = [int(x) for x in input().split()]
s = ''.join(['.',input()])
rtb = True
if '###' in s[a:c] or '###' in s[b:d]:
	print("No")
	exit(0)
if c<d:
	print("Yes")
	exit(0)
elif c>d:
	if '...' in s[b:d]:
		print("Yes")
	else:
		print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = [int(x) for x in input().split()]
s = input()

def check(s,a,b):
    tmp = s[a-1:b]
    if '##' in tmp:
        return False
    else:
        return True

def check2(s,a,b):
    tmp = s[max(a-1,0):min(b+1,n)]
    if '...' in tmp:
        return True
    else:
        return False


if c < d:
    if check(s,a,c) and check(s,b,d):
        print('Yes')
    else:
        print('No')
else:
    if check(s,a,c) and check(s,b,d) and check2(s,b,d):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = [int(x) for x in input().split()]
s = input()

def check(s,a,b):
    tmp = s[a-1:b]
    if '##' in tmp:
        return False
    else:
        return True

def check2(s,a,b):
    tmp = s[a-1:b]
    if '...' in tmp:
        return True
    else:
        return False


if c < d:
    if check(s,a,c) and check(s,b,d):
        print('Yes')
    else:
        print('No')
else:
    if check(s,a,c) and check(s,b,d) and check2(s,b,d):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from collections import deque

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

# canGo = {}

# canGo[(C, D)] = True
# canGo[(C - 1, D)] = S[C - 1] == '.' and D != C - 1
# canGo[(C - 2, D)] = S[C - 2] == '.' and D != C - 2

# canGo[(C, D - 1)] = S[D - 1] == '.' and C != D - 1
# canGo[(C, D - 2)] = S[D - 2] == '.' and C != D - 2

# for i in reversed(range(C)):
#     for j in reversed(range(D)):
#         print(i, j)
#         c = [
#             canGo[(i + 1, j)],
#             canGo[(i, j + 1)]
#         ]
#         if i < C - 1:
#             c.append(canGo[(i + 2, j)])
#         if j < D - 1:
#             c.append(canGo[(i, j + 2)])

#         cg = S[i] == '.' and S[j] == '.' and any(c)
#         canGo[(i, j)] = cg

s = deque()
s.append((A, B))
r = False
# print(A, "to", C)
# print(B, "to", D)
while s:
    a, b = s.pop()
    # print(S[:a] + 'A' + S[a+1:b] + 'B' + S[b+1:])
    if b < D:
        if S[b + 1] == '#' and S[b + 2] == '#':
            break
        if S[b + 1] == '.':
            s.appendleft((a, b + 1))
        if b + 2 <= D and S[b + 2] == '.':
            s.appendleft((a, b + 2))
    else:
        if a == C:
            r = True
            break
        if a + 1 != b and S[a + 1] == '.':
            s.appendleft((a + 1, b))
        if a + 2 <= C and a + 2 != b and S[a + 2] == '.':
            s.appendleft((a + 2, b))

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

Submission status: Wrong Answer

Solution code:
from collections import deque

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

# canGo = {}

# canGo[(C, D)] = True
# canGo[(C - 1, D)] = S[C - 1] == '.' and D != C - 1
# canGo[(C - 2, D)] = S[C - 2] == '.' and D != C - 2

# canGo[(C, D - 1)] = S[D - 1] == '.' and C != D - 1
# canGo[(C, D - 2)] = S[D - 2] == '.' and C != D - 2

# for i in reversed(range(C)):
#     for j in reversed(range(D)):
#         print(i, j)
#         c = [
#             canGo[(i + 1, j)],
#             canGo[(i, j + 1)]
#         ]
#         if i < C - 1:
#             c.append(canGo[(i + 2, j)])
#         if j < D - 1:
#             c.append(canGo[(i, j + 2)])

#         cg = S[i] == '.' and S[j] == '.' and any(c)
#         canGo[(i, j)] = cg

s = deque()
s.append((A, B))
r = False
while s:
    a, b = s.pop()
    if b < D:
        if S[b + 1] == '#' and S[b + 2] == '#':
            break
        if S[b + 1] == '.':
            s.appendleft((a, b + 1))
        if b + 2 <= D and S[b + 2] == '.':
            s.appendleft((a, b + 2))
    else:
        if a == C:
            r = True
            break
        if S[a + 1] == '.':
            s.appendleft((a + 1, b))
        if a + 2 <= C and S[a + 2] == '.':
            s.appendleft((a + 2, b))

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

Submission status: Wrong Answer

Solution code:

n,a,b,c,d = map(int, input().split())
a -= 1
b -= 1
s = input()
ans = "No"
snk = s[a:c].count("##")
fnk = s[b:d].count("##")
if snk == 0 and fnk == 0:
  if c > d:
    if s[b-1:d+1].count("...") >= 0:
      ans = "Yes"
  else:
    ans = "Yes"
    
print(ans)

Submission status: Wrong Answer

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

s = input()
ans = "No"
snk = s[a-1:c].count("##")
fnk = s[b-1:d].count("##")
if snk <= 0 and fnk <= 0:
  if c > d:
    if s[b-2:d+1].count("...") <= 0:
      ans = "Yes"
  else:
    ans = "Yes"
    
print(ans)

Submission status: Wrong Answer

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

s = input()
ans = "No"
snk = s[a:c].count("##")
fnk = s[b:d].count("##")
if snk <= 0 and fnk <= 0:
  if c > d:
    if s[b-1:d+1].count("...") <= 0:
      ans = "Yes"
  else:
    ans = "Yes"
    
print(ans)

Submission status: Wrong Answer

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

s = input()

#すぬけ君のゴールがふぬけ君より右にある場合
if c > d:
  #ゴールより左かつふぬけ君の右に岩のない部分が3つ連続していれば、すぬけ君はふぬけ君を追い越すことができる
  if s[a:c].count("##") == 0 and s[b:d].count("##") == 0:
    if s[b-1:d+1].count("...") >= 1:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  if s[a:c].count("##") == 0 and s[b:d].count("##") == 0:
    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:
  #ゴールより左かつふぬけ君の右に岩のない部分が3つ連続していれば、すぬけ君はふぬけ君を追い越すことができる
  if s[a:c].count("##") == 0 and s[b:d].count("##") == 0:
    if s[b-1:d+1].count("...") >= 1:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  if s[a:].count("##") == 0:
    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:
  #ゴールより左かつふぬけ君の右に岩のない部分が3つ連続していれば、すぬけ君はふぬけ君を追い越すことができる
  if s[a:].count("##") == 0:
    if s[b-1:d+1].count("...") >= 1:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  if s[a:].count("##") == 0:
    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:
  #ゴールより左かつふぬけ君の右に岩のない部分が3つ連続していれば、すぬけ君はふぬけ君を追い越すことができる
  if s[a:].count("##") == 0:
    if s[b-1:d+2].count("...") >= 1:
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  if s[a:].count("##") == 0:
    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:
  #ゴールより左かつふぬけ君の右に岩のない部分が3つ連続していれば、すぬけ君はふぬけ君を追い越すことができる
  
  if s[a:].count("##") == 0:
    for i in range(b,d):
      if s[i-1] == s[i] == s[i+1] == ".":
        print("Yes")
        exit()
  else:
    print("No")
else:
  if s[a:].count("##") == 0:
    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:
  #ゴールより左かつふぬけ君の右に岩のない部分が3つ連続していれば、すぬけ君はふぬけ君を追い越すことができる
  
  if s[b:d+1].count("...") >= 1 and s[a:].count("##") == 0:
    print("Yes")
  else:
    print("No")
else:
  if s[a:].count("##") == 0:
    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:
  #ゴールより左かつふぬけ君の右に岩のない部分が3つ連続していれば、すぬけ君はふぬけ君を追い越すことができる
  if s[b+1:d].count("...") >= 1 and s[a:].count("##") == 0:
    print("Yes")
  else:
    print("No")
else:
  if s[a:].count("##") == 0:
    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:
  #ゴールより左かつふぬけ君の右に岩のない部分が3つ連続していれば、すぬけ君はふぬけ君を追い越すことができる
  if s[b+1:c].count("...") >= 1 and s[a:].count("##") == 0:
    print("Yes")
  else:
    print("No")
else:
  if s[a:].count("##") == 0:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=[True if i=='.' else False for i in list(input())]
if c<d:
    for i in range(n-1):
        if all(s[i:i+2]):
            print('Yes')
            exit()
else:
    for i in range(n-2):
        if all(s[i:i+3]):
            print('Yes')
            exit()
print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = [int(x) for x in input().split()]
S = input()
if('##'in S[min(A,B)-1:max(C,D)]):
    print('No')
else:
    flag = False
    if((B-A)*(D-C)<0):
        if('...'in S[max(A,B)-2:min(C,D)]):
            flag = True
    else:
        flag = True
    if(flag):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = [int(x) for x in input().split()]
S = input()
if('##'in S[min(A,B)-1:max(C,D)]):
    print('No')
else:
    flag = False
    if((B-A)*(D-C)<0):
        if('..'in S[max(A,B):min(C,D)]):
            flag = True
        if('...'==S[max(A,B)-2:max(A,B)+1]):
            flag = True
    else:
        flag = True
    if(flag):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
sac = s[a-1:c]
sbd = s[b-1:d]
ac = "##" not in sac
bd = "##" not in sbd
if c < d:
    if ac and bd:
        print("Yes")
    else:
        print("No")
else:
    if ac and bd and "..." in sbd:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
def CanKenKen(List,Start,Goal):
    Q=List[Start:Goal+1]
    return all([i=="." or Q[n+1]=="." or n==Goal-Start for n,i in enumerate(Q[:-1])])
N,A,B,C,D=map(int,input().split())
A,B,C,D=map(lambda x:x-1 ,[A,B,C,D])#0-indexed
S=list(input())

if A<C<B<D:
    if CanKenKen(S,A,C) and CanKenKen(S,B,D):
        print("Yes")
    else:print("No")
elif A<B<D<C:
    if CanKenKen(S,A,C):
        oikosi=0
        if B>=2:Q=S[B-2:D+2]
        else:Q=S[:D+2]
        for n,i in enumerate(Q):
            if i=="." and Q[n+1]=="." and Q[n+2]==".":
                oikosi=1
                break
            if n==D-B-2:break
        if oikosi:print("Yes")
        else:print("No")
    else:print("No")
elif A<B<C<D:
    if CanKenKen(S,A,D):print("Yes")
    else:print("No")

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0
cntA = 0
for i in range(0, len(s) - 1):
    if s[i] == 'A':
        cntA += 1
    elif s[i: i + 2] == "BC":
        ans += cntA
    elif i > 0 and s[i - 1: i + 1] == "BC":
        continue
    else:
        cntA = 0
print(ans)

Submission status: Wrong Answer

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

S0 = S[:A]
Sa = S[A-1:C]
Sb = S[B-2:D]
F = max(C,D)
S1 = S[F:]
#if S0.rfind('##')>=0 and S1.find('##')>=0 :
#    Sfe = S[S0.rfind('##'):(F+S1.find('##'))]
#elif S0.rfind('##')>=0 :
#    Sfe = S[S0.rfind('##'):]
#elif S1.find('##')>=0 :
#    Sfe = S[:(F+S1.find('##'))]
#else :
#    Sfe = S


#if S.find('##')>=0 and A<S.find('ABC')<C or B<S.find('ABC')<D:
if Sa.find('##')>=0 or Sb.find('##')>=0:
    ans = "No"

if A<B<D<C and not '...' in Sb:
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

S0 = S[:A]
Sa = S[A-1:C]
Sb = S[B-1:D]
F = max(C,D)
S1 = S[F:]
#if S0.rfind('##')>=0 and S1.find('##')>=0 :
#    Sfe = S[S0.rfind('##'):(F+S1.find('##'))]
#elif S0.rfind('##')>=0 :
#    Sfe = S[S0.rfind('##'):]
#elif S1.find('##')>=0 :
#    Sfe = S[:(F+S1.find('##'))]
#else :
#    Sfe = S


#if S.find('##')>=0 and A<S.find('ABC')<C or B<S.find('ABC')<D:
if Sa.find('##')>=0 or Sb.find('##')>=0:
    ans = "No"

if A<B<D<C and not '...' in Sb:
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

S0 = S[:A]
Sa = S[A:C]
Sb = S[B:D]
F = max(C,D)
S1 = S[F:]
if S0.rfind('##')>=0 and S1.find('##')>=0 :
    Sfe = S[S0.rfind('##'):(F+S1.find('##'))]
#elif S0.rfind('##')>=0 :
#    Sfe = S[S0.rfind('##'):]
#elif S1.find('##')>=0 :
#    Sfe = S[:(F+S1.find('##'))]
else :
    Sfe = S


#if S.find('##')>=0 and A<S.find('ABC')<C or B<S.find('ABC')<D:
if Sa.find('##')>=0 or Sb.find('##')>=0:
    ans = "No"

if A<B<D<C and not '...' in Sb:
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

S0 = S[:A]
Sa = S[A:C]
Sb = S[B:D]
F = max(C,D)
S1 = S[F:]
if S0.rfind('##')>=0 and S1.find('##')>=0 :
    Sfe = S[S0.rfind('##'):(F+S1.find('##'))]
#elif S0.rfind('##')>=0 :
#    Sfe = S[S0.rfind('##'):]
#elif S1.find('##')>=0 :
#    Sfe = S[:(F+S1.find('##'))]
else :
    Sfe = S


#if S.find('##')>=0 and A<S.find('ABC')<C or B<S.find('ABC')<D:
if Sa.find('##')>=0 or Sb.find('##')>=0:
    ans = "No"

if A<B<D<C and not '...' in S:
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

S0 = S[:A]
Sa = S[A:C]
Sb = S[B:D]
F = max(C,D)
S1 = S[F:]
if S0.rfind('##')>=0 and S1.find('##')>=0 :
    Sfe = S[S0.rfind('##'):(F+S1.find('##'))]
#elif S0.rfind('##')>=0 :
#    Sfe = S[S0.rfind('##'):]
#elif S1.find('##')>=0 :
#    Sfe = S[:(F+S1.find('##'))]
else :
    Sfe = S


#if S.find('##')>=0 and A<S.find('ABC')<C or B<S.find('ABC')<D:
if Sa.find('##')>=0 or Sb.find('##')>=0:
    ans = "No"

if A<B<D<C and not '...' in Sfe:
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

S0 = S[:A]
Sa = S[A:C]
Sb = S[B:D]
F = max(C,D)
S1 = S[F:]
if S0.rfind('##')>=0 and S1.find('##')>=0 :
    Sfe = S[S0.rfind('##'):(F+S1.find('##'))]
elif S0.rfind('##')>=0 :
    Sfe = S[S0.rfind('##'):]
elif S1.find('##')>=0 :
    Sfe = S[:(F+S1.find('##'))]
else :
    Sfe = S


#if S.find('##')>=0 and A<S.find('ABC')<C or B<S.find('ABC')<D:
if Sa.find('##')>=0 or Sb.find('##')>=0:
    ans = "No"

if A<B<D<C and not '...' in Sa:
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

S0 = S[:A]
Sa = S[A:C]
Sb = S[B:D]
F = max(C,D)
S1 = S[F:]
if S0.rfind('##')>=0 and S1.find('##')>=0 :
    Sfe = S[S0.rfind('##'):(F+S1.find('##'))]
elif S0.rfind('##')>=0 :
    Sfe = S[S0.rfind('##'):]
elif S1.find('##')>=0 :
    Sfe = S[:(F+S1.find('##'))]
else :
    Sfe = S


#if S.find('##')>=0 and A<S.find('ABC')<C or B<S.find('ABC')<D:
if Sa.find('##')>=0 or Sb.find('##')>=0:
    ans = "No"

if A<B<D<C and not '...' in Sfe:
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

S0 = S[:A]
Sa = S[A:C]
Sb = S[B:D]
S1 = S[D:]
if S0.rfind('##')>=0 and S1.find('##')>=0 :
    Sfe = S[S0.rfind('##'):(D+S1.find('##'))]
elif S0.rfind('##')>=0 :
    Sfe = S[S0.rfind('##'):]
elif S1.find('##')>=0 :
    Sfe = S[:(D+S1.find('##'))]
else :
    Sfe = S


#if S.find('##')>=0 and A<S.find('ABC')<C or B<S.find('ABC')<D:
if Sa.find('##')>=0 or Sb.find('##')>=0:
    ans = "No"

if A<B<D<C and not '...' in Sfe:
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

S0 = S[:A]
Sa = S[A:C]
Sb = S[B:D]
S1 = S[D:]
if S0.rfind('##')>=0 and S1.find('##')>=0 :
    Sfe = S[S0.rfind('##'):S1.find('##')]
elif S0.rfind('##')>=0 :
    Sfe = S[S0.rfind('##'):]
elif S1.find('##')>=0 :
    Sfe = S[:S1.find('##')]
else :
    Sfe = S


#if S.find('##')>=0 and A<S.find('ABC')<C or B<S.find('ABC')<D:
if Sa.find('##')>=0 or Sb.find('##')>=0:
    ans = "No"

if A<B<D<C and not '...' in Sb:
    ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = [int(i) for i in input().split(" ")]
s = "_" + input() + "_"

def no2rock(l, r):
    global s
    for i in range(l + 1, r + 1):
        if s[i - 1] == "#" and s[i] == "#":
            return False
    return True

def rest(l, r):
    global s
    for i in range(l + 1, r + 1):
        if s[i - 1] == "." and s[i] == "." and s[i + 1] == ".":
            return True
    return False

if c < d:
    if no2rock(a, c) and no2rock(b, d):
        print("Yes")
    else:
        print("No")
else:
    if no2rock(a, c) and no2rock(b, d) and rest(b, d):
        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()

def no2rock(l, r):
    global s
    for i in range(l + 1, r + 1):
        if s[i - 1] == "#" and s[i] == "#":
            return False
    return True

def rest(l, r):
    global s
    for i in range(l + 2, r + 1):
        if s[i - 2] == "." and s[i - 1] == "." and s[i] == ".":
            return True
    return False

if c < d:
    if no2rock(a, c) and no2rock(b, d):
        print("Yes")
    else:
        print("No")
else:
    if no2rock(a, c) and no2rock(b, d) and rest(b, d):
        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()

def no2rock(l, r):
    global s
    for i in range(l + 1, r):
        if s[i - 1] == "#" and s[i] == "#":
            return False
    return True

def rest(l, r):
    global s
    for i in range(l + 2, r):
        if s[i - 2] == "." and s[i - 1] == "." and s[i] == ".":
            return True
    return False

if c < d:
    if no2rock(a, c) and no2rock(b, d):
        print("Yes")
    else:
        print("No")
else:
    if no2rock(a, c) and no2rock(b, d) and rest(b, d):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = [int(i) for i in input().split()]
s = input()
res = "YES"
e = max(c,d)
if "##" in s[a-1:e-1]:
	res = "NO"
elif c > d:
	if "..." not in s[b-2:d+1]:
		res = "NO"
print(res)

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = [int(i) for i in input().split()]
s = input()
res = "YES"
e = max(c,d)
if "##" in s[a-1:e-1]:
	res = "NO"
elif c > d:
	print(s[b-2:d+1])
	if "..." not in s[b-2:d+1]:
		res = "NO"
print(res)

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

if '##' in S[A:C] or '##' in S[B:D]:
    print("No")
    exit()
if C > D:
    if  '...' not in S[B-2:D+1]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

# AからDの間に岩が二つ連続で置かれている箇所があれば不可
# C > D の場合、すぬけ君はふぬけ君を追い越す必要があることに注意
ans = (
    'Yes' if ('##' not in S[(A - 1):max(C, D)]) and (
        C < D or
        '...' in S[(A - 1):(D + 1)]
    ) else
    'No'
)

# 出力
print(ans)

Submission status: Wrong Answer

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

# AからDの間に岩が二つ連続で置かれている箇所があれば不可
# C > D の場合、すぬけ君はふぬけ君を追い越す必要があることに注意
ans = (
    'Yes' if ('##' not in S[(A - 1):D]) and (
        C < D or
        '...' in S[(A - 1):(D + 1)]
    ) else
    'No'
)

# 出力
print(ans)