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())
s = input()
if c<d:
    i=a-1
    f = True
    while i<c-1:
        if s[i+1]=='.':
            i += 1
        elif i<c-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
            break
    if i!=c-1:f=False
    i = b-1
    while i<d-1:
        if s[i+1]=='.':
            i += 1
        elif i<d-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
            break
    if i!=d-1:f=False
else:
    i=a-1
    f = True
    while i<c-1:
        if s[i+1]=='.':
            i += 1
        elif i<c-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
            break
    if i!=c-1:f=False
    i = b-1
    ok = False
    while i<d-1:
        if s[i-1]=='.' and s[i+1]=='.':
            ok = True
        if s[i+1]=='.':
            i += 1
        elif i<d-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
            break
    if i!=d-1:f=False
    if not ok:f=False
print('Yes' if f else 'No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
if c<d:
    i=a-1
    f = True
    while i<c-1:
        if s[i+1]=='.':
            i += 1
        elif i<c-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
            break
    i = b-1
    while i<d-1:
        if s[i+1]=='.':
            i += 1
        elif i<d-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
            break
else:
    i=a-1
    f = True
    while i<c-1:
        if s[i+1]=='.':
            i += 1
        elif i<c-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
            break
    i = b-1
    ok = False
    while i<d-1:
        if s[i-1]=='.' and s[i+1]=='.':
            ok = True
        if s[i+1]=='.':
            i += 1
        elif i<d-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
            break
    if not ok:f=False
print('Yes' if f else '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 c<d:
    i=a
    f = True
    while i<c-1:
        if s[i+1]=='.':
            i += 1
        elif i<n-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
            break
    i = b
    while i<d-1:
        if s[i+1]=='.':
            i += 1
        elif i<n-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
            break
else:
    i=a
    f = True
    while i<c-1:
        if s[i+1]=='.':
            i += 1
        elif i<n-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
            break
    i = b
    ok = False
    while i<d-1:
        if s[i-1]=='.' and s[i+1]=='.':
            ok = True
        if s[i+1]=='.':
            i += 1
        elif i<n-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
            break
    if not ok:f=False
print('Yes' if f else 'No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
if c<d:
    i=a-1
    f = True
    while i<c-1:
        if s[i+1]=='.':
            i += 1
        elif i<c-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
    i = b-1
    while i<d-1:
        if s[i+1]=='.':
            i += 1
        elif i<d-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
else:
    i=a-1
    f = True
    while i<c-1:
        if s[i+1]=='.':
            i += 1
        elif i<c-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
    i = b-1
    ok = False
    while i<d-1:
        if s[i-1]=='.' and s[i+1]=='.':
            ok = True
        if s[i+1]=='.':
            i += 1
        elif i<d-2 and s[i+2]=='.':
            i += 2
        else:
            f = False
    if not ok:f=False
print('Yes' if f else 'No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int, input().split())
s = input()
ans = "No"
if c < d and s[c-1] != "#" and s[d-1] != "#":
    s = list(s)
    while b < d:
        if b+1 < n and s[b + 1] != "#": b += 2
        elif s[b] != "#": b += 1
        else: break
    s[d-1] = "#"
    while a < c:
        if a+1 < n and s[a + 1] != "#": a += 2
        elif s[a] != "#": a += 1
        else:break
    if a >= c and b >= d: ans = "Yes"
elif c > d and s[c-1] != "#" and s[d-1] != "#":
    if "..." in s[b:d]:
        while b < d:
            if b+1 < n and s[b + 1] != "#": b += 2
            elif s[b] != "#": b += 1
            else: break
        while a < c:
            if a+1 < n and s[a + 1] != "#": a += 2
            elif s[a] != "#": a += 1
            else:break
        if a >= c and b >= d: ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int, input().split())
s = input()
ans = "No"
if c < d and s[c-1] != "#" and s[d-1] != "#":
    s = list(s)
    while b < d:
        if b+1 < n and s[b + 1] != "#": b += 2
        elif s[b] != "#": b += 1
        else: break
    s[d-1] = "#"
    while a < c:
        if a+1 < n and s[a + 1] != "#": a += 2
        elif s[a] != "#": a += 1
        else:break
    if a >= c and b >= d: ans = "Yes"
elif c > d and s[c-1] != "#" and s[d-1] != "#":
    if "..." in s[b:d]: ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
def no():
    print("No")
    exit()

n, a, b, c, d = map(int, input().split())
s = list(input())
for i in range(a - 1, c - 1):
    if s[i] == s[i + 1] == "#":
        no()
for i in range(b - 1, d - 1):
    if s[i] == s[i + 1] == "#":
        no()
if c > d:
    t = 0
    for i in range(a - 1, d - 1):
        if s[i] == s[i + 1] == s[i + 2] == ".":
            t = 1
    if t == 0:
        no()
print("Yes")

Submission status: Wrong Answer

Solution code:
def no():
    print("No")
    exit()

n, a, b, c, d = map(int, input().split())
s = list(input())
for i in range(a - 1, c - 1):
    if s[i] == s[i + 1] == "#":
        no()
for i in range(b - 1, d - 1):
    if s[i] == s[i + 1] == "#":
        no()
if c > d:
    t = 0
    for i in range(a - 1, c - 2):
        if s[i] == s[i + 1] == s[i + 2] == ".":
            t = 1
    if t == 0:
        no()
print("Yes")

Submission status: Wrong Answer

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

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


if c<d:
    for i in range(b,d):
        if s[i]==s[i+1]=="#":
            print("No")
            exit()
    for i in range(a,c):
        if s[i]==s[i+1]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

flag = False
for i in range(b,d-1):
    if s[i]==s[i+1]==s[i+2]==".":
        flag = True
        break
if not flag:
    print("No")
    exit()

for i in range(b,d):
    if s[i]==s[i+1]=="#":
        print("No")
        exit()
for i in range(a,c):
    if s[i]==s[i+1]=="#":
        print("No")
        exit()
print("Yes")

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 c<d:
    for i in range(b,d):
        if s[i]==s[i+1]=="#":
            print("No")
            exit()
    for i in range(a,c):
        if s[i]==s[i+1]=="#":
            print("No")
            exit()
    print("Yes")
    exit()

flag = False
for i in range(b,d):
    if s[i]==s[i+1]==s[i+2]==".":
        flag = True
        break
if not flag:
    print("No")
    exit()

for i in range(b,d):
    if s[i]==s[i+1]=="#":
        print("No")
        exit()
for i in range(a,c):
    if s[i]==s[i+1]=="#":
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
print('YNeos'['##' in s[a-1:c] or '##' in s[b-1:d]::2] if c<=d or '...' in s[b-1:max(c,d)]else 'No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
flag=0
for i in range(n):
  if a-1<=i<=c-1 or b-1<=i<=d-1:
    if flag==1 and s[i]=="#":
      print("No")
      exit()
    elif flag==0 and s[i]=="#":
      flag=1
    elif s[i]==".":
      flag=0

m=0
con=0
if d<c:
  for i in range(b-1,c):
    if s[i]==".":
      con+=1
      m=max(m,con)
    else:
      con=0
  if m>=3:
    print("Yes")
    exit()
  else:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
flag=0
for i in range(n):
  if a-1<=i<=c-1 or b-1<=i<=d-1:
    if flag==1 and s[i]=="#":
      print("No")
      exit()
    elif flag==0 and s[i]=="#":
      flag=1
    elif s[i]==".":
      flag=0

m=0
con=0
if d<c:
  for i in range(b-1,d):
    if s[i]==".":
      con+=1
      m=max(m,con)
    else:
      con=0
  if m>=3:
    print("Yes")
    exit()
  else:
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

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

if "##" not in S[A:B+1] and "##" not in S[C:D+1]:
    if C > D and "..." not in S[B:D+1]:
        print("No")
    else:
        print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if "##" not in S[A-1:B] and "##" not in S[C-1:D]:
    if C > D and "..." not in S[B:D+1]:
        print("No")
    else:
        print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b,c,d=map(int,input().split())
    s=input()
    for i in range(a,max(c,d)):
        if i+2<=n:
            if s[i:i+2]=='##':
                print("No")
                break
    else:
        if c<d:
            print("Yes")
        else:
            flag=False
            for i in range(a,d):    
                if s[i-1:i+2]=="...":
                    flag=True
            if flag==True:
                print("Yes")
            else:
                print("No")

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
before=s[a-2]
bbefore=s[a-3]
check=0
if c>d:
    check=1
for i,v in enumerate(s):
    if i+1<=a and i+1<=b:
        pass
    elif i+1>=c and i+1>=d:
        pass
    else:
        if v=="#" and before=="#":
            print("No")
            exit(0)
        else:
            if v=="." and before=="." and bbefore=="." and min(c,d)>=i>=b:
                check=0
            bbefore=before
            before=v
if check:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b,c,d=map(int,input().split())
    s=input()
    flag=False
    if a+1==b and s[a+2]=='.':
        flag=True
    for i in range(a,max(c,d)):
        if i+2<=n:
            if s[i:i+2]=='##':
                print("No")
                break
            if s[i-1:i+2]=="...":
                flag=True
    else:
        if c<d or (c>d and flag):
            print("Yes")
        else:
            print("No")

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b,c,d=map(int,input().split())
    s=input()
    flag=False
    for i in range(a,max(c,d)):
        if i+2<=n:
            if s[i:i+2]=='##':
                print("No")
                break
            if s[i-1:i+2]=="...":
                flag=True
    else:
        if c<d or (c>d and flag):
            print("Yes")
        else:
            print("No")

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n,a,b,c,d=map(int,input().split())
    s=input()
    flag=False
    for i in range(a,max(c,d)):
        if i+2<=n:
            if s[i:i+2]=='##':
                print("No")
                break
            if s[i-1:i+2]=="...":
                flag=True
    else:
        if c<d or (c>d and flag):
            print("Yes")
        else:
            print("NO")

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
before=s[a-2]
bbefore=s[a-3]
check=0
if c>d:
    check=1
for i,v in enumerate(s):
    if i+1<=a and i+1<=b:
        pass
    elif i+1>=c and i+1>=d:
        pass
    else:
        if v=="#" and before=="#":
            print("No")
            exit(0)
        else:
            if v=="." and before=="." and bbefore==".":
                check=0
            bbefore=before
            before=v
if check:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
def check(s):
    for i in range(len(s) - 1):
        if s[i] == '#' and s[i + 1] == '#':
            return False
    return True


def checksp(s):
    for i in range(len(s) - 2):
        if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
            return True
    return False


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

if C < D:
    if check(S[A:C+1]) and check(S[B:D+1]):
        print('Yes')
    else:
        print('No')
else:
    if checksp(S[B-1:D+2]) and check(S[B:D+1]) and check(S[A:C+1]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def check(s):
    for i in range(len(s) - 1):
        if s[i] == '#' and s[i + 1] == '#':
            return False
    return True


def checksp(s):
    for i in range(len(s) - 2):
        if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
            return True
    return False


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

if C < D:
    if check(S[A:C+1]) and check(S[B:D+1]):
        print('Yes')
    else:
        print('No')
else:
    if checksp(S[B-1:min(D+2, N)]) and check(S[B:D+1]) and check(S[A:C+1]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def check(s):
    for i in range(len(s) - 1):
        if s[i] == '#' and s[i + 1] == '#':
            return False
    return True


def checksp(s):
    for i in range(len(s) - 2):
        if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
            return True
    return False


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

if C < D:
    if check(S[A:C+1]) and check(S[B:D+1]):
        print('Yes')
    else:
        print('No')
else:
    if checksp(S[B-1:D+1]) and check(S[B:D+1]) and check(S[A:C+1]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def check(s):
    for i in range(len(s) - 1):
        if s[i] == s[i + 1] == '#':
            return False
    return True


def checksp(s):
    for i in range(len(s) - 2):
        if s[i] == s[i + 1] == s[i + 2] == '.':
            return True
    return False


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

if C < D:
    if check(S[A:C+1]) and check(S[B:D+1]):
        print('Yes')
    else:
        print('No')
else:
    if checksp(S[B:D+1]) and check(S[B:D+1]) and check(S[A:C+1]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def check(s):
    for i in range(len(s) - 1):
        if s[i] == s[i + 1] == '#':
            return False
    return True


def checksp(s):
    for i in range(len(s) - 2):
        if s[i] == s[i + 1] == s[i + 2] == '.':
            return True
    return False


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

if C < B:
    if check(S[A:C+1]) and check(S[B:D+1]):
        print('Yes')
    else:
        print('No')
elif C < D:
    if check(S[A:D+1]):
        print('Yes')
    else:
        print('No')
else:
    if checksp(S[B:D+1]) and check(S[A:C+1]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def check(s):
    for i in range(len(s) - 1):
        if s[i] == s[i + 1] == '#':
            return False
    return True


def checksp(s):
    for i in range(len(s) - 2):
        if s[i] == s[i + 1] == s[i + 2] == '.':
            return True
    return False


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

if C < D:
    if check(S[A:C+1]) and check(S[B:D+1]):
        print('Yes')
    else:
        print('No')
else:
    if checksp(S[B:D+1]) and check(S[A:C+1]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def check(s):
    for i in range(len(s) - 1):
        if s[i] == s[i + 1] == '#':
            return False
    return True


def checksp(s):
    for i in range(len(s) - 2):
        if s[i] == s[i + 1] == s[i + 2] == '.':
            return True
    return False


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

if C < B:
    if check(S[A:C+1]) and check(S[B:D+1]):
        print('Yes')
    else:
        print('No')
elif C < D:
    if check(S[A:D+1]):
        print('Yes')
    else:
        print('No')
else:
    if checksp(S[A:D+1]) and check(S[A:C+1]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

s=input()

s=list(s)

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

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

Submission status: Wrong Answer

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

s=input()

s=list(s)

for i in range(1,n):
    if s[i-1] == '#' and s[i] == '#':
        if a < i-1 and i < max(c,d):
            print('No')
            exit()

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

Submission status: Wrong Answer

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

s=input()

s=list(s)

for i in range(1,n):
    if s[i-1] == '#' and s[i] == '#':
        if a < i < max(c,d):
            print('No')
            exit()

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

Submission status: Wrong Answer

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

s=input()

s=list(s)

for i in range(1,n):
    if s[i-1] == '#' and s[i] == '#':
        if i < max(c,d):
            print('No')
            exit()

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()
    print('No')

Submission status: Wrong Answer

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

s=input()

s=list(s)

for i in range(1,n):
    if s[i-1] == '#' and s[i] == '#':
        if i < max(c,d):
            print('No')
            exit()

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

if D - C < 0:
  if "..." not in S[B-1:D+2]:
    print("No")
    exit()
    
print("Yes")

Submission status: Wrong Answer

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

if "##" in S[A:C] or "##" in S[B:D]:
  print("No")
  exit()

if D - C < 0:
  if "..." not in S[B-1:D+2]:
    print("No")
    exit()
    
print("Yes")

Submission status: Wrong Answer

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

if "##" in S[A:C] or "##" in S[B:D]:
  print("No")
  exit()

if D - C < 0:
  if "..." not in S:
    print("No")
    exit()
  if S[B+1] == "#" and B - A == 1 and D - B == 2:
    print("No")
    exit()
    
print("Yes")

Submission status: Wrong Answer

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

if "##" in S[A:C] or "##" in S[B:D]:
  print("No")
  exit()

if D - C < 0:
  if "..." not in S:
    print("No")
    exit()

print("Yes")

Submission status: Wrong Answer

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

if C > D:
    print('Yes' if '...' in S[B-1:D+1] and '##' not in S[A:C] else 'No')
else:
    print('Yes' if '##' not in S[A:D] else 'No')

Submission status: Wrong Answer

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

if "##" in S[A:]:
  print("No")
  exit()

if B - A > 0 and D - C < 0:
  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 (B - A > 0 and D - C < 0) or (B - A < 0 and D - C > 0):
  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()
ans="Yes"
if c<b:
    for i in range(a-1,c-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
    if ans=="Yes":
        for i in range(b-1,d-1):
            if s[i]=="#" and s[i+1]=="#":
                ans="No"
                break
elif c<d:
    for i in range(a-1,d-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
else:
    cnt=0
    for i in range(a-1,c-1):
        if s[i]=="#" and s[i+1]=="#":
            ans="No"
            break
    if ans=="Yes":
        for i in range(b-2,d):
            if s[i]==".":
                cnt+=1
                if cnt==3:
                    break
            else:
                cnt=0
        if cnt!=3:
            ans="No"
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

dp_A = [[] for _ in range(N)]
dp_B = [[] for _ in range(N)]
dp_A[A].append(0)
dp_B[B].append(0)

if S[A+1] == '.':
    dp_A[A+1].append(1)
if S[B+1] == '.':
    dp_B[B+1].append(1)

def cal(dp, start):
    for i in range(start+2, N):
        if S[i] == '.':
            if S[i-2] == '.':
                dp[i] += [i+1 for i in dp[i-2]]
            if S[i-1] == '.':
                dp[i] += [i+1 for i in dp[i-1]]
    return dp

dp_A = cal(dp_A, A)
dp_B = cal(dp_B, B)


if dp_A[C]==[] or dp_B[D]==[]:
    print('No')
    exit()

for i in range(N):
    if dp_A[i] != [] and dp_B[i] != []:
        if dp_A[i]==dp_B[i]:
            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:] or("..." not in S[B-2:D+1] and C>D):
    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:]) or ("..." not in S[B:D] and C>D):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

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

cnt = 0
for i in range(a,max(c,d)+1):
    if s[i] == '#':
        cnt += 1
        if cnt >= 2:
            print('No')
            exit()
    else:
        cnt = 0

cnt = 0
if b >= 2:
    if s[b-2] == '.' and s[b-1] == '.':
        cnt = 2

if s[b-1] == '.':
    cnt = 1

if c > d:
    for i in range(b,d+1):
        if s[i] == '.':
            cnt += 1
            if cnt >= 3:
                print('Yes')
                exit()
        else:
            cnt = 0
        if i == d:
            print('No')
            exit()
else:
    print('Yes')