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:
# 3パターンある
# 1. a < c < b < d
# 2. a < b < c < d
# 3. a < b < d < c
# 1はa-cとb-dで独立して考える それぞれの間に#が連続してなかったらおｋ
# 2はb-dが成功したあとa-cが成功すればおｋ
# 3はa-cが成功すればおｋ
# という考察を深めると、cとdの位置関係だけに注目すればいいことがわかる（わかる？）
# d < cのとき、aがcにいくためにbを飛び越えなければならない。飛び越えるには"..."の真ん中を避難地帯としてbを置くしかない

n, a, b, c, d = map(int, input().split())
s = list(input())
if c < d:
    if "##" not in "".join(s[a - 1 : c]) and "##" not in "".join(s[b - 1 : d]):
        print("Yes")
    else:
        print("No")
else:
    # aがゴールできる -> bがゴールできる（aの通る経路はすべてbも通るので）
    # bがゴールできる -> bのゴール後、aがゴールできるとは限らない
    tmp_s1, tmp_s2 = s[:], s[:]
    tmp_s1[d - 1] = "#"
    tmp_s2[c - 1] = "#"
    if (
        "##" not in "".join(s[a - 1 : c])
        and "..." in "".join(s[b - 1 : d])
        or ("##" not in "".join(tmp_s1[a - 1 : c]))
        or ("##" not in "".join(tmp_s2[b - 1 : d]))
    ):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# 3パターンある
# 1. a < c < b < d
# 2. a < b < c < d
# 3. a < b < d < c
# 1はa-cとb-dで独立して考える それぞれの間に#が連続してなかったらおｋ
# 2はb-dが成功したあとa-cが成功すればおｋ
# 3はa-cが成功すればおｋ
# という考察を深めると、cとdの位置関係だけに注目すればいいことがわかる（わかる？）
# d < cのとき、aがcにいくためにbを飛び越えなければならない。飛び越えるには"..."の真ん中を避難地帯としてbを置くしかない

n, a, b, c, d = map(int, input().split())
s = list(input())
if c < d:
    if "##" not in "".join(s[a - 1 : c]) and "##" not in "".join(s[b - 1 : d]):
        print("Yes")
    else:
        print("No")
else:
    # aがゴールできる -> bがゴールできる（aの通る経路はすべてbも通るので）
    # bがゴールできる -> bのゴール後、aがゴールできるとは限らない
    tmp_s1, tmp_s2 = s[:], s[:]
    tmp_s1[d - 1] = "#"
    tmp_s2[c - 1] = "#"
    if (
        "##" not in "".join(s[a - 1 : c])
        and ("##" not in "".join(tmp_s2[b - 1 : d]) or "..." in "".join(s[b - 1 : d]))
    ) or ("##" not in "".join(tmp_s1[a - 1 : c])):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# 3パターンある
# 1. a < c < b < d
# 2. a < b < c < d
# 3. a < b < d < c
# 1はa-cとb-dで独立して考える それぞれの間に#が連続してなかったらおｋ
# 2はb-dが成功したあとa-cが成功すればおｋ
# 3はa-cが成功すればおｋ
# という考察を深めると、cとdの位置関係だけに注目すればいいことがわかる（わかる？）
# d < cのとき、aがcにいくためにbを飛び越えなければならない。飛び越えるには"..."の真ん中を避難地帯としてbを置くしかない

n, a, b, c, d = map(int, input().split())
s = list(input())
if c < d:
    if "##" not in "".join(s[a - 1 : c]) and "##" not in "".join(s[b - 1 : d]):
        print("Yes")
    else:
        print("No")
else:
    # aがゴールできる -> bがゴールできる（aの通る経路はすべてbも通るので）
    # bがゴールできる -> bのゴール後、aがゴールできるとは限らない
    tmp_s = s[:]
    tmp_s[d - 1] = "#"
    if ("##" not in "".join(s[a - 1 : c]) and "..." in "".join(s[b - 1 : d])) or (
        "##" not in "".join(tmp_s[a - 1 : c])
    ):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# 3パターンある
# 1. a < c < b < d
# 2. a < b < c < d
# 3. a < b < d < c
# 1はa-cとb-dで独立して考える それぞれの間に#が連続してなかったらおｋ
# 2はb-dが成功したあとa-cが成功すればおｋ
# 3はa-cが成功すればおｋ
# という考察を深めると、cとdの位置関係だけに注目すればいいことがわかる（わかる？）
# d < cのとき、aがcにいくためにbを飛び越えなければならない。飛び越えるには"..."の真ん中を避難地帯としてbを置くしかない

n, a, b, c, d = map(int, input().split())
s = list(input())
if c < d:
    if "##" not in "".join(s[a - 1 : c]) and "##" not in "".join(s[b - 1 : d]):
        print("Yes")
    else:
        print("No")
else:
    # aがゴールできる -> bがゴールできる（aの通る経路はすべてbも通るので）
    # bがゴールできる -> bのゴール後、aがゴールできるとは限らない
    if "##" not in "".join(s[a - 1 : c]) and (d - b <= 2 or "..." in "".join(s[b - 1 : d])):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# 3パターンある
# 1. a < c < b < d
# 2. a < b < c < d
# 3. a < b < d < c
# 1はa-cとb-dで独立して考える それぞれの間に#が連続してなかったらおｋ
# 2はb-dが成功したあとa-cが成功すればおｋ
# 3はa-cが成功すればおｋ
# という考察を深めると、cとdの位置関係だけに注目すればいいことがわかる（わかる？）
# d < cのとき、aがcにいくためにbを飛び越えなければならない。飛び越えるには"..."の真ん中を避難地帯としてbを置くしかない

n, a, b, c, d = map(int, input().split())
s = list(input())
if c < d:
    if "##" not in "".join(s[a - 1 : c]) and "##" not in "".join(s[b - 1 : d]):
        print("Yes")
    else:
        print("No")
else:
    # aがゴールできる -> bがゴールできる（aの通る経路はすべてbも通るので）
    # bがゴールできる -> bのゴール後、aがゴールできるとは限らない
    if "##" not in "".join(s[a - 1 : c]) and "..." in "".join(s[b - 1 : d]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# 3パターンある
# 1. a < c < b < d
# 2. a < b < c < d
# 3. a < b < d < c
# 1はa-cとb-dで独立して考える それぞれの間に#が連続してなかったらおｋ
# 2はb-dが成功したあとa-cが成功すればおｋ
# 3はa-cが成功すればおｋ
# という考察を深めると、cとdの位置関係だけに注目すればいいことがわかる（わかる？）
# d < cのとき、aがcにいくためにbを飛び越えなければならない。飛び越えるには"..."の真ん中を避難地帯としてbを置くしかない

n, a, b, c, d = map(int, input().split())
s = list(input())
if c < d:
    if "##" not in "".join(s[a - 1 : c]):
        print("Yes")
    else:
        print("No")
else:
    # aがゴールできる -> bがゴールできる（aの通る経路はすべてbも通るので）
    # bがゴールできる -> bのゴール後、aがゴールできるとは限らない
    if "##" not in "".join(s[a - 1 : c]) and "..." in "".join(s[b - 1 : d]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# 3パターンある
# 1. a < c < b < d
# 2. a < b < c < d
# 3. a < b < d < c
# 1はa-cとb-dで独立して考える それぞれの間に#が連続してなかったらおｋ
# 2はb-dが成功したあとa-cが成功すればおｋ
# 3はa-cが成功すればおｋ
# という考察を深めると、cとdの位置関係だけに注目すればいいことがわかる（わかる？）
# d < cのとき、aがcにいくためにbを飛び越えなければならない。飛び越えるには"..."の真ん中を避難地帯としてbを置くしかない

n, a, b, c, d = map(int, input().split())
s = list(input())
if c < d:
    if "##" not in "".join(s[a - 1 : c]):
        print("Yes")
    else:
        print("No")
else:
    if (
        "##" not in "".join(s[a - 1 : c])
        and ("..." in "".join(s[b - 1 : d]))
    ):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# 3パターンある
# 1. a < c < b < d
# 2. a < b < c < d
# 3. a < b < d < c
# 1はa-cとb-dで独立して考える それぞれの間に#が連続してなかったらおｋ
# 2はb-dが成功したあとa-cが成功すればおｋ
# 3はa-cが成功すればおｋ
# という考察を深めると、cとdの位置関係だけに注目すればいいことがわかる（わかる？）
# d < cのとき、aがcにいくためにbを飛び越えなければならない。飛び越えるには"..."の真ん中を避難地帯としてbを置くしかない

n, a, b, c, d = map(int, input().split())
s = list(input())
if c < d:
    if "##" not in "".join(s[a - 1 : c]):
        print("Yes")
    else:
        print("No")
else:
    if (
        "##" not in "".join(s[a - 1 : c])
        and "##" not in "".join(s[b - 1 : d])
        and ("..." in "".join(s[a - 1 : c]))  # えー
    ):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# 3パターンある
# 1. a < c < b < d
# 2. a < b < c < d
# 3. a < b < d < c
# 1はa-cとb-dで独立して考える それぞれの間に#が連続してなかったらおｋ
# 2はb-dが成功したあとa-cが成功すればおｋ
# 3はa-cが成功すればおｋ
# という考察を深めると、cとdの位置関係だけに注目すればいいことがわかる（わかる？）
# d < cのとき、aがcにいくためにbを飛び越えなければならない。飛び越えるには"..."の真ん中を避難地帯としてbを置くしかない

n, a, b, c, d = map(int, input().split())
s = list(input())
if c < d:
    if "##" not in "".join(s[a - 1 : c]):
        print("Yes")
    else:
        print("No")
else:
    if (
        "##" not in "".join(s[a - 1 : c])
        and "##" not in "".join(s[b - 1 : d])
        and (d - b <= 1 or "..." in "".join(s[b - 1 : d]))
    ):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# 3パターンある
# 1. a < c < b < d
# 2. a < b < c < d
# 3. a < b < d < c
# 1はa-cとb-dで独立して考える それぞれの間に#が連続してなかったらおｋ
# 2はb-dが成功したあとa-cが成功すればおｋ
# 3はa-cが成功すればおｋ
# という考察を深めると、cとdの位置関係だけに注目すればいいことがわかる（わかる？）
# d < cのとき、aがcにいくためにbを飛び越えなければならない。飛び越えるには"..."の真ん中を避難地帯としてbを置くしかない

n, a, b, c, d = map(int, input().split())
s = list(input())
if set(s) == 1:
  print("Yes")
  exit()
if c < d:
    if "##" not in "".join(s[a - 1 : c]):
        print("Yes")
    else:
        print("No")
else:
    if (
        "##" not in "".join(s[a - 1 : c])
        and "##" not in "".join(s[b - 1 : d])
        and "..." in "".join(s[b - 1 : d])
    ):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# 3パターンある
# 1. a < c < b < d
# 2. a < b < c < d
# 3. a < b < d < c
# 1はa-cとb-dで独立して考える それぞれの間に#が連続してなかったらおｋ
# 2はb-dが成功したあとa-cが成功すればおｋ
# 3はa-cが成功すればおｋ
# という考察を深めると、cとdの位置関係だけに注目すればいいことがわかる（わかる？）
# d < cのとき、aがcにいくためにbを飛び越えなければならない。飛び越えるには"..."の真ん中を避難地帯としてbを置くしかない

n, a, b, c, d = map(int, input().split())
s = list(input())
if c < d:
    if "##" not in "".join(s[a - 1 : c]):
        print("Yes")
    else:
        print("No")
else:
    if (
        "##" not in "".join(s[a - 1 : c])
        and "##" not in "".join(s[b - 1 : d])
        and "..." in "".join(s[b - 1 : d])
    ):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# 3パターンある
# 1. a < c < b < d
# 2. a < b < c < d
# 3. a < b < d < c
# 1はa-cとb-dで独立して考える それぞれの間に#が連続してなかったらおｋ
# 2はb-dが成功したあとa-cが成功すればおｋ
# 3はa-cが成功すればおｋ
# という考察を深めると、cとdの位置関係だけに注目すればいいことがわかる（わかる？）

n, a, b, c, d = map(int, input().split())
s = list(input())
if c < d:
    if "##" not in "".join(s[a - 1 : c]):
        print("Yes")
    else:
        print("No")
else:
    if "##" not in "".join(s[a - 1 : c]) and "..." in "".join(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()

ans = "Yes"

count_empty_max = count_empty = 0
count_rock_max = count_rock = 0
for i in range(a-1, c):
    if s[i] == '#':
        count_rock += 1
        count_empty = 0
        count_rock_max = max(count_rock_max, count_rock)
    else:
        count_empty += 1
        count_rock = 0
        count_empty_max = max(count_empty_max, count_empty)

count_empty = 0
count_rock = 0
for i in range(b-1, d):
    if s[i] == '#':
        count_rock += 1
        count_empty = 0
        count_rock_max = max(count_rock_max, count_rock)
    else:
        count_empty += 1
        count_rock = 0
        count_empty_max = max(count_empty_max, count_empty)


if count_rock_max >= 2:
    ans = 'No'
if c > d and count_empty_max <= 2:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

ans = "Yes"

count_empty_max = count_empty = 0
count_rock_max = count_rock = 0
for i in range(a-1, c):
    if s[i] == '#':
        count_rock += 1
        count_empty = 0
        count_rock_max = max(count_rock_max, count_rock)
    else:
        count_empty += 1
        count_rock = 0
        count_empty_max = max(count_empty_max, count_empty)

count_empty_max = count_empty = 0
count_rock_max = count_rock = 0
for i in range(b-1, d):
    if s[i] == '#':
        count_rock += 1
        count_empty = 0
        count_rock_max = max(count_rock_max, count_rock)
    else:
        count_empty += 1
        count_rock = 0
        count_empty_max = max(count_empty_max, count_empty)


if count_rock_max >= 2:
    ans = 'No'
if c > d and count_empty_max <= 2:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

n, a, b, c, d = na()
a -= 1
b -= 1
c -= 1
d -= 1
s = ns()
i = a
flag = True
sp = 0
t = 0
last = "."
while flag and i < c:
    if last == "#" and s[i] == "#":
        flag = False
    last = s[i]
    i += 1
i = b
last = "."
while flag and i < d:
    if last == "#" and s[i] == "#":
        flag = False
    if s[i] == ".":
        t += 1
    else:
        sp = max(sp, t)
        t = 0
    last = s[i]
    i += 1
sp = max(sp, t)

if c > d:
    if flag and sp >= 3:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

n, a, b, c, d = na()
a -= 1
b -= 1
c -= 1
d -= 1
s = ns()
i = a
flag = True
sp = 0
t = 0
last = "."
while flag and i < d:
    if last == "#" and s[i] == "#":
        flag = False
    if i > b:
        if s[i] == ".":
            t += 1
        else:
            sp = max(sp, t)
            t = 0
    last = s[i]
    i += 1
sp = max(sp, t)

if c > d:
    if flag and sp >= 3:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

n, a, b, c, d = na()
a -= 1
b -= 1
c -= 1
d -= 1
s = ns()
i = a
flag = True
sp = 0
t = 0
last = "."
while flag and i < d:
    if last == "#" and s[i] == "#":
        flag = False
    if i > b:
        if s[i] == ".":
            t += 1
        else:
            sp = max(sp, t)
            t = 0
    last = s[i]
    i += 1

if c > d:
    if flag and sp >= 3:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
flag = False
for i in range(a-1,c-1):
    if s[i] == s[i+1] == '#':
        print("No")
        exit()
for i in range(b-1,d-1):
    if s[i] == s[i+1] == '#':
        print("No")
        exit()
if c < d:
    print("Yes")
else:
    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()
flag = False
for i in range(a-1,c-1):
    if s[i] == s[i+1] == '#':
        print("No")
        exit()
for i in range(b-1,d-1):
    if s[i] == s[i+1] == '#':
        print("No")
        exit()
if c < d:
    print("Yes")
else:
    for i in range(b-1, d-1):
        if s[i-1] == s[i+1] and s[i] == s[i+1] and s[i] == '.':
            print("Yes")
            exit()
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
if "##" in s[a:max(c,d)]:
	print ("No")
	exit()

if c > d:
	if "..." not in s[max(0,b-2):d]:
		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-1:max(c,d)]:
	print ("No")
	exit()

if c > d:
	if "..." not in s[b:d]:
		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:max(c,d)]:
	print ("No")
	exit()

if c > d:
	if "..." not in s[b:d]:
		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:max(c,d)]:
	print ("No")
	exit()

if c > d:
	if "..." not in s[b:d-1]:
		print ("No")
		exit()
print ("Yes")

Submission status: Wrong Answer

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

if c > d:
	if "..." not in s[b:d-1]:
		print ("No")
		exit()
print ("Yes")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
F = True
#飛び越えられるのは2マスまで
if ("##" in S[B-1:D]) or ("##" in S[A-1:C]):
  F  =False

#C > DのときAがBを飛び越える必要がある。
#... ->　.B. -> AB. -> .BA -> .B. :真ん中にBを退避させる
#飛び越えるためには...が必要，範囲はBが動ける範囲±1
if C > D and ("..." not in S[B-1-1:D+1]): 
    F = False
print(S[B-1-1:D+2])

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

Submission status: Wrong Answer

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

for i in range(N-1):
  if S[i:i+2] == "##":
    print('No')
    exit(0)

if C > D:
  for i in range(B-1,D):
    if S[i-1:i+2] == "...":
      print('Yes')
      exit(0)
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

for i in range(N-1):
  if S[i:i+2] == "##":
    print('No')
    exit(0)

if C > D:
  for i in range(B,D+1):
    if S[i-1:i+2] == "...":
      print('Yes')
      exit(0)
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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


#%%
flag = True
# A -> Cの間に#が二連続するパターン
if '##' in S[A-1:C]:
    flag = False
# B -> Dの間に#が二連続するパターン
if '##' in S[B-1:D]:
    flag = False

# A, Bの位置交換が必要な時
if C > D:
    if '...' not in S[B-1:D+1]:
    # B,Dの間に連続する3つの'.'が必要
        flag = False

if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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


#%%
flag = True
# A -> Cの間に#が二連続するパターン
if '##' in S[A:C]:
    flag = False
# B -> Dの間に#が二連続するパターン
if '##' in S[B:D]:
    flag = False

# A, Bの位置交換が必要な時
if C > D:
    if '...' not in S[B-1:D+1]:
    # B,Dの間に連続する3つの'.'が必要
        flag = False

if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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


#%%
flag = True
# A -> Cの間に#が二連続するパターン
if '##' in S[A:C]:
    flag = False
# B -> Dの間に#が二連続するパターン
if '##' in S[B:D]:
    flag = False

# A, Bの位置交換が必要な時
if C > D:
    if '...' not in S[B-1:D]:
    # B,Dの間に連続する3つの'.'が必要
        flag = False

if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

flag = True

# A -> Cの間に#が二連続するパターン
if '##' in S[A:C]:
    flag = False
# B -> Dの間に#が二連続するパターン
if '##' in S[B:D]:
    flag = False

# A, Bの位置交換が必要な時
if C > D:
    if '...' not in S[B-1:C]:
    # B, Cの間に連続する3つの'.'が必要
        flag = False

if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

flag = True

# A -> Cの間に#が二連続するパターン
if '##' in S[A:C]:
    flag = False
# B -> Dの間に#が二連続するパターン
if '##' in S[B:D]:
    flag = False

# A, Bの位置交換が必要な時
if C > D:
    if '...' not in S[B:C]:
    # B, Cの間に連続する3つの'.'が必要
        flag = False

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

if c > d:
	if "..." not in s:
		print ("No")
		exit()
print ("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import re
n, a, b, c, d = map(int, input().split())
s = input()
if re.search("#{2,}", s[a-1:c]) or re.search("#{2,}", s[b-1:d]):
  print("No")
  exit()
if c > d:
  if re.search("[.]{3,}", s[b-1:d]):
    print("Yes")
  else:
    print("No")
  exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import re
n, a, b, c, d = map(int, input().split())
s = input()
if re.match(".*?#{2,}.*?", s[a-1:c]) or re.match(".*?#{2,}.*?", s[b-1:d]):
  print("No")
  exit()
if c > d:
  if re.match(".*?[.]{3,}.*?", s[b-1:d]):
    print("Yes")
  else:
    print("No")
  exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import re
n, a, b, c, d = map(int, input().split())
s = input()
if re.match(".*?#{2,}.*?", s[a-1:c]) or re.match(".*?#{2,}.*?", s[b-1:d]):
  print("No")
  exit()
if c > d:
  if re.match(".*?[\.]{3,}.*?", s[b-1:d]):
    print("Yes")
  else:
    print("No")
  exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import re
n, a, b, c, d = map(int, input().split())
s = input()
if re.match(".*?#{2,}.*?", s[a-1:c]) or re.match(".*?#{2,}.*?", s[b-1:d]):
  print("No")
  exit()
if c > d:
  if re.match(".*?[\.]{3,}.*?", s[min(a, b)-1:max(c,d)]):
    print("Yes")
  else:
    print("No")
  exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import re
n, a, b, c, d = map(int, input().split())
s = input()
if re.match(".*?#{2,}.*?", s[min(a, b)-1:max(c, d)]):
  print("No")
  exit()
if c > d:
  if re.match(".*?[\.]{3,}.*?", s[min(a, b)-1:max(c,d)]):
    print("Yes")
  else:
    print("No")
  exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import re
n, a, b, c, d = map(int, input().split())
s = input()
if re.match(".*?#{2,}.*?", s[:max(c, d)]):
  print("No")
  exit()
if c > d:
  if re.match(".*?[\.]{3,}.*?", s[:max(c,d)]):
    print("Yes")
  else:
    print("No")
  exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import re
n, a, b, c, d = map(int, input().split())
s = input()
if re.match(".*?#{2,}.*?", s):
  print("No")
  exit()
if c > d:
  if re.match("[\.]{3,}.*?", s):
    print("Yes")
  else:
    print("No")
  exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import re
n, a, b, c, d = map(int, input().split())
s = input()
if re.match(".*?#{2,}.*?", s):
  print("No")
  exit()
if c > d:
  if re.match(".*?[\.]{3,}.*?", s):
    print("Yes")
  else:
    print("No")
  exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
import re
n, a, b, c, d = map(int, input().split())
s = input()
if re.match("[#]{2,}", s):
  print("No")
  exit()
if c > d:
  if re.match("[\.]{3,}", s):
    print("Yes")
  else:
    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-1:C] or "##" in S[B-1:D]:
  print("No")
elif C < D:
  print("Yes")
else:
  if "..." in S[B-2:D+3]:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def no_2(N,S,start,stop):
  for i in range(start,stop):
    if i < N - 2 and S[i] == "#" and S[i+1] == "#":
      return False
  return True


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

f = no_2(N,S,B-1,D)
s = no_2(N,S,A-1,C)
if not (f and s):
  print("No")
elif C < D:
  print("Yes")
else:
  for i in range(B-2,D+1):
    if i < N - 3 and S[i:i+3] == "...":
      print("Yes")
      break
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
def no_2(N,S,start,stop):
  for i in range(start,stop):
    if i < N - 2 and S[i] == "#" and S[i+1] == "#":
      return False
  return True


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

f = no_2(N,S,B-1,D)
s = no_2(N,S,A-1,C)
if not (f and s):
  print("No")
elif C < D:
  print("Yes")
else:
  for i in range(B-1,D+1):
    if i < N - 3 and S[i:i+3] == "...":
      print("Yes")
      break
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
def no_2(N,S,start,stop):
  for i in range(start,stop):
    if i < N - 2 and S[i] == "#" and S[i+1] == "#":
      return False
  return True


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

f = no_2(N,S,B,D)
s = no_2(N,S,A,C)
if not (f and s):
  print("No")
elif C < D:
  print("Yes")
else:
  for i in range(B,D+1):
    if i < N - 3 and S[i:i+3] == "...":
      print("Yes")
      break
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
def no_2(N,S,start,stop):
  for i in range(start,stop):
    if i < N - 2 and S[i] == "#" and S[i+1] == "#":
      return False
  return True


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

f = no_2(N,S,B,D)
s = no_2(N,S,A,C)
if not (f and s):
  print("No")
elif C < D:
  print("Yes")
else:
  for i in range(B,D):
    if i < N - 3 and S[i:i+3] == "...":
      print("Yes")
      break
  else:
    print("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
if '##' in s[a:c+1] or "##" in s[b:d+1]:
    print('No')
    exit()

if c > d:
    if '...' in s[b-2:d+1]:
        print('Yes')
    else:
        print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if "##" in s:
	print ("No")
	exit()

if c > d:
	if "..." not in s:
		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:
	print ("No")
	exit()

if (a < b and c > d) or (a > b and c < d):
	if "..." not in s:
		print ("No")
		exit()
print ("Yes")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = str(input())
E = max(C,D)
AE = S[A:E]
BD = S[B-2:D+1]
if "##" in AE:
  print("NO")
elif C > D and "..." not in BD:
  print("NO")
else:
  print("YES")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = str(input())
E = max(C,D)
AE = S[A:E]
BD = S[B-2:D+1]
check = 0
if "##" not in AE:
  pass
else:
  check = 1
if "..." in BD and C > D:
  pass
else:
  check = 1
if check == 0:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = str(input())
E = max(C,D)
AE = S[A:E+1]
BD = S[B-2:D+1]
check = 0
if "##" in AE:
  check = 1
else:
  check = 0
if check == 0 and C > D:
  if "..." in BD:
    check = 0
  else:
    check = 1
if check == 0:
  print("OK")
else:
  print("MISS")

Submission status: Wrong Answer

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

if "##" in s[a:]:print("No")
elif c>d and "..." not in s[b-2: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 "##" in s:print("No")
elif c>d and "..." not in s[b-2:d+1]:print("No")
else:print("Yes")