Problem:


Score : 400 points

Problem Statement

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

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

You can repeat the following operation any number of times:

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

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

Determine whether this is possible.

Constraints

4 \leq N \leq 200\ 000

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

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

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

A, B, C and D are all different.

A < B

A < C

B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

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

Sample Input 1

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

Sample Output 1

Yes

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

A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB

Sample Input 2

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

Sample Output 2

No

Sample Input 3

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

Sample Output 3

Yes



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


Sample output:
Yes

Submission status: Wrong Answer

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

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

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

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

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

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

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

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

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

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

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

Submission status: Wrong Answer

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

    if '##' in s[a:c]:
        return False
    if '##' in s[b:d]:
        return False
    if c > d:
        if '...' not in s[b-1:d+2]:
            return False
    return True

print(['No', 'Yes'][f()])

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

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

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 ("##" in s):
    ans = "No"
elif (c < d):
    ans = "Yes"
elif (c > d):
    if ("..." in s[b:d]):
        ans = "Yes"
    elif ("..." in s[d:max(d, c - 1)]):
        ans = "Yes"
    else:
        ans = "No"
print(ans)

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 ("##" in s):
    ans = "No"
elif (c < d):
    ans = "Yes"
elif (c > d):
    if ("..." in s[b:d]):
        ans = "Yes"
    elif ("..." in s[b:max(d, c - 1)]):
        ans = "Yes"
    else:
        ans = "No"
print(ans)

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 ("##" in s):
    ans = "No"
elif (c < d):
    ans = "Yes"
elif (c > d):
    if ("..." in s[b:max(d, c-1)]):
        ans = "Yes"
    else:
        ans = "No"
print(ans)

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 ("##" in s):
    ans = "No"
elif (c < d):
    ans = "Yes"
elif (c > d):
    if ("..." in s[b:d]):
        ans = "Yes"
    else:
        ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
if c < d:
    s1 = s[a:c]
    s2 = s[b:d]
    if "##" in s1 or "##" in s2:
        print("No")
    else:
        print("Yes")
else:
    s3 = s[b-2:d]
    s4 = s[a:c]
    s5 = s[d-3:d+1]
    if "..." in s3:
        if "##" in s4:
            print("No")
        else:
            print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:

def check_two_stones(S, A, B, C, D):
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            return False
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            return False

    return True

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

if (B < C and C < D) or (C < B and B < D):
    if check_two_stones(S, A, B, C, D) is False:
        print("No")
        exit()
else:
    check = True
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            check = False

    #  ゴールと手前が"##"
    if check is True and S[D-2] is "#":
         # 途中に"..."があれば回避できる
        for j in range(B-1, D-2):
            if S[j] is "." and S[j+1] is "." and S[j+2] is ".":
                check = True
                break
            else:
                check = False

    if check is False:
        print("No")
        exit()

    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            print("No")
            exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
if c < d:
    s1 = s[a:c]
    s2 = s[b:d]
    if "##" in s1 or "##" in s2:
        print("No")
    else:
        print("Yes")
else:
    s3 = s[b:d-1]
    s4 = s[a:c]
    if "..." in s3:
        if "##" in s4:
            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 c < d:
    s1 = s[a:c]
    s2 = s[b:d]
    if "##" in s1 or "##" in s2:
        print("No")
    else:
        print("Yes")
else:
    s3 = s[b:d]
    s4 = s[a:c]
    if "..." in s3:
        if "##" in s4:
            print("No")
        else:
            print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
#A問題
N,A,B,C,D = map(int,input().split())
Slist = list(str(input()))

flag = 0

Rock = 0
for i in range(D-B+1):
    I = B-1+i
    if Slist[I] == "#":
        Rock+=1
        if Rock == 2:
            flag = 1
            break
    else:
        Rock = 0
Rock = 0
for i in range(C-A+1):
        I = A-1+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0

if C > D:
    white = 0
    wflag = 0
    for i in range(D-B+2):
        I = B-2+i
        if Slist[I] == ".":
            white+=1
            if white >= 3:
                wflag = 1
                break
        else:
            white = 0
    if white >= 3:
        wflag = 1
        
    if wflag == 0:
        flag = 1
        
if flag == 1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
#A問題
N,A,B,C,D = map(int,input().split())
Slist = list(str(input()))

flag = 0

Rock = 0
for i in range(D-B):
    I = B-1+i
    if Slist[I] == "#":
        Rock+=1
        if Rock == 2:
            flag = 1
            break
    else:
        Rock = 0
Rock = 0
for i in range(C-A):
        I = A-1+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0

if C > D:
    white = 0
    wflag = 0
    for i in range(D-B+1):
        I = B-2+i
        if Slist[I] == ".":
            white+=1
            if white >= 3:
                wflag = 1
                break
        else:
            white = 0
    if white >= 3:
        wflag = 1
        
    if wflag == 0:
        flag = 1
        
if flag == 1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
#A問題
N,A,B,C,D = map(int,input().split())
Slist = list(str(input()))

if C < D:
    flag = 0
    
    now = B-1
    Rock = 0
    for i in range(D-B):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    now = A-1
    Rock = 0
    for i in range(C-A):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
    
    if flag == 1:
        print("No")
    else:
        print("Yes")
            
else:
    flag = 0
        
    now = B-1
    Rock = 0
    for i in range(D-B+1):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    now = A-1
    Rock = 0
    for i in range(C-A+1):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    white = 0
    MAX = 0
    now = B-2
    for i in range(D-B+1):
        I = now+i
        if Slist[I] == ".":
            white+=1
        else:
            MAX = max(MAX,white)
            white = 0
    MAX = max(MAX,white)
    if MAX <= 2:
        flag = 1
        
    if flag == 1:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
#A問題
N,A,B,C,D = map(int,input().split())
Slist = list(str(input()))

if C < D:
    flag = 0
    
    now = B-1
    Rock = 0
    for i in range(D-B):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    now = A-1
    Rock = 0
    for i in range(C-A):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
    
    if flag == 1:
        print("No")
    else:
        print("Yes")
            
else:
    flag = 0
        
    now = B-1
    Rock = 0
    for i in range(D-B):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    now = A-1
    Rock = 0
    for i in range(C-A):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    white = 0
    MAX = 0
    now = B-2
    for i in range(D-B+1):
        I = now+i
        if Slist[I] == ".":
            white+=1
        else:
            MAX = max(MAX,white)
            white = 0
    MAX = max(MAX,white)
    if MAX <= 2:
        flag = 1
        
    if flag == 1:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
#A問題
N,A,B,C,D = map(int,input().split())
Slist = list(str(input()))

if C < D:
    flag = 0
    
    now = B-1
    Rock = 0
    for i in range(D-B+1):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    now = A-1
    Rock = 0
    for i in range(C-A+1):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
    
    if flag == 1:
        print("No")
    else:
        print("Yes")
            
else:
    flag = 0
        
    now = B-1
    Rock = 0
    for i in range(D-B+1):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    now = A-1
    Rock = 0
    for i in range(C-A+1):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    white = 0
    MAX = 0
    now = B-1
    for i in range(D-B+1):
        I = now+i
        if Slist[I] == ".":
            white+=1
        else:
            MAX = max(MAX,white)
            white = 0
    MAX = max(MAX,white)
    if MAX <= 2:
        flag = 1
        
    if flag == 1:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
#A問題
N,A,B,C,D = map(int,input().split())
Slist = list(str(input()))

if C < D:
    flag = 0
    
    now = B-1
    Rock = 0
    for i in range(D-B):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    now = A-1
    Rock = 0
    for i in range(C-A):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
    
    if flag == 1:
        print("No")
    else:
        print("Yes")
            
else:
    flag = 0
        
    now = B-1
    Rock = 0
    for i in range(D-B+1):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    now = A-1
    Rock = 0
    for i in range(C-A+1):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    white = 0
    MAX = 0
    now = B-1
    for i in range(D-B+1):
        I = now+i
        if Slist[I] == ".":
            white+=1
        else:
            MAX = max(MAX,white)
            white = 0
    MAX = max(MAX,white)
    if MAX <= 2:
        flag = 1
        
    if flag == 1:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
#A問題
N,A,B,C,D = map(int,input().split())
Slist = list(str(input()))

if C < D:
    flag = 0
    
    now = B-1
    Rock = 0
    for i in range(D-B):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    now = A-1
    Rock = 0
    for i in range(C-A):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
    
    if flag == 1:
        print("No")
    else:
        print("Yes")
            
else:
    flag = 0
        
    now = B-1
    Rock = 0
    for i in range(D-B):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    now = A-1
    Rock = 0
    for i in range(C-A):
        I = now+i
        if Slist[I] == "#":
            Rock+=1
            if Rock == 2:
                flag = 1
                break
        else:
            Rock = 0
            
    white = 0
    MAX = 0
    now = B-1
    for i in range(D-B):
        I = now+i
        if Slist[I] == ".":
            white+=1
        else:
            MAX = max(MAX,white)
            white = 0
    MAX = max(MAX,white)
    if MAX <= 2:
        flag = 1
        
    if flag == 1:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
def isOk(a,b):
    for i in range(b-a):
        if s[a-1+i:a+1+i]=="##":
            return False
    else:
        return True

def is3dots(a,b):
    for i in range(b-a-1):
        if s[a-1+i:a+2+i]=='...':
            return True
    else:
        False

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

if c<d:
    if isOk(a,c) and isOk(b,d):
        print("Yes")
    else:
        print("No")
else:
    if isOk(a,c) and isOk(b,d) and is3dots(b,d):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
s = list(input())
n = len(s)
s = s+['z','z']
mem = []
c = 0
run = 0
i=0
while(i<n):
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
        c+=1
        s[i] = 'B'
        s[i + 1] = 'C'
        s[i + 2] = 'A'
        mem.append(i+2)
        run=1
        i+=3
    else:
        i+=1
        if s[i]=='A':
            mem.append(i)

while(run):
    run = 0
    m = -1
    for i in range(len(mem)):
        idex = mem[i]
        if s[idex] == 'A' and s[idex + 1] == 'B' and s[idex + 2] == 'C' and i>m:
            c += 1
            s[idex] = 'B'
            s[idex + 1] = 'C'
            s[idex + 2] = 'A'
            mem.append(i + 2)
            run = 1
            mem[i]= idex+2
            m=idex+2
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

if d < c:
    if s[d-2] == '#' or s[d] == '#':
        if not '...' in s[a-1:d-2]:
            print('No')
            exit()

for i in range(a, c-1):
    if s[i] == '#' and s[i] == s[i+1]:

        print('No')
        exit()

for i in range(b, d-1):
    if s[i] == '#' and 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(s[b-1:d-2])

if d < c:
    if s[d-2] == '#' or s[d] == '#':
        if not '...' in s[a-1:d-2]:
            print('No')
            exit()

for i in range(a, c-1):
    if s[i] == '#' and s[i] == s[i+1]:

        print('No')
        exit()

for i in range(b, d-1):
    if s[i] == '#' and 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()
if d < c:
    if s[d-2] == '#' or s[d] == '#':
        if not '...' in s[b-1:d-2]:
            print('No')
            exit()

for i in range(a, c-1):
    if s[i] == '#' and s[i] == s[i+1]:

        print('No')
        exit()

for i in range(b, d-1):
    if s[i] == '#' and 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 = str(input().split())

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

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

for i in range(b, d-1):
    if s[i] == '#' and 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 = str(input().split())

if d < c:
    if s[d-2] == '#' or s[d] == '#':
        if not '...' in s[b-1:d-2]:
            print('No')
            exit()

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

for i in range(b, d-1):
    if s[i] == '#' and 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 = str(input().split())

if d < c:
    if s[d-2] == '#' or s[d] == '#':
        if not '...' in s[b-1:d-2]:
            print('No')
            exit()

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

for i in range(b, d-2):
    if s[i] == '#' and 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 = str(input().split())

if d < c:
    if s[d-2] == '#' or s[d] == '#':
        if not '...' in s[b:d]:
            print('No')
            exit()

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

for i in range(b, d):
    if s[i] == '#' and 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 = str(input().split())

if d < c:
    if s[d-2] == '#' or s[d] == '#':
        if not '...' in s[b:d-2]:
            print('No')
            exit()

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

for i in range(b, d-2):
    if s[i] == '#' and 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 = str(input().split())
print(n, a, b, c, d, s)

if d < c:
    if s[d-2] == '#' or s[d] == '#':
        if not '...' in s[b:d-2]:
            print('No')
            exit()

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

for i in range(b, d-2):
    if s[i] == '#' and 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()

flag = False

if c<d:
    if s[a-1:c].count('##') == 0 and s[b-1:d].count('##') == 0:
        flag = True

else:
    if s[a-1:c].count('##') == 0 and s[b-1:d+1].count('...') >= 1:
        flag = True

if flag:
    print('Yes')

else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
l = input().split()
N = int(l[0])
A = int(l[1])
B = int(l[2])
C = int(l[3])
D = int(l[4])
l = input().split()
S = l[0]

# print(N, A, B, C, D, S)

def blocked(path):
    return '##' in path

def find_path(A, B, C, D, S):
    s_path = S[A:C]
    f_path = S[B:D]
    if blocked(s_path) or blocked(f_path):
        return False
    return True

def solve(A, B, C, D, S):
    if not find_path(A, B, C, D, S):
        return False
    begin = B if B == 1 else B - 1
    if S[D - 2] == '#':
        if '...' in S[begin:D - 2]:
            return True
        else:
            return False
    else:
        path = S[begin:C]
        if '...' in path:
            return True
    return False

ret = True
if C < D:
    ret = find_path(A, B, C, D, S)
else:
    ret = solve(A, B, C, D, S)

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

Submission status: Wrong Answer

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

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