Problem:


Score : 400 points

Problem Statement

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

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

You can repeat the following operation any number of times:

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

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

Determine whether this is possible.

Constraints

4 \leq N \leq 200\ 000

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

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

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

A, B, C and D are all different.

A < B

A < C

B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

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

Sample Input 1

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

Sample Output 1

Yes

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

A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB

Sample Input 2

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

Sample Output 2

No

Sample Input 3

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

Sample Output 3

Yes



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


Sample output:
Yes

Submission status: Wrong Answer

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

s=input()

if A<B<C<D:
    if not "##" in s[B:D+1]:
        if not "##" in s[A:C+1]:
            ans="Yes"
        else:
            ans="No"
    else:
        ans="No"
elif A<B<D<C:
    if not "##" in s[A:C+1]:
        if s[B-1]!="#" or s[B+1]!="#":
            ans="Yes"
        if "..." in s[B:D+1]:
            ans="Yes"
        else:
            ans="No"
    else:
        ans="No"
elif A<C<B<D:
    if "##" in s[A:C+1] or "##" in s[B:D+1]:
        ans="No"
    else:
        ans="Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
s = ""
for x in range(N):
  if x == A-1:
    s += "A"
  elif x == B-1:
    s += "B"
  else:
    s += S[x]
#print(s)
if C < D:
  if "##" in s[B:D] or "##" in s[A:C]:
    print("No")
    exit()
else:
  if "##" in s[B:D] or "##" in s[A:C]:
    print("No")
    exit()
  elif "AB." not in s[A:C] and ".B." not in s[A:C] and "..." not in s[B:C]:
    print("No")
    exit() 
print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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


def two_rocks(li):
    for i in range(len(li) - 1):
        if li[i] == li[i+1] == "#":
            return True
        else:
            return False


def three_spaces(x, y):
    for i in range(x, y + 1):
        if s[i-1] == s[i] == s[i+1] == ".":
            return True
    return False


def solve():
    if two_rocks(s[a-1:c-1]):
        return False
    if two_rocks(s[b-1:d-1]):
        return False
    if d < c:
        if three_spaces(b-1, d-1):
            return True
        else:
            return False
    else:
        return True


ans = "Yes" if solve() else "No"
print(ans)

Submission status: Wrong Answer

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

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


def two_rocks(li):
    for i in range(len(li) - 1):
        if li[i] == li[i+1] == "#":
            return True
        else:
            return False


def three_spaces(li):
    for i in range(len(li) - 2):
        if li[i] == li[i+1] == li[i+2] == ".":
            return True
    return False


def solve():
    if two_rocks(s[a-1:c-1]):
        return False
    if two_rocks(s[b-1:d-1]):
        return False
    if d < c:
        if three_spaces(s[b-2:d+1]):
            return True
        else:
            return False
    else:
        return True


ans = "Yes" if solve() else "No"
print(ans)

Submission status: Wrong Answer

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

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


def two_rocks(li):
    for i in range(len(li) - 1):
        if li[i] == li[i+1] == "#":
            return True
        else:
            return False


def three_spaces(li):
    for i in range(len(li) - 2):
        if li[i] == li[i+1] == li[i+2] == ".":
            return True
    return False


def solve():
    if two_rocks(s[a-1:c-1]):
        return False
    if two_rocks(s[b-1:d-1]):
        return False
    if d < c:
        if three_spaces(s[b-1:d-1]):
            return True
        else:
            return False
    else:
        return True


ans = "Yes" if solve() else "No"
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
count1 = count2 = 0
for i in range(A,D):
  if S[i-1] == S[i] == '#':
    count1 += 1
if count1 != 0:
   print('No')
elif C < D:
   print('Yes')
else:
  for j in range(B-1,D-1):
    if S[j] == S[j+1] == S[j+2] == '.':
      count2 += 1
  if count2 == 0:
    print('No')
  else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
count1 = count2 = 0
for i in range(A,D):
  if S[i-1] == S[i] == '#':
    count1 += 1
if count1 != 0:
   print('No')
elif C < B:
   print('Yes')
else:
  if C < D:
    print('Yes')
  else:
    for j in range(B-1,D-2):
      if S[j] == S[j+1] == S[j+2] == '.':
        count2 += 1
    if count2 == 0:
      print('No')
    else:
      print('Yes')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
count1 = count2 = 0
for i in range(A,D):
  if S[i-1] == S[i] == '#':
    count1 += 1
if count1 != 0:
   print('No')
elif C < B:
   print('Yes')
else:
  if C < D:
    print('Yes')
  else:
    for j in range(B,D-1):
      if S[j-1] == S[j] == S[j+1] == '.':
        count2 += 1
    if count2 == 0:
      print('No')
    else:
      print('Yes')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
count1 = count2 = 0
for i in range(A,D):
  if S[i-1] == S[i] == '#':
    count1 += 1
if count1 != 0:
   print('No')
elif C < B:
   print('Yes')
else:
  if C < D:
    print('Yes')
  else:
    for j in range(B-1,D-1):
      if S[j] == S[j+1] == S[j+2] == '.':
        count2 += 1
    if count2 == 0:
      print('No')
    else:
      print('Yes')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
count1 = count2 = 0
for i in range(N-1):
  if S[i] == S[i+1] == '#':
    count1 += 1
if count1 != 0:
   print('No')
elif C < B:
   print('Yes')
else:
  if C < D:
    print('Yes')
  else:
    for j in range(B-1,D-2):
       if S[j] == S[j+1] == S[j+2] == '.':
        count2 += 1
    if count2 == 0:
      print('No')
    else:
      print('Yes')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
count1 = count2 = 0
for i in range(N-1):
  if S[i] == S[i+1] == '#':
    count1 += 1
if count1 != 0:
   print('No')
elif C < B:
   print('Yes')
else:
  if C < D:
    print('Yes')
  else:
    for j in range(B,D-2):
       if S[j] == S[j+1] == S[j+2] == '.':
        count2 += 1
    if count2 == 0:
      print('No')
    else:
      print('Yes')

Submission status: Wrong Answer

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

A -= 1
B -= 1
C -= 1
D -= 1


def moveA(A, dest=True):
    if A == C:
        return A, True
    elif dest is True and A+1 == C and B != A+1:
        A += 1
    elif dest is True and A+2 == C and B != A+2:
        A += 2
    elif A+1 < N and S[A+1] == "." and B != A+1:
        A += 1
    elif A+2 < N and S[A+2] == "." and B != A+2:
        A += 2
    else:
        return A, True

    return A, False


def moveB(B, dest=True):
    if B == D:
        return B, True
    elif dest is True and B+1 == D and A != B+1:
        B += 1
    elif dest is True and B+2 == D and A != B+2:
        B += 2
    elif B+1 < N and S[B+1] == "." and A != B+1:
        B += 1
    elif B+2 < N and S[B+2] == "." and A != B+2:
        B += 2
    else:
        return B, True

    return B, False


if C < D:
    while B != D:
        B, stop = moveB(B)
        if stop:
            break
        # print(A, '=', C, ',', B, '=', D)

    while A != C:
        A, stop = moveA(A)
        if stop:
            break
        # print(A, '=', C, ',', B, '=', D)
else:
    while A < B and A != C:
        A, stop = moveA(A, dest=False)
        if stop:
            B, stop = moveB(B, dest=False)
            if stop:
                # for i in range(-3 + A, 4 + A):
                #     if i == A:
                #         print('A', end='')
                #     elif i == B:
                #         print('B', end='')
                #     else:
                #         print(S[i], end='')
                # print()
                # print(A, B, C, D)
                # print(A+2 < N and S[A+2] == "." and B != A+2)
                # print(S[A+2] == ".")
                # print(B != A+2)
                break
        # print(1, A, '=', C, ',', B, '=', D)

    while A != C:
        A, stop = moveA(A)
        if stop:
            # print('A', S[A-4:A+3], A, '=', C, ',', B, '=', D)
            break
        # print(2, A, '=', C, ',', B, '=', D)

    while B != D:
        B, stop = moveB(B)
        if stop:
            print('B', S[B-4:B+3], A, '=', C, ',', B, '=', D)
            break
        # print(3, A, '=', C, ',', B, '=', D)

if A == C and B == D:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

A -= 1
B -= 1
C -= 1
D -= 1


def moveA(A):
    if A == C:
        return A, True
    elif A+1 == C and B != A+1:
        A += 1
    elif A+2 == C and B != A+2:
        A += 2
    elif A+1 < N and S[A+1] == "." and B != A+1:
        A += 1
    elif A+2 < N and S[A+2] == "." and B != A+2:
        A += 2
    else:
        return A, True

    return A, False


def moveB(B):
    if B == D:
        return B, True
    elif B+1 == D and A != B+1:
        B += 1
    elif B+2 == D and A != B+2:
        B += 2
    elif B+1 < N and S[B+1] == "." and A != B+1:
        B += 1
    elif B+2 < N and S[B+2] == "." and A != B+2:
        B += 2
    else:
        return B, True

    return B, False


if C < D:
    while B != D:
        B, stop = moveB(B)
        if stop:
            break
        # print(A, '=', C, ',', B, '=', D)

    while A != C:
        A, stop = moveA(A)
        if stop:
            break
        # print(A, '=', C, ',', B, '=', D)
else:
    while A < B and A != C:
        A, stop = moveA(A)
        if stop:
            B, stop = moveB(B)
            if stop:
                break
        # print(1, A, '=', C, ',', B, '=', D)

    while A != C:
        A, stop = moveA(A)
        if stop:
            break
        # print(2, A, '=', C, ',', B, '=', D)

    while B != D:
        B, stop = moveB(B)
        if stop:
            break
        # print(3, A, '=', C, ',', B, '=', D)

if A == C and B == D:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

A -= 1
B -= 1
C -= 1
D -= 1


def moveA(A):
    if A == C:
        return A, True
    elif A+1 == C and B != A+1:
        A += 1
    elif A+2 == C and B != A+2:
        A += 2
    elif A+1 < N and S[A+1] == "." and B != A+1:
        A += 1
    elif A+2 < N and S[A+2] == "." and B != A+2:
        A += 2
    else:
        return A, True

    return A, False


def moveB(B):
    if B == D:
        return B, True
    elif B+1 == D and A != B+1:
        B += 1
    elif B+2 == D and A != B+2:
        B += 2
    elif B+1 < N and S[B+1] == "." and A != B+1:
        B += 1
    elif B+2 < N and S[B+2] == "." and A != B+2:
        B += 2
    else:
        return B, True

    return B, False


if C < D:
    while B != D:
        B, stop = moveB(B)
        if stop:
            break
        print(A, '=', C, ',', B, '=', D)

    while A != C:
        A, stop = moveA(A)
        if stop:
            break
        print(A, '=', C, ',', B, '=', D)
else:
    while A < B and A != C:
        A, stop = moveA(A)
        if stop:
            B, stop = moveB(B)
            if stop:
                break
        print(1, A, '=', C, ',', B, '=', D)

    while A != C:
        A, stop = moveA(A)
        if stop:
            break
        print(2, A, '=', C, ',', B, '=', D)

    while B != D:
        B, stop = moveB(B)
        if stop:
            break
        print(3, A, '=', C, ',', B, '=', D)

if A == C and B == D:
    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:c].count('##') == 0 and s[b-1:d].count('##') == 0:
    if c < d:
        print('Yes')
    elif s[b-2:d].count('...') >= 1:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
if s[a:c].count('##') == 0 and s[b:d].count('##') == 0:
    if c < d:
        print('Yes')
    elif s[b-2:d].count('...') >= 1:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B, C, D, = map(int, input().split())
L = list(input().strip())

A -= 1
B -= 1
C -= 1
D -= 1

m = [0] * N
m[A] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[C] == 0:
    print("No")
    exit()

m = [0] * N
m[B] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[D] == 0:
    print("No")
    exit()

if C > D:
    for i in range(B, D):
        if "#" not in L[i-1:i+2]:
            print("Yes")
            exit()
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B, C, D, = map(int, input().split())
L = list(input().strip())

A -= 1
B -= 1
C -= 1
D -= 1

m = [0] * N
m[A] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[C] == 0:
    print("No")
    exit()

m = [0] * N
m[B] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[D] == 0:
    print("No")
    exit()

if C > D:
    for i in range(B, C):
        if "#" not in L[i-1:i+2]:
            print("No")
            exit()
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B, C, D, = map(int, input().split())
L = list(input().strip())

A -= 1
B -= 1
C -= 1
D -= 1

m = [0] * N
m[A] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[C] == 0:
    print("No")
    exit()

m = [0] * N
m[B] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[D] == 0:
    print("No")
    exit()

if C > D:
    for i in range(B, C):
        if "#" not in L[i-1:i+2]:
            print("Yes")
            exit()
    print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B, C, D, = map(int, input().split())
L = list(input().strip())

A -= 1
B -= 1
C -= 1
D -= 1

m = [0] * N
m[A] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[C] == 0:
    print("No")
    exit()

m = [0] * N
m[B] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[D] == 0:
    print("No")
    exit()

if C > D:
    for i in range(B, C):
        if "#" not in L[i-1:i+2]:
            print("Yes")
            exit()
    print("Yes")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B, C, D, = map(int, input().split())
L = list(input().strip())

A -= 1
B -= 1
C -= 1
D -= 1

m = [0] * N
m[A] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[C] == 0:
    print("No")
    exit()

m = [0] * N
m[B] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[D] == 0:
    print("No")
    exit()

if C > D:
    for i in range(B, N):
        if "#" not in L[i-1:i+2]:
            print("Yes")
            exit()
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B, C, D, = map(int, input().split())
L = list(input().strip())

A -= 1
B -= 1
C -= 1
D -= 1

m = [0] * N
m[A] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[C] == 0:
    print("No")
    exit()

m = [0] * N
m[B] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[D] == 0:
    print("No")
    exit()

if C > D:
    for i in range(B, C):
        if "#" not in L[i-1:i+2]:
            print("Yes")
            exit()
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B, C, D, = map(int, input().split())
L = list(input().strip())

A -= 1
B -= 1
C -= 1
D -= 1

m = [0] * N
m[A] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[C] == 0:
    print("No")
    exit()

m = [0] * N
m[B] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[D] == 0:
    print("No")
    exit()

if C > D:
    for i in range(B, C - 1):
        if "#" not in L[i-1:i+2]:
            print("Yes")
            exit()
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B, C, D, = map(int, input().split())
L = list(input().strip())

A -= 1
B -= 1
C -= 1
D -= 1

m = [0] * N
m[A] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[C] == 0:
    print("No")
    exit()

m = [0] * N
m[B] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[D] == 0:
    print("No")
    exit()

if C > D:
    for i in range(B, C - 2):
        if "#" not in L[i-1:i+2]:
            print("Yes")
            exit()
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B, C, D, = map(int, input().split())
L = list(input().strip())

A -= 1
B -= 1
C -= 1
D -= 1

m = [0] * N
m[A] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[C] == 0:
    print("No")
    exit()

m = [0] * N
m[B] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[D] == 0:
    print("No")
    exit()

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B, C, D, = map(int, input().split())
L = list(input().strip())

A -= 1
B -= 1
C -= 1
D -= 1

m = [0] * N
m[A] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[C] == 0:
    print("No")
    exit()

m = [0] * N
m[B] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[D] == 0:
    print("No")
    exit()

if C > D:
    for i in range(B, C - 3):
        if "#" not in {L[i], L[i + 1], L[i + 2]}:
            print("Yes")
            exit()
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, A, B, C, D, = map(int, input().split())
L = list(input().strip())

A -= 1
B -= 1
C -= 1
D -= 1

m = [0] * N
m[A] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[C] == 0:
    print("No")
    exit()

m = [0] * N
m[B] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[D] == 0:
    print("No")
    exit()
    
if C > D:
    for i in range(N - 3):
        if "#" not in {L[i], L[i + 1], L[i + 2]}:
            print("Yes")
            exit()
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(list(sys.stdin.readline())[:-1])

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def main():
    N,A,B,C,D = LI()
    s = S()

    for i in range(B-1,D-1):
        if s[i] == "#" and s[i+1] == "#":
            return "No"

    if C<D:
        for i in range(A-1,C-1):
            if s[i] == "#" and s[i+1] == "#":
                return "No"
        return "Yes"

    flag = False
    for i in range(B-1,D-1):
        if s[i-1] == "." and s[i] == "." and s[i+1] == ".":
            flag = True
    if flag:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

Solution code:
import sys

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(list(sys.stdin.readline())[:-1])

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def main():
    N,A,B,C,D = LI()
    s = S()

    for i in range(B-1,D-1):
        if s[i] == "#" and s[i+1] == "#":
            return "No"

    if C<D:
        for i in range(A-1,C-1):
            if s[i] == "#" and s[i+1] == "#":
                return "No"
        return "Yes"

    flag = False
    for i in range(B-1,D-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            flag = True
    if flag:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

Solution code:
import sys

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(list(sys.stdin.readline())[:-1])

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def main():
    N,A,B,C,D = LI()
    s = S()

    for i in range(B-1,D-1):
        if s[i] == "#" and s[i+1] == "#":
            return "No"

    if C<D:
        for i in range(A-1,C-1):
            if s[i] == "#" and s[i+1] == "#":
                return "No"
        return "Yes"

    flag = False
    for i in range(A-1,C-2):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            flag = True
    if flag:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    print(main())

Submission status: Wrong Answer

Solution code:
import sys
INPUT = sys.stdin.readline
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())

N, A, B , A_goal, B_goal = MULTIPLE_INT_MAP()
S = input()
S_list = list(S.strip())

if '##' in S[A:]:
    print('No')
else:
    if A_goal < B_goal:
        print('Yes')
    
    elif A_goal > B_goal:
        for i in range(B-1, B_goal):
            
            if S_list[i-1] == '.' and S_list[i] == '.' and S_list[i+1] == '.':
                print('Yes')
                break
            
            else:
                if i == B_goal - 1:
                    print('No')
                else:
                    pass

Submission status: Wrong Answer

Solution code:
import sys
INPUT = sys.stdin.readline
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())

N, A, B , A_goal, B_goal = MULTIPLE_INT_MAP()
S = input()
S_list = list(S.strip())

if '##' in S:
    print('No')
else:
    if A_goal < B_goal:
        print('Yes')
    
    elif A_goal > B_goal:
        for i in range(B-1, B_goal):
            
            if S_list[i-1] == '.' and S_list[i] == '.' and S_list[i+1] == '.':
                print('Yes')
                break
            
            else:
                if i == B_goal - 1:
                    print('No')

Submission status: Wrong Answer

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

if c < d:
    ok1 = not any(s[i] == s[i + 1] == '#' for i in range(a, c))
    ok2 = not any(s[i] == s[i + 1] == '#' for i in range(b, d))
    print('Yes' if ok1 and ok2 else 'No')
else:
    ok1 = not any(s[i] == s[i + 1] == '#' for i in range(a, c))
    ok2 = not any(s[i] == s[i + 1] == '#' for i in range(b, d))
    ok3 = any(s[i - 1] == s[i] == s[i + 1] == '.' for i in range(b, d - 2) if 0 < i and i < n - 1)
    print('Yes' if ok1 and ok2 and ok3 else 'No')

Submission status: Wrong Answer

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

if c < d:
    ok1 = not any(s[i] == s[i + 1] == '#' for i in range(a, c))
    ok2 = not any(s[i] == s[i + 1] == '#' for i in range(b, d))
    print('Yes' if ok1 and ok2 else 'No')
else:
    ok1 = not any(s[i] == s[i + 1] == '#' for i in range(a, c))
    ok2 = not any(s[i] == s[i + 1] == '#' for i in range(b, d))
    ok3 = any(s[i] == s[i + 1] == s[i + 2] == '.' for i in range(b, d - 2))
    print('Yes' if ok1 and ok2 and ok3 else 'No')

Submission status: Wrong Answer

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

if c < d:
    ok1 = not any(s[i] == s[i + 1] == '#' for i in range(a, c))
    ok2 = not any(s[i] == s[i + 1] == '#' for i in range(b, d))
    print('Yes' if ok1 and ok2 else 'No')
else:
    ok1 = not any(s[i] == s[i + 1] == '#' for i in range(a, c))
    ok2 = not any(s[i] == s[i + 1] == '#' for i in range(b, d))
    ok3 = any(s[i] == s[i + 1] == s[i + 2] == '.' for i in range(a, c - 2))
    ok4 = any(s[i] == s[i + 1] == s[i + 2] == '.' for i in range(b, d - 2))
    print('Yes' if ok1 and ok2 and ok3 and ok4 else 'No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = [int(i) for i in input().split()]
S = input()
ans = True
# check if there are two connected rocks
for i in range(A-1, max(C, D)):
    if S[i:i+2] == "##":
        ans = False
        break
else:
    if C > D:
        # check if there are three dots between B and D
        for i in range(B-1, D):
            if S[i:i+3] == "...":
                break
        else:
            ans = False
        if S[B-2] == "." and S[B] == "." or\
            S[D-2] == "." and S[D] == ".":
            ans = True
if ans:
    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()
ans = True
# check if there are two connected rocks
for i in range(N-1):
    if S[i:i+2] == "##":
        ans = False
        break
else:
    if C > D:
        # check if there are three dots between B and D
        for i in range(B-1, D):
            if S[i:i+3] == "...":
                break
        else:
            ans = False
        if S[B-2] == "." and S[B] == "." or\
            S[D-2] == "." and S[D] == ".":
            ans = True
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

can_reach = True
bef = False
for i in range(a,c):
    if s[i] == "#":
        if bef:
            can_reach = False
        else:
            bef = True
    else:
        bef = False

bef = False
for i in range(b,d):
    if s[i] == "#":
        if bef:
            can_reach = False
        else:
            bef = True
    else:
        bef = False

if can_reach:
    if c < d:
        print("Yes")
    else:
        can_over = False
        bef1 = False
        bef2 = False
        for i in range(b-1,d):
            if s[i] == ".":
                if bef1:
                    if bef2:
                        can_over = True
                    else:
                        bef2 = True
                else:
                    bef1 = True
            else:
                bef1 = False
                bef2 = False
        if can_over:
            print("Yes")
        else:
            print("No")
else:
    print("No")