Problem:


Score : 400 points

Problem Statement

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

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

You can repeat the following operation any number of times:

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

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

Determine whether this is possible.

Constraints

4 \leq N \leq 200\ 000

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

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

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

A, B, C and D are all different.

A < B

A < C

B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

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

Sample Input 1

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

Sample Output 1

Yes

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

A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB

Sample Input 2

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

Sample Output 2

No

Sample Input 3

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

Sample Output 3

Yes



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


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline

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

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

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

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline

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

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

if D < C:
#    print(S[A:D])
    if "..." not in S[A:D]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

for i in range(C - A):
    if S[A + i: A + i + 2] == '##':
        print('No')
        exit(0)
for i in range(D - B):
    if S[B + i: B + i + 2] == '##':
        print('No')
        exit(0)

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

print('Yes')

Submission status: Wrong Answer

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

for i in range(C - A):
    if S[A + i: A + i + 2] == '##':
        print('No')
        exit(0)
for i in range(D - B):
    if S[B + i: B + i + 2] == '##':
        print('No')
        exit(0)

if C > D:
    if '...' not in S[B: D + 1]:
        print('No')
        exit(0)

print('Yes')

Submission status: Wrong Answer

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

def can_go(instr,l,r):
    s1 = instr[l:r+1]
    res =  all([ len(i) < 2 for i in s1.split(".") if i != ""])
    return res

def can_swap(instr,l,r):
    s1 = instr[l:r+1]
    res = any([ len(i) >= 3 for i in s1.split("#") if i != ""])
    return res

ans = "No"
if can_go(s,a,c) and can_go(s,b,d):
    if c < d:
        ans = "Yes"
    else:
        if can_swap(s,b-1,d):
            ans = "Yes"
print(ans)

Submission status: Wrong Answer

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

def can_go(instr,l,r):
    s1 = instr[l:r+1]
    res =  all([ len(i) < 2 for i in s1.split(".") if i != ""])
    return res

def can_swap(instr,l,r):
    s1 = instr[l:r+1]
    res = any([ len(i) >= 3 for i in s1.split("#") if i != ""])
    return res

ans = "No"
if can_go(s,a,c) and can_go(s,b,d):
    if c < d:
        ans = "Yes"
    else:
        if can_swap(s,b,d):
            ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

sl=list(s)

sl[a-1]="A"
sl[b-1]="B"
sl[c-1]="a"
sl[d-1]="b"
#print(sl)

if c>d:
    g_far=c
else:
    g_far=d

#連続して"#"が来た場合はクリア不可
for i in range(a-1,g_far-2):
    if sl[i]=="#" and sl[i+1]=="#":
        print("No")
        sys.exit()

#c>dの場合、連続3マスの"."が必要

if c>d:
    for j in range(b-1-1,d-1-1):
        #print(sl[j],sl[j+1],sl[j+2])
        if sl[j] !="#" and sl[j+1] !="#" and sl[j+2] !="#":
            print("Yes")
            sys.exit()
else:
    print("Yes")
    sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

sl=list(s)

sl[a-1]="A"
sl[b-1]="B"
sl[c-1]="a"
sl[d-1]="b"
#print(sl)

if c>d:
    g_far=c
else:
    g_far=d

#連続して"#"が来た場合はクリア不可
for i in range(a-1,g_far-2):
    if sl[i]=="#" and sl[i+1]=="#":
        #print("No")
        sys.exit()

#c>dの場合、連続3マスの"."が必要

if c>d:
    for j in range(b-1-1,d-1-1):
        #print(sl[j],sl[j+1],sl[j+2])
        if sl[j] !="#" and sl[j+1] !="#" and sl[j+2] !="#":
            print("Yes")
            sys.exit()
else:
    print("Yes")
    sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

sl=list(s)

sl[a-1]="A"
sl[b-1]="B"
sl[c-1]="a"
sl[d-1]="b"
print(sl)

if c>d:
    g_far=c
else:
    g_far=d

#連続して"#"が来た場合はクリア不可
for i in range(a-1,g_far-2):
    if sl[i]=="#" and sl[i+1]=="#":
        #print("No")
        sys.exit()

#c>dの場合、連続3マスの"."が必要

if c>d:
    for j in range(b-1-1,d-1-1):
        #print(sl[j],sl[j+1],sl[j+2])
        if sl[j] !="#" and sl[j+1] !="#" and sl[j+2] !="#":
            print("Yes")
            sys.exit()
else:
    print("Yes")
    sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

sl=list(s)

sl[a-1]="A"
sl[b-1]="B"
sl[c-1]="a"
sl[d-1]="b"
print(sl)

if c>d:
    g_far=c
else:
    g_far=d

#連続して"#"が来た場合はクリア不可
for i in range(a-1,g_far-2):
    if sl[i]=="#" and sl[i+1]=="#":
        print("No")
        sys.exit()

#c>dの場合、連続3マスの"."が必要

if c>d:
    for j in range(b-1-1,d-1-1):
        print(sl[j],sl[j+1],sl[j+2])
        if sl[j] !="#" and sl[j+1] !="#" and sl[j+2] !="#":
            print("Yes")
            sys.exit()
else:
    print("Yes")
    sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

sl=list(s)

sl[a-1]="A"
sl[b-1]="B"
sl[c-1]="a"
sl[d-1]="b"
#print(sl)

if c>d:
    g_far=c
else:
    g_far=d

#連続して"#"が来た場合はクリア不可
for i in range(a-1,g_far-2):
    if sl[i]=="#" and sl[i+1]=="#":
        print("No")
        sys.exit()

#c>dの場合、連続3マスの"."が必要

if c>d:
    for j in range(b-1,d-1-1):
        #print(sl[j],sl[j+1],sl[j+2])
        if sl[j] !="#" and sl[j+1] !="#" and sl[j+2] !="#":
            print("Yes")
            sys.exit()
else:
    print("Yes")
    sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

sl=list(s)

sl[a-1]="A"
sl[b-1]="B"
sl[c-1]="a"
sl[d-1]="b"

if c>d:
    g_far=c
else:
    g_far=d

#連続して"#"が来た場合はクリア不可
for i in range(a-1,g_far-2):
    if sl[i]=="#" and sl[i+1]=="#":
        print("No")
        sys.exit()

#c>dの場合、連続3マスの"."が必要

if c>d:
    for j in range(b-1,d-1-2):
        if sl[j] !="#" and sl[j+1] !="#" and sl[j+2] !="#":
            print("Yes")
            sys.exit()
else:
    print("Yes")
    sys.exit()

print("No")

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b,c,d = map(int,input().split())
    ls = list(input())
    
    ls.insert(0,"#")
    if c<d:
        flg = 0
        for i in range(b,d+1):
            if ls[i]=="#":
                flg +=1
            else:
                flg =0
            if flg ==2:
                print("No")
                exit()
        print("Yes")
    
    else:
        flg = 0
        aki = 0
        aki_max = 0
        for i in range(b,c+1):
            if ls[i]=="#":
                flg +=1
                aki = 0
            else:
                flg =0
                aki +=1
            if flg ==2:
                print("No")
                exit()
            aki_max = max(aki,aki_max)
        if aki_max>=3:
            print("Yes")
        else:
            print("No")
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b,c,d = map(int,input().split())
    ls = list(input())
    
    ls.insert(0,"#")
    if c<d:
        flg = 0
        for i in range(1,d+1):
            if ls[i]=="#":
                flg +=1
            else:
                flg =0
            if flg ==2:
                print("No")
                exit()
        print("Yes")
    
    else:
        flg = 0
        aki = 0
        aki_max = 0
        for i in range(1,c+1):
            if ls[i]=="#":
                flg +=1
                aki = 0
            else:
                flg =0
                aki +=1
            if flg ==2:
                print("No")
                exit()
            aki_max = max(aki,aki_max)
        if aki_max>=3:
            print("Yes")
        else:
            print("No")
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b,c,d = map(int,input().split())
    ls = list(input())
    
    ls.insert(0,"#")
    if c<d:
        flg = 0
        for i in range(1,n+1):
            if ls[i]=="#":
                flg +=1
            else:
                flg =0
            if flg ==2:
                print("No")
                exit()
        print("Yes")
    
    else:
        flg = 0
        aki = 0
        aki_max = 0
        for i in range(1,n+1):
            if ls[i]=="#":
                flg +=1
                aki = 0
            else:
                flg =0
                aki +=1
            if flg ==2:
                print("No")
                exit()
            aki_max = max(aki,aki_max)
        if aki_max>=3:
            print("Yes")
        else:
            print("No")
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# AGC034A - Kenken Race
def main():
    n, a, b, c, d = tuple(map(int, input().rstrip().split()))
    S = input().rstrip()
    if "##" in S[a - 1 : c] or "##" in S[b - 1 : d]:
        flg = 0
    else:
        if c < d:
            flg = 1
        else:
            flg = "..." in S[b - 1 : d + 1]
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# AGC034A - Kenken Race
def main():
    n, a, b, c, d = tuple(map(int, input().rstrip().split()))
    S = input().rstrip()
    if "##" in S[a - 1 : max(c, d)]:
        flg = 0
    else:
        if c < d:
            flg = 1
        else:
            flg = "..." in S[b - 1 : d + 1]
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# AGC034A - Kenken Race
def main():
    n, a, b, c, d = tuple(map(int, input().rstrip().split()))
    S = input().rstrip()
    if "##" in S[a - 1 : c] or "##" in S[b - 1 : d]:
        flg = 0
    else:
        if c < d:
            flg = 1
        else:
            flg = "..." in S[b - 1 : d]
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# AGC034A - Kenken Race
def main():
    n, a, b, c, d = tuple(map(int, input().rstrip().split()))
    S = input().rstrip()
    if "##" in S[a - 1 : max(c, d)]:
        flg = 0
    else:
        if c < d:
            flg = 1
        else:
            flg = "..." in S[b - 1 : c]
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# AGC034A - Kenken Race
def main():
    n, a, b, c, d = tuple(map(int, input().rstrip().split()))
    S = input().rstrip()
    if "##" in S[a - 1 :]:
        flg = 0
    else:
        if c < d:
            flg = 1
        else:
            flg = "..." in S[b - 1 : d]
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# AGC034A - Kenken Race
def main():
    n, a, b, c, d = tuple(map(int, input().rstrip().split()))
    S = input().rstrip()
    if "##" in S[a - 1 : max(c, d)]:
        flg = 0
    else:
        if c < d:
            flg = 1
        else:
            flg = "..." in S[b - 1 : d]
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# AGC034A - Kenken Race
def main():
    n, a, b, c, d = tuple(map(int, input().rstrip().split()))
    S = input().rstrip()
    flg1 = "##" not in S[a - 1 : max(c, d)]
    flg2 = 1 if c < d else "..." in S[b - 1 : d]
    print("Yes" if flg1 and flg2 else "No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from copy import *

N, A, B, C, D = map(lambda x: int(x)-1, input().split())
S = input()
if "##" in S[A:C] or "##" in S[B:D]:
    print('No')
    exit()
if C < D:
    print('Yes')
else:
    if "..." in S[B:D+2]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from copy import *

N, A, B, C, D = map(lambda x: int(x)-1, input().split())
S = input()
if "##" in S[A:C] or "##" in S[B:D]:
    print('No')
    exit()
if C < D:
    print('Yes')
else:
    if "..." in S[B:D+1]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from copy import *

N, A, B, C, D = map(lambda x: int(x)-1, input().split())
S = input()
if "##" in S[A:C] or "##" in S[B:D]:
    print('No')
    exit()
if C < D:
    print('Yes')
else:
    if "..." in S[B+1:D+1]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from copy import *

N, A, B, C, D = map(lambda x: int(x)-1, input().split())
S = input()
if "##" in S[A:C] or "##" in S[B:D]:
    print('No')
    exit()
if C < D:
    print('Yes')
else:
    if "..." in S[A:D+1]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif D < C:
    for index in range(B-1, D-1):
        if inputs[index-1] != '#'  and index - 1 != A - 1 and inputs[index] != '#' and inputs[index+1] != '#':
            flag = True
    flag = flag and compute(A-1, C-1) and compute(B-1, D-1)

print('Yes' if flag else 'No')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif D < C:
    for index in range(B-1, D-1):
        if inputs[index-1] != '#'  and index != A - 1 and inputs[index] != '#' and inputs[index+1] != '#':
            flag = True
    flag = flag and compute(A-1, C-1) and compute(B-1, D-1)

print('Yes' if flag else 'No')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif D < C:
    for index in range(B, D):
        if inputs[index-1] != '#'  and index - 1 != A - 1 and inputs[index] != '#' and inputs[index+1] != '#':
            flag = True
    flag = flag and compute(A-1, C-1) and compute(B-1, D-1)

print('Yes' if flag else 'No')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif D < C:
    for index in range(B, D):
        if inputs[index-1] != '#'  and index - 1 != A and inputs[index] != '#' and inputs[index+1] != '#':
            flag = True
    flag = flag and compute(A-1, C-1) and compute(B-1, D-1)

print('Yes' if flag else 'No')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif D < C:
    for index in range(B, D):
        if inputs[index-1] != '#'  and index - 1 != A and inputs[index] != '#' and inputs[index+1] != '#':
            flag = True
    flag = compute(A-1, C-1) and compute(B-1, D-1)

print('Yes' if flag else 'No')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) or compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) or compute(B-1, D-1)
elif D < C:
    pass

print('Yes' if flag else 'No')

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

'''

Submission status: Wrong Answer

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

# S[A - 1] = "A"
# S[B - 1] = "B"
# print(S)

"""
必要なこと
・C>D (並び順が開始時と違うとき)
    ・すぬけとふぬけを入れ替えることができる
        ・たどり着ける範囲で...が存在する
・AC間に##が無い
・BD間に##が無い
"""

# AC間に##が無いか判定
AC = (S.count("##", A - 1, C - 1))
# print(AC)
# BD間に##が無いか判定
BD = (S.count("##", B-1, D-1))
# print(BD)

DC = True if C > D else False  # 入れ替えが必要ならTrue

if DC:
    if S.count("...", B-1, D-1) != 0:
        canchange = True
    else:
        canchange = False
else:
    canchange = True
# print(canchange)

if AC == 0 and BD == 0 and canchange:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

# S[A - 1] = "A"
# S[B - 1] = "B"
# print(S)

"""
必要なこと
・C>D (並び順が開始時と違うとき)
    ・すぬけとふぬけを入れ替えることができる
        ・たどり着ける範囲で...が存在する
・AC間に##が無い
・BD間に##が無い
"""

# AC間に##が無いか判定
AC = (S.count("##", A - 1, C - 1))
# print(AC)
# BD間に##が無いか判定
BD = (S.count("##", B-1, D-1))
# print(BD)

DC = True if C > D else False  # 入れ替えが必要ならTrue

if DC:
    if S.count("...", A-1, D-1) != 0:
        canchange = True
    else:
        canchange = False
else:
    canchange = True
# print(canchange)

if AC == 0 and BD == 0 and canchange:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

# S[A - 1] = "A"
# S[B - 1] = "B"
# print(S)

"""
必要なこと
・C>D (並び順が開始時と違うとき)
    ・すぬけとふぬけを入れ替えることができる
        ・たどり着ける範囲で...が存在する
・AC間に##が無い
・BD間に##が無い
"""

# AC間に##が無いか判定
AC = (S.count("##", A - 1, C - 1))
# print(AC)
# BD間に##が無いか判定
BD = (S.count("##", B-1, D-1))
# print(BD)

DC = True if C > D else False  # 入れ替えが必要ならTrue

if DC:
    left = S.find("##", 0, A - 1)
    if left == -1:  # 左に壁はない
        left = 0
    else:  # Aに最も近い壁を探す
        while True:
            temp = S.find("##", left+1, A - 1)
            if temp == -1:
                break
            left = temp

    right = S.find("##", B - 1)
    if right == -1:  # 右に壁はない
        right = len(S) - 1

    center = S.find("##", A - 1, B - 1)
    if center == -1:
        if S.count("...", left, right):
            canchange = True
        else:
            canchange = False
    else:
        canchange = False
else:
    canchange = True
# print(canchange)

if AC == 0 and BD == 0 and canchange:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def solve():
    if '##' in s[a:c + 1] or '##' in s[b:d + 1]:
        return False
    if b < c < d:
        return True  # sfsf
    if c < b < d:
        return True  # ssff
    return '...' in s[b - 1:d]  # sffs


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

s = input()

print('Yes' if solve() else 'No')

Submission status: Wrong Answer

Solution code:
def solve():
    if '##' in s[a:c + 1] or '##' in s[b:d + 1]:
        return False
    if b < c < d:
        return True  # sfsf
    if c < b < d:
        return True  # ssff
    return '...' in s[b - 1:d + 1]  # sffs


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

s = input()

print('Yes' if solve() 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 S[A:max(C,D)].count("##") == 0 :
    if C < D :
        print("Yes")
    else :
        if S[B-1:D+1].count("...") :
            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()
A -= 1
B -= 1
C -= 1
D -= 1

if S[A:D].count("##") == 0 :
    if C < D :
        print("Yes")
    else :
        if S[B-1:D+1].count("...") :
            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()
A -= 1
B -= 1
C -= 1
D -= 1

if S.count("##") == 0 :
    if C < D :
        print("Yes")
    else :
        if S[B-1:D+1].count("...") :
            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()
A -= 1
B -= 1
C -= 1
D -= 1

if S.count("##") == 0 :
    if C < D :
        print("Yes")
    else :
        if S[B-1:D].count("...") :
            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()
A -= 1
B -= 1
C -= 1
D -= 1

if S.count("##") == 0 :
    if C < D :
        print("Yes")
    else :
        if S[B-1:C].count("...") :
            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()
A -= 1
B -= 1
C -= 1
D -= 1

if S.count("##") == 0 :
    if C < D :
        print("Yes")
    else :
        if S[B-1:C].count("...") :
            print("Yes")
        else :
            print("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#AGC34-A
import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

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

ma = 0
i = 0
while i < n:
    if s[i] == '.':
        cnt = 0
        for j in range(i,n):
            if s[j] == '.':
                cnt += 1
                if j == n-1:
                    i += cnt-1
                    break
            else:
                i += cnt-1
                break
        ma = max(ma,cnt)
    else:
        if s[i] == '#':
            if i + 1 < n:
                if s[i+1] == '#':
                    if c >= i+1 or d >= i+1:
                        print('No')
                        quit()
    i += 1
if d < c:
    if ma >= 3:
        print('Yes')
    else:
        print('No')
else:
    if ma == 0:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#AGC34-A
import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

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

ma = 0
i = 0
while i < n:
    if s[i] == '.':
        cnt = 0
        for j in range(i,n):
            if s[j] == '.':
                cnt += 1
                if j == n-1:
                    i += cnt
                    break
            else:
                i += cnt
                break
        ma = max(ma,cnt)
    i += 1
if d < c:
    if ma >= 3:
        print('Yes')
    else:
        print('No')
else:
    if ma == 0:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#AGC34-A
import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

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

ma = 0
i = 0
while i < n:
    if s[i] == '.':
        cnt = 0
        for j in range(i,n):
            if j == n-1:
                i += cnt
                break
            if s[j] == '.':
                cnt += 1
            else:
                i += cnt
                break
        ma = max(ma,cnt)
    i += 1
if d < c:
    if ma >= 3:
        print('Yes')
    else:
        print('No')
else:
    if ma == 0:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#AGC34-A
import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

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

ma = 0
i = 0
while i < n:
    if s[i] == '.':
        cnt = 0
        for j in range(i,n):
             if s[j] == '.':
                 cnt += 1
                 i += 1
             else:
                break
        ma = max(ma,cnt)
    i += 1

if d < c:
    if ma >= 3:
        print('Yes')
    else:
        print('No')
else:
    if ma == 0:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    b = LI()
    ans = []
    for j in range(n):
        for i in range(len(b))[::-1]:
            if b[i] == i+1:
                x = b.pop(i)
                ans.append(x)
                break
    if b:
        print(-1)
    else:
        print(*ans[::-1],sep = "\n")
    return

#B
def B():
    n,a,b,c,d = LI()
    s = S()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    k = b
    while b < d:
        if s[b+1] == ".":
            b += 1
        else:
            if s[b+2] == "#":
                print("No")
                return
            b += 2
    b = k
    if c < d:
        while a < c:
            if s[a+1] == ".":
                a += 1
            else:
                if s[a+2] == "#":
                    print("No")
                    return
                a += 2
        print("Yes")
    else:
        for i in range(b-1,d+2):
            if s[i:i+3].count(".") == 3:
                print("Yes")
                return
        print("No")
    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    B()

Submission status: Wrong Answer

Solution code:
import re
 
count = 0
 
def count_inversion(sequence):
    return sum(sum(m>n for m in sequence[i+1:]) for i,n in enumerate(sequence))
 
s = input()
s = s.replace("BC", "D")
s = re.split(r"[B-C]+", s)
 
while "" in s:
    s.remove("")
for x in s:
    count += count_inversion(list(x))
        
print(count)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
a=0
E=N-D
if C>D:
    for i in range(N-3):
        if S[i]=="#":
            for j in range(1,4):
                if S[i]==S[i+j]:
                    a=1
    if E==0:
        for i in range(B-2,D-2):
            if S[i]==".":
                if S[i]==S[i+1] and S[i+1]==S[i+2]:
                    a=0
                    break
    if E>=1:
        for i in range(B-2,D-1):
            if S[i]==".":
                if S[i]==S[i+1] and S[i+1]==S[i+2]:
                    a=0
                    break
for i in range(N-1):
    if S[i]=="#":
        if S[i+1]=="#":
            a=1
if a==0:
    print("Yes")
if a==1:
    print("No")

Submission status: Wrong Answer

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

if C < D:
    if "##" in S[A:C] or "##" in S[B:D]:
        print("No")
    else:
        print("Yes")
else:
    if "##" in S[A:C] or "##" in S[B:D] or "..." not in S[B:D]:
        print("No")
    else:
        print("Yes")