Problem:


Score : 400 points

Problem Statement

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

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

You can repeat the following operation any number of times:

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

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

Determine whether this is possible.

Constraints

4 \leq N \leq 200\ 000

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

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

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

A, B, C and D are all different.

A < B

A < C

B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

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

Sample Input 1

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

Sample Output 1

Yes

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

A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB

Sample Input 2

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

Sample Output 2

No

Sample Input 3

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

Sample Output 3

Yes



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


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
import sys
import math


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, A, B, C, D = map(int, input().split())
    S = input()
    flag = 0
    while A < C:
        if flag ==1 and S[A]=="#":
            print("No")
            exit()
        elif S[A] =="#":
            flag =1
        else:
            flag =0

        A +=1

    while B < D:
        if flag ==1 and S[B]=="#":
            print("No")
            exit()
        elif S[B] =="#":
            flag =1
        else:
            flag =0

        B +=1

    if C>D:
        j=B-1
        while j<C:
            if S[j-2]=="." and S[j-1]=="." and S[j]==".":
                print("Yes")
                exit()
            j+=1
        print("No")
    else:
        print("Yes")




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=list(map(int,input().split()))
l=list(input())
if "##" in "".join(l[A-1:max(C,D)]):
   print("No")
   exit()
if C>D:
   pass
else:
   print("Yes")
   exit()
if "..." in "".join(l[B-2:D+2]):
   print("Yes")
else:
   print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=list(map(int,input().split()))
l=list(input())
if "##" in "".join(l):
   print("No")
   exit()
if C>D:
   pass
else:
   print("Yes")
   exit()
if "..." in "".join(l[B-1:D+2]):
   print("Yes")
else:
   print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=list(map(int,input().split()))
l=list(input())
if "##" in "".join(l):
   print("No")
   exit()
if C>D:
   pass
else:
   print("Yes")
   exit()
if "..." in l[B-1:D+1]:
   print("Yes")
else:
   print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=list(map(int,input().split()))
l=list(input())
if "##" in "".join(l):
   print("No")
   exit()
if C>D:
   l[B-1]="#"
l="".join(l)
if "##" in l:
   if "..." in l[B-1:D+1]:
      print("Yes")
   else:
      print("No")
else:
   print("Yes")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=list(map(int,input().split()))
l=list(input())
if "##" in "".join(l):
   print("No")
   exit()
if C>D:
   l[B-1]="#"
l="".join(l)
if "##" in l:
   if "..." in l[B:D+1]:
      print("Yes")
   else:
      print("No")
else:
   print("Yes")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=list(map(int,input().split()))
l=list(input())
if "##" in "".join(l):
   print("No")
   exit()
if C>D:
   l[B-1]="#"
l="".join(l)
if "##" in l:
   if "..." in l[max(A,B)-1:]:
      print("Yes")
   else:
      print("No")
else:
   print("Yes")

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n,a,b,c,d = LI()
    s = "#" + S()
    ans = True
    if a<b and b<c and c<d:
        ans &= "##" not in  s[b:d]
        ans &= "##" not in  s[a:c]
    elif a<b and b<d and d<c:
        ans &= "##" not in  s[b:d]
        ans &= "..." in s[b-1:d+1]
        ans &= "##" not in  s[a:c]
    elif a<c and c<b and b<d:
        ans &= "##" not in  s[b:d]
        ans &= "##" not in  s[a:c]
    
    print("Yes" if ans else "No")
    
main()

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; e = 1
for i in range(b, min(c, d)):
    if s[i-1] == "." and s[i] == "." and s[i+1] == ".": e = 0
if c < d: e = 0
for i in range(a, max(c, d)-1):
    if s[i] == "#" and s[i+1] == "#": e = 1
print("Yes") if e == 0 else print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
##agc034_a
N,A,B,C,D = map(int, input().split()) #A→C、B→D #4≤N≤200,000
S = [0] + list(input())

#すれ違うには . の3連続が必要
#すれ違わなくても、#が2連続であるとアウト

#すれ違いが必要かを判定する
#  A<B
#  A<C
#  B<D
#を利用すると下記の3パターンしかない。
if A < B < D < C:
    need_passing = True
elif (A < B < C < D) or (A < C < B < D):
    need_passing = False

#下記のように考える
#すれ違いが必要
    #Yes
        #すれ違い可能点(. . .)を列挙
        #A/B→すれ違い可能点へ行ける = 左記の区間に # # な並びがない
            #すれ違い可能点→C/Dへ行ける? = 左記の区間に # # な並びがない
    #No
        #A→CとB→Dで通行可能 = 左記の区間に # # な並びがない

passing_point_set = set() #すれ違い場所の始点のset
imos_stop = list() # "#"が2連続している場所で増加する。
imos_stop.append(0)

for i in range(1,N-1):
    if S[i] == S[i+1] == "#":
        imos_stop.append(imos_stop[-1] + 1)
    else:
        imos_stop.append(imos_stop[-1])

    if S[i] == S[i+1] == S[i+2] == ".":
        passing_point_set.add(i)

i = N-1
if S[i] == S[i+1] == "#":
    imos_stop.append(imos_stop[-1] + 1)
else:
    imos_stop.append(imos_stop[-1])
#i = N
#右側はない。
imos_stop.append(imos_stop[-1]) #   .##.

#print(imos_stop)
#print(passing_point_set)

def is_reachable(start,goal):
    if imos_stop[start] == imos_stop[goal] and start <= goal: #右に1か2マスにジャンプさせる ∴右方向にしか進めない
        return True
    else:
        return False

if need_passing == True: #A < B < D < C が成立している
    for passing_point in passing_point_set:
        if ((is_reachable(A,passing_point) == True and 
             is_reachable(passing_point,C) == True and
             is_reachable(B,passing_point) == True and
             is_reachable(passing_point,D) == True) and
            (D != passing_point or
            (D == passing_point and A in passing_point_set and B-1 == A))):
            #passing pointの範囲内にDがある場合、passingできない場合がある
            #ex.   A#..D#  …これはOK。A#.BD#.  として、追い抜かせてからB→D
            #ex.   A#..D.# …これはOK。ただし、.D.がpassing_pointになる
            #ex.   A#D..#  …NG
                #↓のパターンが考察不足だった
                #.  ##AB.#D..#C# …start <= goal条件により、追い越し不可扱いになる
            print("Yes")
            break
    else:
        print("No")
else:
    if is_reachable(A,C) == True and is_reachable(B,D) == True:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

if c < d:
    if "##" not in s[a-1:d-1]:
        print("Yes")
    else:
        print("No")
else:
    if ("..." in s[b-2:d-1]) and ("##" not in s[a-1:c-1]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

if c < d:
    if "##" not in s[a-1:d]:
        print("Yes")
    else:
        print("No")
else:
    if ("..." in s[b-1:d-1]) and ("##" not in s[a-1:c-1]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

if c < d:
    if "##" not in s[a-1:d]:
        print("Yes")
    else:
        print("No")
else:
    if ("..." in s[b-1:d]) and ("##" not in s[a-1:c]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

if c < d:
    if "##" not in s[a-1:d]:
        print("Yes")
    else:
        print("No")
else:
    if ("..." in s[b-1:d]) and ("##" not in s[b-1:c]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

if c < d:
    if "##" not in s[a-1:d]:
        print("Yes")
    else:
        print("No")
else:
    if ("..." in s[b-1:d]) and ("##" not in s[b-1:d]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

if c < d:
    if "##" not in s[a-1:d]:
        print("Yes")
    else:
        print("No")
else:
    if ("..." in s[b:d]) and ("##" not in s[b-1:d]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

if c < d:
    if "##" not in s[a-1:d]:
        print("Yes")
    else:
        print("No")
else:
    if ("..." in s[b:d]) and ("##" not in s[a-1:d]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

cnt = 0

for i in range(n):
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[cnt:]

cnt = 0

for i in range(len(s))[::-1]:
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[:len(s)-cnt]

if c < d:
    if "##" not in s[a+1:d]:
        print("Yes")
    else:
        print("No")
else:
    if ("..." in s[b:d]) and ("##" not in s[a+1:d]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

cnt = 0

for i in range(n):
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[cnt:]

cnt = 0

for i in range(len(s))[::-1]:
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[:len(s)-cnt]

if c < d:
    if "##" not in s[a:d]:
        print("Yes")
    else:
        print("No")
else:
    if ("..." in s[b:d]) and ("##" not in s[a:d]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

"""

cnt = 0

for i in range(n):
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[cnt:]

cnt = 0

for i in range(len(s))[::-1]:
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[:len(s)-cnt]

"""

if c < d:
    if "##" not in s[a:d]:
        print("Yes")
    else:
        print("No")
else:
    if ("..." in s[b:d]) and ("##" not in s[b:d]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

cnt = 0

for i in range(n):
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[cnt:]

cnt = 0

for i in range(len(s))[::-1]:
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[:len(s)-cnt]

if c < d:
    if "##" not in s:
        print("Yes")
    else:
        print("No")
else:
    if ("..." in s) and ("##" not in s):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

cnt = 0

for i in range(n):
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[cnt:]

cnt = 0

for i in range(len(s))[::-1]:
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[:len(s)-cnt]

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

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

cnt = 0

for i in range(n):
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[cnt:]

cnt = 0

for i in range(len(s))[::-1]:
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[:len(s)-cnt]

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

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

cnt = 0

for i in range(n):
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[cnt:]

cnt = 0

for i in range(len(s))[::-1]:
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[:len(s)-cnt]

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

print(s)

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

cnt = 0

for i in range(n):
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[cnt:]

cnt = 0

for i in range(len(s))[::-1]:
    if s[i] == "#":
        cnt += 1
    else:
        break

s = s[:len(s)-cnt]

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

Submission status: Wrong Answer

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, a, b, c, d = inintm()
s = input()

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

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, a, b, c, d = input_int_list()
    S = input()

    if c < d:
        ptr = S[b:d + 1].find("##")
        if ptr == -1:
            print("Yes")
        else:
            print("No")
    elif d < c:
        ptr_1 = S[b:c + 1].find("##")
        ptr_2 = S[b:d + 1].find("...")
        if ptr_2 != -1 and ptr_1 == -1:
            print("Yes")
        else:
            print("No")

    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, a, b, c, d = input_int_list()
    S = input()

    if c < d:
        ptr = S[b:].find("##")
        if ptr == -1 or ptr + b > d:
            print("Yes")
        else:
            print("No")
    elif d < c:
        ptr_1 = S[b:].find("##")
        ptr_2 = S[b - 2:].find("...")
        if (ptr_2 > -1 and ptr_2 < b - 2 + d) and (ptr_1 == -1 or ptr_1 + b > d):
            print("Yes")
        else:
            print("No")

    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a

import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, a, b, c, d = input_int_list()
    S = input()

    if c < d:
        ptr = S[b:].find("##")
        if ptr > -1:
            print("No")
        else:
            print("Yes")
    elif d < c:
        ptr_1 = S[b:].find("##")
        ptr_2 = S[b - 2:].find("...")
        if ptr_2 > -1 and ptr_1 == -1:
            print("Yes")
        else:
            print("No")

    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
for i in range(A - 1, max(C, D) - 1):
    if S[i] == S[i + 1] == '#':
        print("No")
        exit()

if C < D:
    print("Yes")
else:
    for i in range(B - 2, D):
        if S[i:i + 3] == '...':
            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:
    print('No')
    exit()

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
S=input()
answer=0
rock=0
for n_ in range(a,max(c,d)):
    if S[n_]=='#':
        rock+=1
    else:
        rock=0
    if rock>=2:
        answer=1
        break
if answer==1:
    print('No')
else:
    if c > d:
        answer=1
        rock = 0
        for n_ in range(a,d):
            if S[n_] == '.':
                rock += 1
            else:
                rock = 0
            if rock >= 3:
                answer=0
                break
    if b==a+1 and b+1==d and d+1==c:
        print('Yes')
    elif b==a+1 and c==b+1 and d==c+1:
        print('Yes')
    elif answer == 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
S=input()
answer=0
rock=0
for n_ in range(a,max(c,d)):
    if S[n_]=='#':
        rock+=1
    else:
        rock=0
    if rock>=2:
        answer=1
        break
if answer==1:
    print('No')
else:
    if c > d:
        answer=1
        rock = 0
        for n_ in range(a,d):
            if S[n_] == '.':
                rock += 1
            else:
                rock = 0
            if rock >= 3:
                answer=0
                break
    if b==a+1 and abs(d-c)==1:
        print('Yes')
    elif answer == 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
S=input()
answer=0
rock=1
for n_ in range(a,max(c,d)):
    if S[n_]=='#':
        rock+=1
    else:
        rock=0
    if rock>=2:
        answer=1
        break
if answer==1:
    print('No')
else:
    if c > d:
        answer=1
        rock = 0
        for n_ in range(a,d):
            if S[n_] == '.':
                rock += 1
            else:
                rock = 0
            if rock >= 3:
                answer=0
                break
    if n==4:
        print('Yes')
    elif answer == 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
S=input()
answer=0
rock=0
for n_ in range(a,max(c,d)):
    if S[n_]=='#':
        rock+=1
    else:
        rock=0
    if rock>=2:
        answer=1
        break
if answer==1:
    print('No')
else:
    if c > d:
        answer=1
        rock = 0
        for n_ in range(a,d):
            if S[n_] == '.':
                rock += 1
            else:
                rock = 0
            if rock >= 3:
                answer=0
                break
    if n==4:
        print('Yes')
    elif answer == 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
S=input()
answer=0
rock=0
for n_ in range(a,max(c,d)):
    if S[n_]=='#':
        rock+=1
    else:
        rock=0
    if rock>=2:
        answer=1
        break
if answer==1:
    print('No')
else:
    if c > d:
        answer=1
        rock = 0
        for n_ in range(a,d):
            if S[n_] == '.':
                rock += 1
            else:
                rock = 0
            if rock >= 3:
                answer=0
                break
    if answer == 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
S=input()
answer=0
rock=0
for n_ in range(n):
    if S[n_]=='#':
        rock+=1
    else:
        rock=0
    if rock>=3:
        answer=1
        break
if answer==1:
    print('No')
else:
    if c > d:
        answer=1
        rock = 0
        for n_ in range(d):
            if S[n_] == '.':
                rock += 1
            else:
                rock = 0
            if rock >= 3:
                answer=0
                break
    if answer == 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if "##" in s[b:d+1]:
    print("No")
    exit()

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

Submission status: Wrong Answer

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

if "##" in s[b:d+1]:
    print("No")
    exit()

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

Submission status: Wrong Answer

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

if "##" in s[b:d+1]:
    print("No")
    exit()

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

Submission status: Wrong Answer

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

if "##" 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(lambda  x: int(x) - 1, input().split())
S = input()
if C < D:
    if "**" in S[A: D + 1]:
        print("No")
    else:
        print("Yes")
else:
    if "**" in S[A: D + 1] or not("..." in S[B - 1: D + 2]):
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
if C < D:
    if "**" in S[A: D + 1]:
        print("No")
    else:
        print("Yes")
else:
    if "**" in S[A: D + 1] and not("..." in S[B - 1: min(D + 2, C)]):
        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-1:c] or '##' in s[b-1:d]:
    print('No')
    exit()
else:
    if c<d:
        print('Yes')
    else:
        if '...' not in s[b-2:d+1]:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(s[b-1:d])