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:
##agc034_a
N,A,B,C,D = map(int, input().split()) #A→C、B→D #4≤N≤200,000
S = [0] + list(input())

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

#すぬけ君かふぬけ君を選び、1 マス右か 2 マス右にジャンプさせる。
#このときジャンプ先にマスが存在しなければならない
#またそのマスに岩が置かれていたりもう一人がいてはならない。

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

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

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

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

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

i += 1
if S[i] == S[i+1] == "#":
    imos_stop.append(imos_stop[-1] + 1)
else:
    imos_stop.append(imos_stop[-1])

imos_stop.append(imos_stop[-1])

#print(imos_stop)
#print(passing_point_set)

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

if need_passing == True:
    for passing_point in passing_point_set:
        if is_reachable(A,passing_point) == is_reachable(passing_point,C) == is_reachable(B,passing_point) == is_reachable(passing_point,D) == True and D != passing_point and D != passing_point+2:
            #passing pointの範囲内にDがある場合、passingできない場合がある
            #ex.   A#..D#  …NG
            #ex.   A#D..#  …NG
            #ex.   A#..D.# …これはOK.ただし、.D.がpassing_pointになる
            print("Yes")
            break
    else:
        print("No")
else:
    if is_reachable(A,C) == is_reachable(B,D) == True:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

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

#すぬけ君かふぬけ君を選び、1 マス右か 2 マス右にジャンプさせる。
#このときジャンプ先にマスが存在しなければならない
#またそのマスに岩が置かれていたりもう一人がいてはならない。

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

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

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

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

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

i += 1
if S[i] == S[i+1] == "#":
    imos_stop.append(imos_stop[-1] + 1)
else:
    imos_stop.append(imos_stop[-1])

imos_stop.append(imos_stop[-1])

#print(imos_stop)
#print(passing_point_set)

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

if need_passing == True:
    for passing_point in passing_point_set:
        if is_reachable(A,passing_point) == is_reachable(passing_point,C) == is_reachable(B,passing_point) == is_reachable(passing_point,D) == True and D != passing_point and D != passing_point+2:
            #passing pointの範囲内にDがある場合、passingできない場合がある
            #ex.   A#..D#  …NG
            #ex.   A#D..#  …NG
            #ex.   A#..D.# …これはOK.ただし、.D.がpassing_pointになる
            print("Yes")
            break
    else:
        print("No")
else:
    if is_reachable(A,C) == is_reachable(B,D) == True:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

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

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

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

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

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

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

i += 1
if S[i] == S[i+1] == "#":
    imos_stop.append(imos_stop[-1] + 1)
else:
    imos_stop.append(imos_stop[-1])

imos_stop.append(imos_stop[-1])

#print(imos_stop)
#print(passing_point_set)

def is_reachable(start,goal):
    if imos_stop[start] == imos_stop[goal]:
        return True
    else:
        return False

if need_passing == True:
    for passing_point in passing_point_set:
        if is_reachable(A,passing_point) == is_reachable(passing_point,C) == is_reachable(B,passing_point) == is_reachable(passing_point,D) == True:
            print("Yes")
            break
    else:
        print("No")
else:
    if is_reachable(A,C) == is_reachable(B,D) == True:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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


def log(*args):
    print(*args, file=sys.stderr)


def main():
    N, A, B, C, D = map(int, input().split())
    log(N, A, B, C, D)
    S = input()
    if "##" in S[B-1:D]:
        print("No")
        return
    if C < D:
        print("Yes")
        return
    log(S[B-2:D+1])
    if "..." in S[B-2:D+1]:
        print("Yes")
        return
    print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def log(*args):
    print(*args, file=sys.stderr)


def main():
    N, A, B, C, D = map(int, input().split())
    log(N, A, B, C, D)
    S = input()
    if "##" in S:
        print("No")
        return
    if C < D:
        print("Yes")
        return
    if "..." in S[B-2:D+1]:
        print("Yes")
        return
    print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def log(*args):
    print(*args, file=sys.stderr)


def main():
    N, A, B, C, D = map(int, input().split())
    log(N, A, B, C, D)
    S = input()
    if "##" in S:
        print("No")
        return
    if C < D:
        print("Yes")
        return
    if "..." in S:
        print("Yes")
        return
    print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
s = list(s)
s[a-1]="#"
s[b-1]="#"
s[c-1]="#"
q=0
for i in range(n-2):
    if s[i] == s[i+1] ==s[i+2]==".":
        q = 1
s[a-1]="."
s[b-1]="."
s[c-1]="."
r=0
s[a-1]="#"
s[b-1]="#"
s[d-1]="#"
for i in range(n-2):
    if s[i] == s[i+1] ==s[i+2]==".":
        r = 1
s[a-1]="."
s[b-1]="."
s[d-1]="."
f=1
s[a-1] = "#"
for i in range(b-1,d-1):
    if s[i] == s[i+1] == "#":
        f=0
s[a-1] = "."
s[d-1] = "#"
for i in range(a-1,c-1):
    if s[i] == s[i+1] == "#":
        f = 0
F=1
s[b-1] = "#"
for i in range(a-1,c-1):
    if s[i] == s[i+1] == "#":
        F=0
s[b-1] = "."
s[c-1] = "#"
for i in range(b-1,d-1):
    if s[i] == s[i+1] == "#":
        F = 0

if c < d:
    if not f and not F:
        print("No")
    else:
        print("Yes")
else:
    if not q and not r:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
s = list(s)
s[a-1]="#"
s[b-1]="#"
s[c-1]="#"
q=0
for i in range(n-2):
    if s[i] == s[i+1] ==s[i+2]==".":
        q = 1
s[a-1]="."
s[b-1]="."
s[c-1]="."
r=0
s[a-1]="#"
s[b-1]="#"
s[d-1]="#"
for i in range(n-2):
    if s[i] == s[i+1] ==s[i+2]==".":
        r = 1
s[a-1]="."
s[b-1]="."
s[d-1]="."
f=1
s[a-1] = "#"
for i in range(b-1,d-1):
    if s[i] == s[i+1] == "#":
        f=0
s[a-1] = "."
s[d-1] = "#"
for i in range(a-1,c-1):
    if s[i] == s[i+1] == "#":
        f = 0
F=1
s[b-1] = "#"
for i in range(a-1,c-1):
    if s[i] == s[i+1] == "#":
        F=0
s[b-1] = "."
s[c-1] = "#"
for i in range(b-1,d-1):
    if s[i] == s[i+1] == "#":
        F = 0

if not f and not F and not r and not q:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
s = list(s)
if c > d:
    x=b
    y=d
    b,d=a,c
    a,c=x,y
s[b-1] = "#"
for i in range(b-1,d-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
s[b-1] = "."
s[d-1] = "#"
for i in range(a-1,c-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

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

#すれ違いが必要かを判定する
#位置関係を全列挙したが、ABCDに制約があるので、その必要はなかった
#12通りがすれ違い要
#('B', 'C', 'A', 'D')　……要
#('B', 'A', 'C', 'D')　……要
#('A', 'D', 'C', 'B')　……要
#('B', 'C', 'D', 'A')　……要
#('A', 'D', 'B', 'C')　……要
#('A', 'B', 'D', 'C')　……要
#('C', 'B', 'A', 'D')　……要
#('C', 'B', 'D', 'A')　……要
#('C', 'D', 'B', 'A')　……要
#('D', 'A', 'C', 'B')　……要
#('D', 'C', 'A', 'B')　……要
#('D', 'A', 'B', 'C')　……要
need_passing_each_other_pattern = [
    ('B', 'C', 'A', 'D')
    ,('B', 'A', 'C', 'D')
    ,('A', 'D', 'C', 'B')
    ,('B', 'C', 'D', 'A')
    ,('A', 'D', 'B', 'C')
    ,('A', 'B', 'D', 'C')
    ,('C', 'B', 'A', 'D')
    ,('C', 'B', 'D', 'A')
    ,('C', 'D', 'B', 'A')
    ,('D', 'A', 'C', 'B')
    ,('D', 'C', 'A', 'B')
    ,('D', 'A', 'B', 'C')]
#12通りがすれ違い不要
#('B', 'D', 'C', 'A')　……不要
#('A', 'C', 'D', 'B')　……不要
#('A', 'B', 'C', 'D')　……不要　先にBにDを行かせておけばよい
#('A', 'C', 'B', 'D')　……不要
#('B', 'A', 'D', 'C')　……不要　先にCにAを行かせておけばよい
#('B', 'D', 'A', 'C')　……不要
#('C', 'A', 'B', 'D')　……不要
#('C', 'A', 'D', 'B')　……不要
#('C', 'D', 'A', 'B')　……不要　先にCにAを行かせておけばよい
#('D', 'B', 'A', 'C')　……不要
#('D', 'B', 'C', 'A')　……不要
#('D', 'C', 'B', 'A')　……不要　先にBにDを行かせておけばよい
needless_passing_each_other_pattern = [
    ('B', 'D', 'C', 'A')
    ,('A', 'C', 'D', 'B')
    ,('A', 'B', 'C', 'D')
    ,('A', 'C', 'B', 'D')
    ,('B', 'A', 'D', 'C')
    ,('B', 'D', 'A', 'C')
    ,('C', 'A', 'B', 'D')
    ,('C', 'A', 'D', 'B')
    ,('C', 'D', 'A', 'B')
    ,('D', 'B', 'A', 'C')
    ,('D', 'B', 'C', 'A')
    ,('D', 'C', 'B', 'A')]

input_dict = dict(zip(['A', 'B', 'C', 'D'],[A,B,C,D])) #dictの入力順序付き
input_sorted = sorted(input_dict.items(),key=lambda x:x[1])
input_sorted = [i[0] for i in input_sorted]

if tuple(input_sorted) in need_passing_each_other_pattern:
    need_passing = True
elif tuple(input_sorted) in needless_passing_each_other_pattern:
    need_passing = False

#下記3点を考える必要がある
#1.すれ違いができるか?? @ 全範囲
#……...な箇所があればOK
#2.すれ違い場所まで行けるか??? @すれ違い場所～各スタート
#……#2連続がなければOK
#3.すれ違い後、ゴールまで行けるか??　@各スタート～ゴール
#……#2連続がなければOK

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

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

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

i += 1
if S[i] == S[i+1] == "#":
    imos_stop.append(imos_stop[-1] + 1)
else:
    imos_stop.append(imos_stop[-1])

imos_stop.append(imos_stop[-1])

#print(imos_stop)
#print(passing_point_set)

def is_reachable(start,goal):
    if imos_stop[start] == imos_stop[goal]:
        return True
    else:
        return False

if need_passing == True:
    for passing_point in passing_point_set:
        if is_reachable(A,passing_point) == is_reachable(passing_point,C) == is_reachable(B,passing_point) == is_reachable(passing_point,D) == True:
            print("Yes")
            break
    else:
        print("No")
else:
    if is_reachable(A,C) == is_reachable(B,D) == True:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def movable(S,N,A,B,C,D):
    #右にあるやつがそこより左のゴールにたどり着くのに邪魔になることはない
    #よってより右に向かうBをさきにDに向かわせる
    #A<Bならこれで互いに邪魔にならないからそれぞれで判定
    #具体的には"##"がなければよし
    #A>BならAが動く範囲(A<=pt<=C)で"..."があれば相手が邪魔にならない
    if A > B:
        if "..." in S[A-1:C+1] and "##" not in S[B:D+1]:
            return True
    else:
        if "##" not in S[A:C+1] and "##" not in S[B:D+1]:
            return True
    return False

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

    if C > D:
        A,B = B,A
        C,D = D,C

    if movable(S,N,A-1,B-1,C-1,D-1):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def movable(S,N,A,B,C,D):
    #右にあるやつがそこより左のゴールにたどり着くのに邪魔になることはない
    #よってより右に向かうBをさきにDに向かわせる
    #A<Bならこれで互いに邪魔にならないからそれぞれで判定
    #具体的には"##"がなければよし
    #A>BならAが動く範囲(A<=pt<=C)で"..."があれば相手が邪魔にならない
    if A > B:
        if "..." in S[A:C+1] and "##" not in S[B:D+1]:
            return True
    else:
        if "##" not in S[A:C+1] and "##" not in S[B:D+1]:
            return True
    return False

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

    if C > D:
        A,B = B,A
        C,D = D,C

    if movable(S,N,A-1,B-1,C-1,D-1):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import fractions
import sys
from functools import reduce
import math

input = sys.stdin.readline


def main():
    n, a, b, c, d = input_list()
    s = input()
    uses = s[a-1:d]
    if '##' in uses:
        print('No')
        exit()
    if c < d:
        print('Yes')
    else:
        if '...' in s[b-2:d]:
            print('Yes')
        else:
            print('No')


def get_camulative(l):
    import itertools
    # 累積和
    return [0] + list(itertools.accumulate(l))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import fractions
import sys
from functools import reduce
import math

input = sys.stdin.readline


def main():
    n, a, b, c, d = input_list()
    s = input()
    uses = s[a-1:d]
    if '##' in uses:
        print('No')
        exit()
    if c < d:
        print('Yes')
    else:
        if '...' in s[b-1:d]:
            print('Yes')
        else:
            print('No')


def get_camulative(l):
    import itertools
    # 累積和
    return [0] + list(itertools.accumulate(l))

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if s[c] == '#' or s[d] == '#':
    print('No')
    exit()

# '##'を検知
num_hash = s[a:].count('##')
if num_hash > 0:
    print('No')
    exit()

if c > d:
    # 3 マス以上の連続する'.'が必要
    num_dot = s[b:].count("...")
    if num_dot == 0:
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

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

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

if C < D:
    print('Yes')
    exit(0)

for i in range(B-1, D):
    if S[i-1:i+2] == '...':
        print('Yes')
        exit(0)
print('No')

Submission status: Wrong Answer

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

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

if C < D:
    print('Yes')
    exit(0)

for i in range(B, min(C, D)):
    if S[i-1:i+2] == '...':
        print('Yes')
        exit(0)
print('No')

Submission status: Wrong Answer

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

ooo = False
cnt_o = 0
cnt_x = 0
for i in range(A-1, max(C, D)):
    if S[i] == '.':
        if B <= i+1 <= min(C, D):
            cnt_o += 1

        if cnt_x >= 2:
            print('No')
            exit(0)
        cnt_x = 0
    else:
        cnt_x += 1
        if cnt_o >= 3:
            ooo = True
        cnt_o = 0

if C < D:
    print('Yes')
else:
    if ooo:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

ooo = False
cnt_o = 0
cnt_x = 0
for i in range(A, max(C, D)):
    if S[i] == '.':
        if B <= i+1 <= min(C, D):
            cnt_o += 1

        if cnt_x >= 2:
            print('No')
            exit(0)
        cnt_x = 0
    else:
        cnt_x += 1
        if cnt_o >= 3:
            ooo = True
        cnt_o = 0

if C < D:
    print('Yes')
else:
    if ooo:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

ooo = False
cnt_o = 0
cnt_x = 0
for i in range(A, max(C, D)):
    if S[i] == '.':
        cnt_o += 1
        if cnt_x >= 2:
            print('No')
            exit(0)
        cnt_x = 0
    else:
        if B <= i+1 <= D:
            cnt_x += 1
        if cnt_o >= 3:
            ooo = True
        cnt_o = 0

if C < D:
    print('Yes')
else:
    if ooo:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

ooo = False
cnt_o = 0
cnt_x = 0
for i in range(A-1, max(C, D)):
    if S[i] == '.':
        cnt_o += 1
        if cnt_x >= 2 and A <= i+1 <= C and B <= i+1 <= D:
            print('No')
            exit(0)
        cnt_x = 0
    else:
        cnt_x += 1
        if cnt_o >= 3 and B <= i-2 <= min(C, D):
            ooo = True
        cnt_o = 0

if C < D:
    print('Yes')
else:
    if ooo:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

ooo = False
cnt_o = 0
cnt_x = 0
for i in range(A-1, max(C, D)):
    if S[i] == '.':
        cnt_o += 1
        if cnt_x >= 2:
            print('No')
            exit(0)
        cnt_x = 0
    else:
        cnt_x += 1
        if cnt_o >= 3 and B <= i-2 <= min(C, D):
            ooo = True
        cnt_o = 0

if C < D:
    print('Yes')
else:
    if ooo:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

ooo = False
cnt_o = 0
cnt_x = 0
for i in range(A-1, max(C, D)):
    if S[i] == '.':
        cnt_o += 1
        if cnt_x >= 2:
            print('No')
            exit(0)
        cnt_x = 0
    else:
        cnt_x += 1
        if cnt_o >= 3 and B <= i+1 <= min(C, D):
            ooo = True
        cnt_o = 0

if C < D:
    print('Yes')
else:
    if ooo:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

ooo = False
cnt_o = 0
cnt_x = 0
for i in range(A, max(C, D)):
    if S[i] == '.':
        cnt_o += 1
        if cnt_x >= 2:
            print('No')
            exit(0)
        cnt_x = 0
    else:
        cnt_x += 1
        if cnt_o >= 3:
            ooo = True
        cnt_o = 0

if C < D:
    print('Yes')
else:
    if ooo:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

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

def find_route(X,Y):
    for i in range(X,Y):
        if S[i] == S[i + 1] == '#':
            return False
    return True

if C < D:
    if find_route(A,C) and find_route(B,D):
        print('Yes')
    else:
        print('No')
else:
    flag = False
    for i in range(B,D):
        if S[i] == S[i + 1] == S[i + 2] == '.':
            flag = True
            break
    if flag and find_route(A,C):
        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 '##' in s[a-1:d]:
    print('No')
  else:
    print('Yes')
else:
  if '##' in s[a-1:c] or '...' not in s[b-2:d]:
    print('No')
  else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
flag1, flag2 = False, False
if d > c:
    flag = "##" not in s[b: d] and "##" not in s[a: c]
else:
    flag = "..." in s[b: d]

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
flag1, flag2 = False, False
if d > c:
    flag = "##" not in s[b: d - 1] and "##" not in s[a: c - 1]
else:
    flag = "..." in s[b: d]

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
flag1, flag2 = False, False
if d > c:
    print("OK1")
    flag = "##" not in s[b: d - 1] and "##" not in s[a: c - 1]
else:
    print("OK2")
    flag = "..." in s[b: d]

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
flag1, flag2 = False, False
if d > c:
    flag = "##" not in s[b: d - 1] and "##" not in s[a: c - 1]
else:
    flag = "..." in s[b: d - 1]

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
flag1, flag2 = False, False
if d > c:
    print("OK1")
    flag = "##" not in s[b: d - 1] and "##" not in s[a: c - 1]
else:
    print("OK2")
    flag = "..." in s[b: d - 1]

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

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
def deal(s):
    stin=[]
    for i in range(len(s)):
        if s[i]==".":
            stin.append(0)
        else:
            stin.append(1)
    return stin
n,a,b,c,d=map(int,input().split())
s=deal(input())
if c<b:
    for i in range(c-1):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    for i in range(b,d-1):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    print("Yes")
elif c<d:
    for i in range(n-1):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    print("Yes")
elif d<c:
    if c==n:
        for i in range(a-1,c-1):
            if s[i]==1 and s[i+1]==1:
                print("No")
                exit()
        for i in range(b,d):
            if s[i]==0 and s[i-1]==0 and s[i+1]==0:
                print("Yes")
                exit()
        print("No") 
        exit()  
    for i in range(a-1,c):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    for i in range(b,d):
        if s[i]==0 and s[i-1]==0 and s[i+1]==0:
            print("Yes")
            exit()
    print("No") 
    exit()
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
def deal(s):
    stin=[]
    for i in range(len(s)):
        if s[i]==".":
            stin.append(0)
        else:
            stin.append(1)
    return stin
n,a,b,c,d=map(int,input().split())
s=deal(input())
if c<b:
    for i in range(c-1):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    for i in range(b,d-1):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    print("Yes")
elif c<d:
    for i in range(n-1):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    print("Yes")
elif d<c:
    check=0
    for i in range(a-1,c):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    for i in range(b,d):
        if s[i]==0 and s[i-1]==0 and s[i+1]==0:
            print("Yes")
            exit()
    print("No") 
    exit()
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
def deal(s):
    stin=[]
    for i in range(len(s)):
        if s[i]==".":
            stin.append(0)
        else:
            stin.append(1)
    return stin
n,a,b,c,d=map(int,input().split())
s=deal(input())
if c<b:
    for i in range(c-1):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    for i in range(b,d-1):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    print("Yes")

elif c<d:
    for i in range(n-1):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    print("Yes")
elif d<c:
    check=0
    for i in range(a-1,c):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    for i in range(b,d):
        if s[i]==0 and s[i-1]==0 and s[i+1]==0:
            print("Yes")
            exit()
    print("No") 
    exit()
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
def deal(s):
    stin=[]
    for i in range(len(s)):
        if s[i]==".":
            stin.append(0)
        else:
            stin.append(1)
    return stin
n,a,b,c,d=map(int,input().split())
s=deal(input())
if c<d:
    for i in range(n-1):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    print("Yes")
elif d<c:
    check=0
    for i in range(a-1,c):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    for i in range(b,d):
        if s[i]==0 and s[i-1]==0 and s[i+1]==0:
            print("Yes")
            exit()
    print("No") 
    exit()
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
def deal(s):
    stin=[]
    for i in range(len(s)):
        if s[i]==".":
            stin.append(0)
        else:
            stin.append(1)
    return stin
n,a,b,c,d=map(int,input().split())
s=deal(input())
if c<d:
    for i in range(n-1):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    print("Yes")
elif d<c:
    check=0
    for i in range(a-1,c):
        if s[i]==1 and s[i+1]==1:
            print("No")
            exit()
    for i in range(b,c-2):
        if s[i]==0 and s[i+1]==0 and s[i+2]==0:
            check=1
    if check<1:
        print("No")
        exit()
    print("Yes")
else:
    print("No")