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 = 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 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')

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 c > d:
    for i in range(b,d+1):
        if s[i] == '.':
            cnt += 1
            if cnt >= 3:
                if i-1 != d:
                    print('Yes')
                    exit()
        else:
            cnt = 0
        if i == c:
            print('No')
            exit()
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 c > d:
    for i in range(b,c+1):
        if s[i] == '.':
            if i == d:
                cnt = 0
            else:
                cnt += 1
            if cnt >= 3:
                print('Yes')
                exit()
        else:
            cnt = 0
        if i == c:
            print('No')
            exit()
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 c > d:
    for i in range(b,c+1):
        if s[i] == '.':
            cnt += 1
            if cnt >= 3:
                print('Yes')
                exit()
        else:
            cnt = 0
        if i == c:
            print('No')
            exit()
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
# a->c, b->d
# a<b
if '##' in s:
  print('No')
  exit()
if c>d and '...' 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()

flg = 0
cnt = 0
S_ac = S[A:C]
S_bd = S[B:D]

if '##' in S_ac or '##' in S_bd:
    flg = 1

if D < C and flg == 0:
    S = S[B-2:D]
    if '...' not in S:
        flg = 1

if flg == 1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

flg = 0
cnt = 0
S_ac = S[A:C-1]
S_bd = S[B:D-1]

if '##' in S_ac or '##' in S_bd:
    flg = 1

if D < C and flg == 0:
    S = S[B-2:D]
    if '...' not in S:
        flg = 1

if flg == 1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

flg = 0
cnt = 0
S_ac = S[A:C-2]
S_bd = S[B:D-2]

if '##' in S_ac or '##' in S_bd:
    flg = 1

if D < C and flg == 0:
    S = S[B-2:D]
    if '...' not in S:
        flg = 1

if flg == 1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

flg = 0
cnt = 0
for i in range(A, C):
    if S[i] == '#':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        flg = 1
        break
if flg == 0:
    cnt = 0
    for i in range(B, D):
        if S[i] == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            flg = 1
            break
if D < C and flg == 0:
    cnt = 0
    flg = 1
    for i in range(B-1, D):
        if S[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flg = 0
            break
if flg == 1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

flg = 0
cnt = 0
for i in range(A, C):
    if S[i] == '#':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        flg = 1
        break
if flg == 0:
    cnt = 0
    for i in range(B, D):
        if S[i] == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            flg = 1
            break
if D < C and flg == 0:
    cnt = 0
    flg = 1
    for i in range(B-1, D+1):
        if S[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flg = 0
            break
if flg == 1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

flg = 0
cnt = 0
for i in range(A, C):
    if S[i] == '#':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        flg = 1
        break
if flg == 0:
    for i in range(B, D):
        if S[i] == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            flg = 1
            break
if D < C and flg == 0:
    cnt = 0
    flg = 1
    for i in range(B-1, D+1):
        if S[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flg = 0
            break
if flg == 1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

flg = 0
cnt = 0
for i in range(A, max(C,D)):
    if S[i] == '#':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        flg = 1
        break
if D < C and flg == 0:
    cnt = 0
    flg = 1
    for i in range(B-1, D+1):
        if S[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flg = 0
            break
    if cnt != 3:
        flg = 1
if flg == 1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

flg = 0
cnt = 0
for i in range(A, max(C,D)):
    if S[i] == '#':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        flg = 1
        break
if D < C and flg == 0:
    cnt = 0
    flg = 1
    for i in range(B-1, D+1):
        if S[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flg = 0
            break
if flg == 1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

flg = 0
cnt = 0
for i in range(A, D):
    if S[i] == '#':
        cnt += 1
    else:
        cnt = 0
    if cnt == 2:
        flg = 1
        break
if D < C and flg == 0:
    cnt = 0
    flg = 1
    for i in range(B-1, min(D+1,N)):
        if S[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flg = 0
            break
if flg == 1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

flg = 0

if C < D:
    cnt = 0
    for i in range(A, D):
        if S[i] == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            flg = 1
            break

else:
    cnt = 0
    flg = 1
    for i in range(B-1, D+1):
        if S[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flg = 0
            break
if flg == 1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

if "##" in S:
    print("No")
    exit(0)

if C <= D:
    print("Yes")
    exit(0)

ans = False
for i in range(B - 1, D):
    if (S[i - 1] == '.') and (S[i] == '.') and (S[i + 1] == '.'):
        ans = True
        break

if ans:
    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(0)

if C <= D:
    print("Yes")
    exit(0)

ans = False
for i in range(B - 1, D):
    if S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
        ans = True
        break

if ans:
    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(0)

if C <= D:
    print("Yes")
    exit(0)

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(0)

if C <= D:
    print("Yes")
    exit(0)

if "..." in S[B - 1: 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(0)

if C <= D:
    print("Yes")
    exit(0)

ans = False
for i in range(B - 1, D):
    if i + 1 == N:
        break
    if S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
        ans = True
        break

if ans:
    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(0)

if C <= D:
    print("Yes")
    exit(0)

ans = False
for i in range(B - 1, D - 1):
    if S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
        ans = True
        break

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

Submission status: Wrong Answer

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B, C, D = lr()
S = input()
# if C > D:
#     if "..." not in S[B-1:D]:
#         print("No")
#         exit(0)
# if "##" in S[A-1:C] or "##" in S[B-1:D]:
#     print("No")
# else:
#     print("Yes")

# ans = "Yes"
# if C > D:
#     tmp = S[B-2:D+1].count("...")
#     if tmp == 0:
#         ans = "No"

# tmp = S[A-1:max(C, D)].count("##")
# if tmp > 0:
#     ans = "No"
# print(ans)


ans="Yes"

if D<C:
  if "..." in S[B-2:D+1]:
    ans="No"
if "##" in S[A-1:max(C,D)]:
  ans="No"

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B, C, D = lr()
S = input()
# if C > D:
#     if "..." not in S[B-1:D]:
#         print("No")
#         exit(0)
# if "##" in S[A-1:C] or "##" in S[B-1:D]:
#     print("No")
# else:
#     print("Yes")
ret = "Yes"
if C > D:
    if "..." not in S[B-1:D]:
        ret = "No"
if "##" in S[A-1:C] or "##" in S[B-1:D]:
    ret = "No"

print(ret)

Submission status: Wrong Answer

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B, C, D = lr()
S = input()
# if C > D:
#     if "..." not in S[B-1:D]:
#         print("No")
#         exit(0)
# if "##" in S[A-1:C] or "##" in S[B-1:D]:
#     print("No")
# else:
#     print("Yes")
if "##" in S[A-1:C] or "##" in S[B-1:D]:
    print("No")
elif C < D:
    print("Yes")
elif "..." not in S[B-1:D]:
    print("No")
    exit(0)
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B, C, D = lr()
S = input()
# if C > D:
#     if "..." not in S[B-1:D]:
#         print("No")
#         exit(0)
# if "##" in S[A-1:C] or "##" in S[B-1:D]:
#     print("No")
# else:
#     print("Yes")
if "##" in S[A-1:C] or "##" in S[B-1:D]:
    print("No")
elif C < D:
    print("YES")
elif "..." not in S[B-1:D]:
    print("No")
    exit(0)
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, A, B, C, D = lr()
S = input()
if C > D:
    if "..." not in S[B-1:D]:
        print("No")
        exit(0)
if "##" in S[A-1:C] or "##" in S[B-1:D]:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def dfs(start, end, obs):
    q = [start-1]
    obs -= 1
    while q:
        s = q.pop()
        if s==end-1:
            return True
        if s+2<N and s+2!=obs and S[s+2]==".":
            q.append(s+2)
        elif s+1<N and s+1!=obs and S[s+1]==".":
            q.append(s+1)
    return False


res = dfs(A, C, -1) and dfs(B, D, -1)

if C<D:
    print("Yes" if res else "No")
else:
    #A<B<D<C
    for i in range(B-1, D):
        if S[i-1]=="." and S[i]=="." and S[i+1]==".":
            print("Yes" if res else "No")
            break
    else:
        print("No")

Submission status: Wrong Answer

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


def dfs(start, end, obs):
    q = [start-1]
    obs -= 1
    while q:
        s = q.pop()
        if s==end-1:
            return True
        if s+2<N and s+2!=obs and S[s+2]==".":
            q.append(s+2)
        elif s+1<N and s+1!=obs and S[s+1]==".":
            q.append(s+1)
    return False


res = dfs(A, C, -1) and dfs(B, D, -1)

if C<D:
    print("Yes" if res else "No")
else:
    for i in range(B-1, D):
        if S[i]==".":
            if (0<=i-1<N and (S[i-1]=="." or (i-1)==A-1)) and (0<=i+1<N and (S[i+1]=="." or (i+1)==C-1)):
                print("Yes" if res else "No")
                break
    else:
        print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    _, A, B, C, D = map(int, input().split())
    S = input().rstrip("\r\n")
    ans = "Yes"
    for i in range(A-1,C-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
            break
    for i in range(B-1,D-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
            break
    if C < D or ans == "No":
        print(ans)
    else:
        ans = "No"
        for i in range(B-1, D-1):
            if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
                ans = "Yes"
        print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    N, A, B, C, D = map(int, input().split())
    S = input().rstrip("\r\n")
    ans = "Yes"
    for i in range(A-1,C-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
            break
    for i in range(B-1,D-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
            break
    if C < D or ans == "No":
        print(ans)
    else:
        ans = "No"
        start = min(A, B) - 1
        end = N - 2
        for i in range(start, end):
            if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
                ans = "Yes"
                break
        print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    N, A, B, C, D = map(int, input().split())
    S = input().rstrip("\r\n")
    ans = "Yes"
    for i in range(A-1,C-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
            break
    for i in range(B-1,D-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
            break
    if C < D or ans == "No":
        print(ans)
    else:
        ans = "No"
        start = min(A, B) - 1
        end = N - 2
        if start <= end:
            for i in range(start, end):
                if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
                    ans = "Yes"
                    break
        print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
def main():
    N, A, B, C, D = map(int, input().split())
    S = input().rstrip("\r\n")
    ans = "Yes"
    for i in range(A-1,C-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
            break
    for i in range(B-1,D-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
            break
    if C < D or ans == "No":
        print(ans)
    else:
        ans = "No"
        start = max(A, B) - 1
        end = N - 2
        if start <= end:
            for i in range(start, end):
                if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
                    ans = "Yes"
                    break
        print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N,A,B,C,D = map(int,input().split())
s = list(input())
ok = False

# AC間、BD間、に連続した岩がなければ良い
#print (s)
for i in range(A,C):
#    print (s[i-1:i+1])
    if s[i-1:i+1] == ["#","#"]:
        print ("No")
        exit ()

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


# C > D の場合
# BD間に連続した3つの空きがあれば良い
if C < D:
    ok = True
else:
#    print (s)
    for i in range(B,D):
#        print (s[i-1:i+2])
        if s[i-1:i+2] == [".",".","."]:
            ok = True
            break

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N,A,B,C,D = map(int,input().split())
s = list(input())
ok = False

# AC間、BD間、に連続した岩がなければ良い
#print (s)
for i in range(A,C):
#    print (s[i-1:i+1])
    if s[i-1:i+1] == ["#","#"]:
        print ("No")
        exit ()

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


# C > D の場合
# BD間に連続した3つの空きがあれば良い
if C < D:
    ok = True
else:
#    print (s)
    for i in range(B,D):
        print (s[i-1:i+2])
        if s[i-1:i+2] == [".",".","."]:
            ok = True
            break

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

Submission status: Wrong Answer

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

# AC間、BD間、に連続した岩がなければ良い
for i in range(B,D):
    if s[i-1:i+1] == ["#","#"]:
        print ("No")
        exit ()
for i in range(A,C):
    if s[i-1:i+1] == ["#","#"]:
        print ("No")
        exit ()

# C > D の場合
# BD間に連続した3つの空きがあれば良い
if C < D:
    ok = True
else:
    for i in range(B,D):
        if s[i-1:i+2] == [".",".","."]:
            ok = True
            break

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

Submission status: Wrong Answer

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

# C < D の場合
# AC間、BD間、に連続した岩がなければ良い
if C < D:
    ok = True
    for i in range(B,D):
        if s[i-1:i+1] == ["#","#"]:
            print ("No")
            exit ()

    for i in range(A,C):
        if s[i-1:i+1] == ["#","#"]:
            print ("No")
            exit ()

# C > D の場合
# AC間、BD間、に連続した岩が無くかつAD間に3つ連続した空きがあれば良い
else:
    for i in range(B,D):
        if s[i-1:i+1] == ["#","#"]:
            print ("No")
            exit ()

    for i in range(A,C):
        if s[i-1:i+1] == ["#","#"]:
            print ("No")
            exit ()

    for i in range(A,D):
        if s[i-1:i+2] == [".",".","."]:
            ok = True

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

Submission status: Wrong Answer

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

if C < D:
    ok = True
    for i in range(B,D):
        if s[i-1:i+1] == ["#","#"]:
            print ("No")
            exit ()

    for i in range(A,C):
        if s[i-1:i+1] == ["#","#"]:
            print ("No")
            exit ()

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

        if s[i-1:i+2] == [".",".","."]:
            ok = True

    for i in range(A,C):
        if s[i-1:i+1] == ["#","#"]:
            print ("No")
            exit ()

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

Submission status: Wrong Answer

Solution code:
import sys
from sys import stdin

n, a, b, c, d = map(int, stdin.readline().rstrip().split())
s = stdin.readline().rstrip()

if c > d:
    dc = 0
    for si in s[b-1:d]:
        if si == '.':
            dc += 1
            if dc >= 3:
                print("Yes")
                sys.exit()
        else:
            dc = 0
    print('No')
    sys.exit()

tmp = '.'
for si in s[a-1:c]:
    if tmp == '#' and si == '#':
        print('No')
        sys.exit()
    tmp = si
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
from sys import stdin

n, a, b, c, d = map(int, stdin.readline().rstrip().split())
s = stdin.readline().rstrip()

if c > d:
    dc = 0
    for si in s[b-1:]:
        if si == '.':
            dc += 1
            if dc >= 3:
                print("Yes")
                sys.exit()
        else:
            dc = 0
    print('No')
    sys.exit()

tmp = '.'
for si in s[a-1:]:
    if tmp == '#' and si == '#':
        print('No')
        sys.exit()
    tmp = si
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
from sys import stdin

n, a, b, c, d = map(int, stdin.readline().rstrip().split())
s = stdin.readline().rstrip()

if c > d:
    dc = 0
    tmp = '.'
    for si in s:
        if si == '.':
            dc += 1
            tmp = '.'
            if dc >= 3:
                print("Yes")
                sys.exit()
        else:
            dc = 0
            tmp = '#'
    print('No')
    sys.exit()

tmp = '.'
for si in s:
    if tmp == '#' and si == '#':
        print('No')
        sys.exit()
    tmp = si
print('Yes')

Submission status: Wrong Answer

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


if c < d:
    ans = "Yes"
    for i in range(a-1,d):
        if s[i-1] == s[i] == "#":
            ans = "No"
            break
else:
    ans = "No"
    for i in range(b-1,d):
        if s[i-2] == s[i-1] == s[i] == ".":
            ans = "Yes"
            break
print(ans)

Submission status: Wrong Answer

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


if c < d:
    ans = "Yes"
    for i in range(1,n):
        if s[i-1] == s[i] == "#":
            ans = "No"
            break
else:
    ans = "No"
    for i in range(2,n):
        if s[i-2] == s[i-1] == s[i] == ".":
            ans = "Yes"
            break
print(ans)

Submission status: Wrong Answer

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

for i in range(A-1,D):
    if S[i] == '#' and S[i+1] == '#':
        print('No')
        exit()

    if C > D:
        for j in range(B-1,D):
            if S[j-1] == '.' and S[j] == '.' and S[j+1] == '.':
                print('Yes')
                exit()

        print('No')
        exit()

    else:
        print('Yes')
        exit()