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 = list(map(int, input().split()))
s = '#' + input()

import re

# 今いる位置から目的地まで進めるか？
def can_forward(start, end):
    if start>end:
        end,start = start,end
    steps = s[start:end+1]
    if "##" in steps:
        return False
    return True

if not (can_forward(a, c) or can_forward(b, d)):
    print('No')
    exit()

if a<b and c>d or a>b and c<d:
    # 二人とも追い越し可能区間にいけるか？
    for m in re.finditer(r'\.\.\.+',s):
        f,t = m.span()
        if can_forward(a, f) and can_forward(b, f):
            print('Yes')
            exit()
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

import re

# 今いる位置から目的地まで進めるか？
def can_forward(start, end):
    if start>end:
        end,start = start,end
    steps = s[start:end+1]
    if "##" in steps:
        return False
    return True

if not (can_forward(a, c) or can_forward(b, d)):
    print('No')
    exit()

if a<b and c>d:
    # 二人とも追い越し可能区間にいけるか？
    for m in re.finditer(r'\.\.\.+',s):
        f,t = m.span()
        if can_forward(a, f) and can_forward(b, f):
            print('Yes')
            exit()
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

s=input()

if c<d:
    p=s[a:d-1].count("##")
    if p==0:
        print("Yes")
    else:
        print("No")
else:
    p=s[a:c-1].count("##")
    q=s[b-1:d+2].count("...")
    if p==0 and q>0:
        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:
    p=s[a:d-1].count("##")
    if p==0:
        print("Yes")
    else:
        print("No")
else:
    p=s[a:c-1].count("##")
    q=s[b-1:d].count("...")
    if p==0 and q>0:
        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:
    p=s[a:d-1].count("##")
    if p==0:
        print("Yes")
    else:
        print("No")
else:
    p=s[a:c-1].count("##")
    q=s[b-1:d+1].count("...")
    if p==0 and q>0:
        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:
    p=s[a:d-1].count("##")
    if p==0:
        print("Yes")
    else:
        print("No")
else:
    p=s[a:c-1].count("##")
    q=s[b:d+1].count("...")
    if p==0 and q>0:
        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:
    p=s[a:d-1].count("##")
    if p==0:
        print("Yes")
    else:
        print("No")
else:
    p=s[a:c-1].count("##")
    q=s[b:d+2].count("...")
    if p==0 and q>0:
        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:
    p=s[a:d-1].count("##")
    if p==0:
        print("Yes")
    else:
        print("No")
else:
    p=s[a:c-1].count("##")
    q=s[b:d-1].count("...")
    if p==0 and q>0:
        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:
    p=s[a:d+1].count("##")
    if p==0:
        print("Yes")
    else:
        print("No")
else:
    p=s[a:c+1].count("##")
    q=s[b:d+1].count("...")
    if p==0 and q>0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

# ##となっていたら無理
# C < D のとき、それぞれが移動可能かでわかる
# C > D のときは? 追い越しは...となる箇所があればいける

for i, s in enumerate(S[:-1]):
    if S[i:i+2] == '##':
        print('No')
        quit()

if C < D:
    print('Yes')
else:
    for i, s in enumerate(S[:-2]):
        if S[i:i+3] == '...':
            print('Yes')
            quit()
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = list(map(int,input().split()))
A -= 1
B -= 1
C -= 1
D -= 1
S = input()
if S[C] == '#' or S[D] == '#':
    print('No')
    exit()
if C<D:
    LA = S[A:C+1]
    LB = S[B:D+1]
    if LA.count('##') > 0 or LB.count('##') > 0:
        print('No')
        exit()
if C>D:
    LA = S[A:D+1]
    LB = S[B:C+1]
    if LA.count('##') > 0 or LB.count('##') > 0 or LA.count('...') == 0:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = list(map(int,input().split()))
A -= 1
B -= 1
C -= 1
D -= 1
S = input()
if S[C] == '#' or S[D] == '#':
    print('No')
    exit()
if C<D:
    LA = S[A:C+1]
    LB = S[B:D+1]
    if LA.count('##') > 0 or LB.count('##') > 0:
        print('No')
        exit()
if C>D:
    LA = S[A:D+1]
    LB = S[B:C+1]
    if LA.count('##') > 0 or LB.count('##') > 0 or LB.count('...') == 0:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    n, a, b, c, d = geta(int)
    s = "#" + gete()

    if c < d:
        # no consecutive rocks between [a,c] and [b,d]
        if "##" in s[a:c + 1] or "##" in s[b:d + 1]:
            print("No")
        else:
            print("Yes")
    else:
        # no consecutive rocks between [a,c] and,
        # [b-1,d+1] contains "..."

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

s = input()

if c < d:
    if "##" in s[a-1:c] or "##" in s[b-1:d]:
        print("No")
    else:
        print("Yes")
else:
    if "..." in s[b-2:d] and "##" not in s[a-1:c] and "##" not in s[b-1:d]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

s = input()

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

Submission status: Wrong Answer

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

s = input()

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

Submission status: Wrong Answer

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

if c < d:
    if s[a-1:c].find('##')==-1 and s[b-1:d].find('##')==-1:
        print('Yes')
    else:
        print('No')
else:
    if s[a-1:c].find('##')==-1 and s[b-1:d].find('##')==-1 and s[b-2:d+1].find('...'):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
max_sp = 0
max_bl = 0
cnt_sp = 0
cnt_bl = 0
for l in s[b-2:d+1]:
    if l == '.':
        cnt_sp += 1
        max_sp = max(cnt_sp, max_sp)
    else:
        cnt_sp = 0

for l in s:
    if l == '#':
        cnt_bl += 1
        max_bl = max(cnt_bl, max_bl)
    else:
        cnt_bl = 0

if c < d:
    if max_bl < 2:
        print('Yes')
    else:
        print('No')
else:
    if max_sp >= 3 and max_bl < 2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
max_sp = 0
max_bl = 0
cnt_sp = 0
cnt_bl = 0
for l in s[b-2:d]:
    if l == '.':
        cnt_sp += 1
        max_sp = max(cnt_sp, max_sp)
    else:
        cnt_sp = 0

for l in s:
    if l == '#':
        cnt_bl += 1
        max_bl = max(cnt_bl, max_bl)
    else:
        cnt_bl = 0

if c < d:
    if max_bl < 2:
        print('Yes')
    else:
        print('No')
else:
    if max_sp >= 3 and max_bl < 2:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
max_sp = 0
max_bl = 0
cnt_sp = 0
cnt_bl = 0
for l in s[b-2:d]:
    if l == '.':
        cnt_sp += 1
        max_sp = max(cnt_sp, max_sp)
    else:
        cnt_sp = 0

for l in s:
    if l == '#':
        cnt_bl += 1
        max_bl = max(cnt_bl, max_bl)
    else:
        cnt_bl = 0

if c < d:
    if max_bl < 2:
        print('Yes')
    else:
        print('No')
else:
    if max_sp >= 3:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
max_sp = 0
max_bl = 0
cnt_sp = 0
cnt_bl = 0
for l in s[b-2:d]:
    if l == '.':
        cnt_sp += 1
        cnt_bl = 0
        max_sp = max(cnt_sp, max_sp)
    else:
        cnt_bl += 1
        cnt_sp = 0
        max_bl = max(cnt_bl, max_bl)
if s[c-1] != '#' and s[d-1] != '#':
    if c < d:
        if max_bl < 2:
            print('Yes')
        else:
            print('No')
    else:
        if max_sp >= 3:
            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()
max_sp = 0
max_bl = 0
cnt_sp = 0
cnt_bl = 0
for l in s[b-1:d]:
    if l == '.':
        cnt_sp += 1
        cnt_bl = 0
        max_sp = max(cnt_sp, max_sp)
    else:
        cnt_bl += 1
        cnt_sp = 0
        max_bl = max(cnt_bl, max_bl)
if s[c-1] != '#' and s[d-1] != '#':
    if c < d:
        if max_bl < 2:
            print('Yes')
        else:
            print('No')
    else:
        if max_sp >= 3:
            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()
max_sp = 0
max_bl = 0
cnt_sp = 0
cnt_bl = 0
for l in s[b:d]:
    if l == '.':
        cnt_sp += 1
        cnt_bl = 0
        max_sp = max(cnt_sp, max_sp)
    else:
        cnt_bl += 1
        cnt_sp = 0
        max_bl = max(cnt_bl, max_bl)
if s[c-1] != '#' and s[d-1] != '#':
    if c < d:
        if max_bl < 2:
            print('Yes')
        else:
            print('No')
    else:
        if max_sp >= 3:
            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()
max_sp = 0
max_bl = 0
cnt_sp = 0
cnt_bl = 0
for l in s:
    if l == '.':
        cnt_sp += 1
        cnt_bl = 0
        max_sp = max(cnt_sp, max_sp)
    else:
        cnt_bl += 1
        cnt_sp = 0
        max_bl = max(cnt_bl, max_bl)
if s[c-1] != '#' and s[d-1] != '#':
    if c < d:
        if max_bl < 2:
            print('Yes')
        else:
            print('No')
    else:
        if max_sp >= 3:
            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()
max_sp = 0
max_bl = 0
cnt_sp = 0
cnt_bl = 0
for l in s:
    if l == '.':
        cnt_sp += 1
        cnt_bl = 0
        max_sp = max(cnt_sp, max_sp)
    else:
        cnt_bl += 1
        cnt_sp = 0
        max_bl = max(cnt_bl, max_bl)
if c < d:
    if max_bl < 2:
        print('Yes')
    else:
        print('No')
else:
    if max_sp >= 3:
        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:
        print("No")
    else:
        if "..." in s[B-2:D+1]:
            print("Yes")
        else:
            print("No")
else:
    if "##" in s:
        print("Yes")
    else:
        print("Yes")

Submission status: Wrong Answer

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

if C > D:
    if "##" in s:
        print("No")
    else:
        if "..." in s[B-2:D+1]:
            print("No")
        else:
            print("No")
else:
    if "##" in s:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

if C > D:
    if "##" in s:
        print("No")
    else:
        if "..." in s[B-2:D+1]:
            print("Yes")
        else:
            print("No")
else:
    if "##" in s:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

if C > D:
    if "..." in s[B-2:D+1]:
        flag = False
    if "##" in s:
        print("Yes")
    else:
        if flag:
            print("No")
        else:
            print("Yes")
else:
    if "##" in s:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

if C > D:
    if "..." in s[B-3:D+1]:
        flag = False
    if "##" in s:
        print("No")
    else:
        if flag:
            print("No")
        else:
            print("Yes")
else:
    if "##" in s:
        print("No")
    else:
        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 "..." in s[B-2:D+2]:
        flag = True
    if "##" in s:
        print("No")
    else:
        if not flag:
            print("No")
        else:
            print("Yes")
else:
    if "##" in s:
        print("No")
    else:
        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 "..." in s[B-2:D+1]:
        flag = True
    if "##" in s:
        print("No")
    else:
        if not flag:
            print("No")
        else:
            print("Yes")
else:
    if "##" in s:
        print("No")
    else:
        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 "..." in s[B-2:D]:
        flag = True
    if "##" in s:
        print("No")
    else:
        if not flag:
            print("No")
        else:
            print("Yes")
else:
    if "##" in s:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

if C > D:
    s[D-1] = '#'
    s = ''.join(s)
    if "..." in s[B-2:D]:
        flag = True
    if "##" in s and not flag:
        print("No")
    else:
        if not flag:
            print("No")
        else:
            print("Yes")
else:
    s = ''.join(s)
    if "##" in s:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

if C > D:
    s[D-1] = '#'
    s = ''.join(s)
    if "..." in s[B-1:D]:
        flag = True
    if "##" in s and not flag:
        print("No")
    else:
        if not flag:
            print("No")
        else:
            print("Yes")
else:
    s = ''.join(s)
    if "##" in s:
        print("No")
    else:
        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 "..." in s[B-1:D]:
        flag = True
    if "##" in s:
        print("No")
    else:
        if not flag:
            print("No")
        else:
            print("Yes")
else:
    if "##" in s:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

if C > D:
    s[D-1] = '#'
    s = ''.join(s)
    if "..." in s[B-1:D]:
        flag = True
else:
    s = ''.join(s)

if "##" in s:
    print("No")
else:
    if not flag:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
s = list(input())
flag = False
if C > D:
    s[D-1] = '#'
    s = ''.join(s)
    if "..." in s[B-1:D]:
        flag = True
else:
    s = ''.join(s)
if "##" in s and not flag:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
s = list(input())
flag = False
if C > D:
    s[D-1] = '#'
    s = ''.join(s)
    if "..." in s[B-1:D]:
        flag = True
if "##" in s and not flag:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
s = list(input())
flag = False
if C > D:
    s[D-1] = '#'
    s = ''.join(s)
    if "..." in s[B-1:C]:
        flag = True
if "##" in s and not flag:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N,A,B,C,D = map(int,readline().split())
S = readline().rstrip()

if C < D:
    if S[B-1:D].find('##') == -1 and S[A-1:C].find('##') == -1:
        print('Yes')
    else:
        print('No')
else:
    if S[B-1:D].find('##') == -1 and S[A-1:C].find('##') == -1 and S[B-2:C+1].find('...') != -1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N,A,B,C,D = map(int,readline().split())
S = readline().rstrip()

if C < D:
    if S[B-1:D].find('##') == -1 and S[A-1:C].find('##') == -1:
        print('Yes')
    else:
        print('No')
else:
    if S[B-1:D].find('##') == -1 and S[A-1:C].find('##') == -1 and S[B-2:C].find('...') != -1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N,A,B,C,D = map(int,readline().split())
S = readline().rstrip()

if C < D:
    if S[B-1:D].find('##') == -1 and S[A-1:C].find('##') == -1:
        print('Yes')
    else:
        print('No')
else:
    if S[B-1:D].find('##') == -1 and S[A-1:C].find('##') == -1 and S[B-1:C].find('...') != -1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,a,b,c,d = iim()
s = input()
st = s[b-1:min(c,d)+1]
s = s[a-1:max(c,d)]

if '##' in s:
    print('No')
elif c < d:
    print('Yes')
else:
    print('Yes' if '...' in st else ' No')

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,a,b,c,d = iim()
s = input()
st = s[b-1:min(c,d)]
s = s[a-1:max(c,d)]

if '##' in s:
    print('No')
elif c < d:
    print('Yes')
else:
    print('Yes' if '...' in st else ' No')

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,a,b,c,d = iim()
s = input()
st = s[b:min(c,d)]
s = s[a:max(c,d)]

if '##' in s:
    print('No')
elif c < d:
    print('Yes')
else:
    print('Yes' if '...' in st else ' No')

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,a,b,c,d = iim()
s = input()[a:d]

if '##' in s:
    print('No')
elif c < d:
    print('Yes')
else:
    print('Yes' if '...' in s else ' No')

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

n,a,b,c,d = iim()
s = input()[:d]

if '##' in s:
    print('No')
elif c < d:
    print('Yes')
else:
    print('Yes' if '...' in s else ' No')

Submission status: Wrong Answer

Solution code:
import re

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

flag = True
if re.search(r'##', S[min([A,B]): max([C,D])+1]):
    flag *= False

if D < C:
    if re.search(r'\.\.\.', S[B-1:D+2]):
        flag *= True
    else:
        flag *= False
        
print('Yes') if flag else print('No')

Submission status: Wrong Answer

Solution code:
import re

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

flag = True
if re.search(r'##', S[min([A,B]): max([C,D])+1]):
    flag *= False

if D < C:
    if re.search(r'\.\.\.', S[B:D+1]):
        flag *= True
    else:
        flag *= False
        
print('Yes') if flag else print('No')

Submission status: Wrong Answer

Solution code:
import re

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

flag = True
#if re.search(r'##', S[min([A,B]): max([C,D])+1]):
#    flag *= False

if C < D:
    if re.search(r'\.\.', S[B:C+1]):
        flag *= True
    else:
        flag *= False
else:
    if re.search(r'\.\.\.', S[B:D+1]):
        flag *= True
    else:
        flag *= False
        
print('Yes') if flag else print('No')

Submission status: Wrong Answer

Solution code:
import re

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

flag = True
if re.search(r'##', S[min([A,B]): max([C,D])+1]):
    flag *= False

if C < D:
    if re.search(r'\.\.', S[B:C+1]):
        flag *= True
    else:
        flag *= False
else:
    if re.search(r'\.\.\.', S[B:D+1]):
        flag *= True
    else:
        flag *= False
        
print('Yes') if flag else print('No')

Submission status: Wrong Answer

Solution code:
import re

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

if C < D:
    if re.search(r'\.\.', S):
        print('Yes')
    else:
        print('No')
else:
    if re.search(r'\.\.\.', S):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a
import sys
n, a, b, c, d = map(int, input().split())
s = list(input())

for i in range(n - 1):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        sys.exit()

if c > d:
    f = False
    for i in range(b - 1, d):
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            f = True
else:
    f = True
if f:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a
import sys
n, a, b, c, d = map(int, input().split())
s = list(input())

for i in range(n - 1):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        sys.exit()

if c > d:
    f = False
    for i in range(b, d):
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            f = True
else:
    f = True
if f:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a
import sys
n, a, b, c, d = map(int, input().split())
s = list(input())

for i in range(n - 1):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        sys.exit()

if c > d:
    f = False
    for i in range(b, d - 2):
        if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
            f = True
else:
    f = True
if f:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a
import sys
n, a, b, c, d = map(int, input().split())
s = list(input())

for i in range(n - 1):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        sys.exit()

if c > d:
    f = False
    for i in range(b, max(d - 1, n - 2)):
        if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
            f = True
else:
    f = True
if f:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc034/tasks/agc034_a
import sys
n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
# 0-indexed
s = list(input())
s[a] = 'A'
s[b] = 'B'
for i in range(n - 1):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        sys.exit()

if c > d:
    f = False
    for i in range(n - 1):
        if i != c and i != d and s[i] == '.' and s[i + 1] == '.':
            f = True
else:
    f = True
if f:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
S = list(s)
if c < d:
  k = S[a:d]
  for i in range(len(k)-1):
    if k[i] == k[i+1] == '#':
      print('No')
      exit()
  print('Yes')
else:
  bc = s[b-1:d+1]
  if not '...' in bc:
    print('No')
    exit()
  k = S[a:d]
  for i in range(len(k)-1):
    if k[i] == k[i+1] == '#':
      print('No')
      exit()
  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:
  k = S[a:d]
  for i in range(len(k)-1):
    if k[i] == k[i+1] == '#':
      print('No')
      exit()
  print('Yes')
else:
  bc = s[b-1:d]
  if not '...' in bc:
    print('No')
    exit()
  k = S[a:d]
  for i in range(len(k)-1):
    if k[i] == k[i+1] == '#':
      print('No')
      exit()
  print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
print('YNeos'[not ('...' in input()[b:min(c,d)+1] or c<d)::2])

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
print('YNeos'[not ('...' in input() or c<d)::2])

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
print('YNeos'[('...' in input() or c<d)::2])

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:
            #passing pointの範囲内にDやDがある場合、passingできない場合がある
            #ex.   A#..D#  …NGではない
                # A#.BD#.  として、追い抜かせてからB→D
            #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")