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

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

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

        print('No')
        exit()

    else:
        print('Yes')
        exit()

Submission status: Wrong Answer

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

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

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

        print('No')
        exit()

    else:
        print('Yes')
        exit()

Submission status: Wrong Answer

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

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

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

        print('No')
        exit()

    else:
        print('Yes')
        exit()

Submission status: Wrong Answer

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

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

    if C > D:
        for i in range(N-2):
            if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
                print('Yes')
                exit()

        print('No')
        exit()

    else:
        print('Yes')
        exit()

Submission status: Wrong Answer

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

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

    if C > D:
        for i in range(N-2):
            if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
                print('Yes')
                exit()

        print('No')
        exit()

    else:
        print('Yes')

Submission status: Wrong Answer

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

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

    print('Yes')
    exit()

if C > D:
    for i in range(N-2):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            print('Yes')
            exit()

    print('No')
    exit()

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

"""
A<Bとする。
C<Dの場合：
A～CとB~Dの間に"##"が無ければ達成できる.
C>Dの場合：
上記に加え、B~Cの間に"..."が存在すれば達成できる
"""

n,a,b,c,d = map(int,readline().split())
s = readline().rstrip().decode('utf-8')
a,b,c,d = a-1,b-1,c-1,d-1

flag = 1
space = 0
res = 0
rock = 0
for i in range(a,c+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
for i in range(b,d+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
if c > d:
	for i in range(b-1,d+2):
		if s[i] == ".":
			space += 1
		else:
			res = max(res,space)
			space = 0
	if res < 3:
		flag = 0

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

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

"""
A<Bとする。
C<Dの場合：
A～CとB~Dの間に"##"が無ければ達成できる.
C>Dの場合：
上記に加え、B~Cの間に"..."が存在すれば達成できる
"""

n,a,b,c,d = map(int,readline().split())
s = readline().rstrip().decode('utf-8')
a,b,c,d = a-1,b-1,c-1,d-1

flag = 1
space = 0
res = 0
rock = 0
for i in range(a,c+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
for i in range(b,d+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
if c > d:
	for i in range(b,d+1):
		if s[i] == ".":
			space += 1
		else:
			res = max(res,space)
			space = 0
	if res < 3:
		flag = 0

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

Submission status: Wrong Answer

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

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

    print('Yes')

if C > D:
    for i in range(N-2):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            print('Yes')
            exit()

    print('No')

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

"""
A<Bとする。
C<Dの場合：
A～CとB~Dの間に"##"が無ければ達成できる.
C>Dの場合：
上記に加え、B~Cの間に"..."が存在すれば達成できる
"""

n,a,b,c,d = map(int,readline().split())
s = readline().rstrip().decode('utf-8')
a,b,c,d = a-1,b-1,c-1,d-1

flag = 1
space = 0
res = 0
rock = 0
for i in range(a,c+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
for i in range(b,d+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
if c > d:
	for i in range(b-1,d+2):
		if s[i] == ".":
			space += 1
		else:
			res = max(res,space)
			space = 0
	if res < 3:
		flag = 0


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

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

"""
A<Bとする。
C<Dの場合：
A～CとB~Dの間に"##"が無ければ達成できる.
C>Dの場合：
上記に加え、B~Cの間に"..."が存在すれば達成できる
"""

n,a,b,c,d = map(int,readline().split())
s = readline().rstrip().decode('utf-8')
a,b,c,d = a-1,b-1,c-1,d-1

flag = 1
space = 0
res = 0
rock = 0
for i in range(a,c+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
for i in range(b,d+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
if c > d:
	for i in range(b-1,min(n,d+2)):
		if s[i] == ".":
			space += 1
		else:
			res = max(res,space)
			space = 0
	if res < 3:
		flag = 0


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

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

"""
A<Bとする。
C<Dの場合：
A～CとB~Dの間に"##"が無ければ達成できる.
C>Dの場合：
上記に加え、B~Cの間に"..."が存在すれば達成できる
"""

n,a,b,c,d = map(int,readline().split())
s = readline().rstrip().decode('utf-8')
a,b,c,d = a-1,b-1,c-1,d-1

flag = 1
space = 0
res = 0
rock = 0
for i in range(a,c+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
for i in range(b,d+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
if c > d:
	for i in range(b-1,min(n,c+2)):
		if s[i] == ".":
			space += 1
		else:
			res = max(res,space)
			space = 0
	if res < 3:
		flag = 0


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

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

"""
A<Bとする。
C<Dの場合：
A～CとB~Dの間に"##"が無ければ達成できる.
C>Dの場合：
上記に加え、B~Cの間に"..."が存在すれば達成できる
"""

n,a,b,c,d = map(int,readline().split())
s = readline().rstrip().decode('utf-8')
a,b,c,d = a-1,b-1,c-1,d-1

flag = 1
space = 0
res = 0
rock = 0
for i in range(a,c+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
for i in range(b,d+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
if c > d:
	for i in range(b-1,c+1):
		if s[i] == ".":
			space += 1
		else:
			res = max(res,space)
			space = 0
	if res < 3:
		flag = 0


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

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

"""
A<Bとする。
C<Dの場合：
A～CとB~Dの間に"##"が無ければ達成できる.
C>Dの場合：
上記に加え、B~Cの間に"..."が存在すれば達成できる
"""

n,a,b,c,d = map(int,readline().split())
s = readline().rstrip().decode('utf-8')
a,b,c,d = a-1,b-1,c-1,d-1

flag = 1
space = 0
res = 0
rock = 0
for i in range(a,c+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
for i in range(b,d+1):
	if s[i] == "#":
		rock += 1
	else:
		rock = 0
	if rock >= 2:
		flag = 0
if c > d:
	for i in range(b,c+1):
		if s[i] == ".":
			space += 1
		else:
			res = max(res,space)
			space = 0
	if res < 3:
		flag = 0


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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = list(map(int, input().split()))
a,b,c,d = a-1,b-1,c-1,d-1 #indexに合わせる
s = input()
k = 0
swappable = False
possible = True

#A-C, B-D に岩が二つ並んでいる箇所があるなら不可能

#C>Dの場合B以上の位置で3マス以上の空白があれば
for i in range(a, max(c,d)):#+1):
    j = s[i]
    if j=='#':
        if (k==0) and ((a<i<c) or (b<i<d)):
            possible = False
            break
        k = 0
    if j=='.':
        k += 1
        if (k>=3) and (b<=i<=d):
            swappable = True
    

if (c>d) and (not swappable):
    possible = False

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = list(map(int, input().split()))
a,b,c,d = a-1,b-1,c-1,d-1 #indexに合わせる
s = input()
k = 0
swappable = False
possible = True

#A-C, B-D に岩が二つ並んでいる箇所があるなら不可能

#C>Dの場合B以上の位置で3マス以上の空白があれば
for i in range(a, max(c,d)+1):
    j = s[i]
    if j=='#':
        if (k==0) and ((a<i<c) or (b<i<d)):
            possible = False
            break
        k = 0
    if j=='.':
        k += 1
        if (k>=3) and (b<i<=d):
            swappable = True
    

if (c>d) and (not swappable):
    possible = False

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = list(map(int, input().split()))
a,b,c,d = a-1,b-1,c-1,d-1 #indexに合わせる
s = input()
k = 0
swappable = False
possible = True

#A-C, B-D に岩が二つ並んでいる箇所があるなら不可能

#C>Dの場合B以上の位置で3マス以上の空白があれば
for i in range(a, max(c,d)):#+1):
    j = s[i]
    if j=='#':
        if (k==0) and ((a<i<c) or (b<i<d)):
            possible = False
            break
        k = 0
    if j=='.':
        k += 1
        if (k>=3) and (b<i<=d):
            swappable = True
    

if (c>d) and (not swappable):
    possible = False

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = list(map(int, input().split()))
a,b,c,d = a-1,b-1,c-1,d-1 #indexに合わせる
s = input()
k = 0
swappable = False
possible = True

#A-C, B-D に岩が二つ並んでいる箇所があるなら不可能

#C>Dの場合B以上の位置で3マス以上の空白があれば
for i in range(a, max(c,d)):#+1):
    j = s[i]
    if j=='#':
        if (k==0) and ((a<i<c) or (b<i<d)):
            possible = False
            break
        k = 0
    if j=='.':
        k += 1
        if (k>=3) and (b<i<d):
            swappable = True
    

if (c>d) and (not swappable):
    possible = False

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = list(map(int, input().split()))
a,b,c,d = a-1,b-1,c-1,d-1 #indexと合わせる
s = input()
k = 0
swappable = False
possible = True

#C>Dの場合B以上の位置で3マス以上の空白があれば
for i in range(a, max(c,d)):#+1):
    j = s[i]
    if j=='#':
        if (k==0) and ((a<i<c) or (b<i<d)):
            possible = False
            break
        k = 0
    if j=='.':
        k += 1
        if (k>=3) and (i>b):
            swappable = True
    

if (c>d) and (not swappable):
    possible = False

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = list(map(int, input().split()))
a,b,c,d = a-1,b-1,c-1,d-1 #indexと合わせる
s = input()
k = 0
swappable = False
possible = True

#C>Dの場合B以上の位置で3マス以上の空白があれば
for i in range(a, max(c,d)+1):
    j = s[i]
    if j=='#':
        if (k==0) and ((a<i<c) or (b<i<d)):
            possible = False
            break
        k = 0
    if j=='.':
        k += 1
        if (k>=3) and (i>b):
            swappable = True
    

if (c>d) and (not swappable):
    possible = False

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

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B, C, D = MAP()

S = input()

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

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

if S[B-1:D+1].count("...") >= 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B, C, D = MAP()

S = input()

if S[A:C+1].count("##") >= 1 or S[B:D+1].count("##") >= 1:
    print("No")
    exit()

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

if S[B:D+1].count("...") >= 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B, C, D = MAP()

S = input()

if S[A:C+1].count("##") >= 1 or S[B:D+1].count("##") >= 1:
    print("No")
    exit()

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

if S[A:D+1].count("...") >= 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, A, B, C, D = MAP()

S = input()

if S[A:].count("##") >= 1 or S[B:].count("##") >= 1:
    print("No")
    exit()

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

if S[A:D+1].count("...") >= 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

flag = True
for i in range(A, C):
    if S[i] == "#" and S[i + 1] == "#":
        flag = False
        break
else:
    for i in range(B, D):
        if S[i] == "#" and S[i + 1] == "#":
            flag = False
            break

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

Submission status: Wrong Answer

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

flag = True
for i in range(A, C):
    if S[i] == "#" and S[i + 1] == "#":
        flag = False
        break
else:
    for i in range(B, D):
        if S[i] == "#" and S[i + 1] == "#":
            flag = False
            break

if flag:
    if C < D:
        print("Yes")
    else:
        for i in range(B - 1, D):
            if S[i - 1] == "." and S[i] == "." and S[i + 1] == ".":
                print("Yes")
                break
        else:
            print("No")
else:
    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, D):
    if S[i] == "#" and S[i + 1] == "#":
        print("No")
        break
else:
    if C < D:
        print("Yes")
    else:
        for i in range(B - 1, D):
            if S[i - 1] == "." and S[i] == "." and S[i + 1] == ".":
                print("Yes")
                break
        else:
            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, D):
    if S[i] == "#" and S[i + 1] == "#":
        print("No")
else:
    if C < D:
        print("Yes")
    else:
        for i in range(B - 1, D):
            if S[i - 1] == "." and S[i] == "." and S[i + 1] == ".":
                print("Yes")
                break
        else:
            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, D):
    if S[i] == "#" and S[i + 1] == "#":
        print("No")
else:
    if C < D:
        print("Yes")
    else:
        for i in range(B + 1, D):
            if S[i - 1] == "." and S[i] == "." and S[i + 1] == ".":
                print("Yes")
                break
        else:
            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, N):
    if S[i] == "#" and S[i + 1] == "#":
        print("No")
else:
    if C < D:
        print("Yes")
    else:
        for i in range(B + 1, D - 1):
            if S[i - 1] == "." and S[i] == "." and S[i + 1] == ".":
                print("Yes")
                break
        else:
            print("No")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

res = 'Yes'

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

if res != 'No':
    if c < d:
        for i in range(b-1, d-1):
            if s[i] == s[i+1] == '#':
                res = 'No'
                break
    else:
        for i in range(b-1, d-1):
            if s[i] == s[i+1] == s[i+2] == '.':
                break
        else:
            res = 'No'

print(res)

Submission status: Wrong Answer

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

res = 'Yes'

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

if res != 'No':
    if c < d:
        for i in range(b-1, d-1):
            if s[i] == s[i+1] == '#':
                res = 'No'
                break
    else:
        for i in range(a-1, d-1):
            if s[i] == s[i+1] == s[i+2] == '.':
                break
        else:
            res = 'No'

print(res)

Submission status: Wrong Answer

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

res = 'Yes'

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

if res != 'No':
    if c < d:
        for i in range(b-1, d-1):
            if s[i] == s[i+1] == '#':
                res = 'No'
                break
    else:
        for i in range(a-1, c-2):
            if s[i] == s[i+1] == s[i+2] == '.':
                break
        else:
            res = 'No'

print(res)

Submission status: Wrong Answer

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

if D<C:
  triple = S[B-1:D+2].count("...")
  if triple ==0:
    ans="No"

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

Submission status: Wrong Answer

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

if D<C:
  triple = S[B-1:D].count("...")
  if triple ==0:
    ans="No"

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

Submission status: Wrong Answer

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

if D<C:
  triple = S[B-1:D].count("...")
  if triple ==0:
    ans="No"

double= S[A-1:].count("##")
if double > 0:
  ans="No"
  
print(ans)

Submission status: Wrong Answer

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

if D<C:
  triple = S[B:D+1].count("...")
  if triple ==0:
    ans="No"

double= S[A:].count("##")
if double > 0:
  ans="No"
  
print(ans)

Submission status: Wrong Answer

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

if D<C:
  triple = S[B:C+1].count("...")
  if triple ==0:
    ans="No"

double= S[A:].count("##")
if double > 0:
  ans="No"
  
print(ans)

Submission status: Wrong Answer

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

cant = False
if c>d:
        cant = True
        for i in range(max(0,b-2), min(d-2, n-3)):
                if s[i]==s[i+1]==s[i+2]=='.': cant = False

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

print("YNeos"[cant::2])

Submission status: Wrong Answer

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

cant = False
for i in range(b-1, d-1):
        if s[i]==s[i+1]=='#': cant = True

if c>d:
        cant = True
        for i in range(max(0,b-2), d-2):
                if s[i]==s[i+1]==s[i+2]=='.': cant = False
for i in range(a-1, c-1):
        if s[i]==s[i+1]=='#': cant = True

print("YNeos"[cant::2])

Submission status: Wrong Answer

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

cant = False
for i in range(b-1, d-1):
        if s[i]==s[i+1]=='#': cant = True

if c>d:
        cant = True
        for i in range(b-2, d-2):
                if s[i]==s[i+1]==s[i+2]=='.': cant = False
for i in range(a-1, c-1):
        if s[i]==s[i+1]=='#': cant = True

print("YNeos"[cant::2])

Submission status: Wrong Answer

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

cant = False
for i in range(b-1, d-1):
        if s[i]==s[i+1]=='#': cant = True

if c<d:
        for i in range(a-1, c-1):
                if s[i]==s[i+1]=='#': cant = True
else:
        cant = True
        for i in range(a-1, d-2):
                if s[i]==s[i+1]==s[i+2]=='.': cant = False
        for i in range(a-1, c-1):
                if s[i]==s[i+1]=='#': cant = True

print("YNeos"[cant::2])

Submission status: Wrong Answer

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

cant = False
for i in range(b-1, d-1):
        if s[i]==s[i+1]=='#': cant = True

if c<d:
        for i in range(a-1, c-1):
                if s[i]==s[i+1]=='#': cant = True
else:
        cant = True
        for i in range(a-1, d-1):
                if s[i]==s[i+1]==s[i+2]=='.': cant = False
        for i in range(d-1, c-1):
                if s[i]==s[i+1]=='#': cant = True

print("YNeos"[cant::2])

Submission status: Wrong Answer

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

cant = False
for i in range(b-1, d-1):
        if s[i]==s[i+1]=='#': cant = True

if c<d:
        for i in range(a-1, c-1):
                if s[i]==s[i+1]=='#': cant = True
else:
        cant = True
        for i in range(a-1, c-2):
                if s[i]==s[i+1]==s[i+2]=='.': cant = False

print("YNeos"[cant::2])

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
ans=True
#ゴールの手前の岩が二個以上連続で並ぶとき
#手前のゴールが岩に挟まれているとき
#ぬかせない状況(.が連続する箇所が2つ以下)のとき、Bのゴールの隣に岩がある
#ぬかせないときD<C　

#ぬかせるかどうかのフラグ
trace=False
count=0
flag=False
if D<C:
    for i in range(B-1,min(C,D)):
        if S[i]==".":
            if flag:
                count+=1
                if count>=3:
                    trace=True
                    break
            else:
                flag=True
                count=1
        else:
            flag=False
            count=0
#ゴールの手前の岩が二個以上並ぶかどうか
rock1=False
count=0
flag=False
for i in range(min(A,B)-1,max(C,D)):
    if S[i]=="#":
        if flag:
            count+=1
            if count>=2:
                rock1=True
                break
        else:
            flag=True
            count=1
    else:
        flag=False
        count=0
#手前のゴールが岩に挟まれているかどうか
rock2=False
m=min(C,D)
if S[m-2]=="#" and S[m]=="#":
    rock2=True
if C<D:
    if not rock1:
        ans=True
    else:
        ans=False
    if ans:
        print("Yes")
    else:
        print("No")
    exit()
if not trace:
    if D<C:
        ans=False
if rock1:
    ans=False
"""
if rock2:
    ans=False
"""
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
ans=True
#ゴールの手前の岩が二個以上連続で並ぶとき
#手前のゴールが岩に挟まれているとき
#ぬかせない状況(.が連続する箇所が2つ以下)のとき、Bのゴールの隣に岩がある
#ぬかせないときD<C　

#ぬかせるかどうかのフラグ
trace=False
count=0
flag=False
if D<C:
    for i in range(B-1,min(C,D)):
        if S[i]==".":
            if flag:
                count+=1
                if count>=3:
                    trace=True
                    break
            else:
                flag=True
                count=1
        else:
            flag=False
            count=0
#ゴールの手前の岩が二個以上並ぶかどうか
rock1=False
count=0
flag=False
for i in range(max(C,D)):
    if S[i]=="#":
        if flag:
            count+=1
            if count>=2:
                rock1=True
                break
        else:
            flag=True
            count=1
    else:
        flag=False
        count=0
#手前のゴールが岩に挟まれているかどうか
rock2=False
m=min(C,D)
if S[m-2]=="#" and S[m]=="#":
    rock2=True
if C<D:
    if not rock1:
        ans=True
    else:
        ans=False
    if ans:
        print("Yes")
    else:
        print("No")
    exit()
if not trace:
    if D<C:
        ans=False
if rock1:
    ans=False
"""
if rock2:
    ans=False
"""
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
ans=True
#ゴールの手前の岩が二個以上連続で並ぶとき
#手前のゴールが岩に挟まれているとき
#ぬかせない状況(.が連続する箇所が2つ以下)のとき、Bのゴールの隣に岩がある
#ぬかせないときD<C　

#ぬかせるかどうかのフラグ
trace=False
count=0
flag=False
if D<C:
    for i in range(B-1,min(C,D)):
        if S[i]==".":
            if flag:
                count+=1
                if count>=3:
                    trace=True
                    break
            else:
                flag=True
                count=1
        else:
            flag=False
            count=0
#ゴールの手前の岩が二個以上並ぶかどうか
rock1=False
count=0
flag=False
for i in range(max(C,D)):
    if S[i]=="#":
        if flag:
            count+=1
            if count>=2:
                rock1=True
                break
        else:
            flag=True
            count=1
    else:
        flag=False
        count=0
#手前のゴールが岩に挟まれているかどうか
rock2=False
m=min(C,D)
if S[m-2]=="#" and S[m]=="#":
    rock2=True
if C<D:
    if not rock1:
        ans=True
    else:
        ans=False
    if ans:
        print("Yes")
    else:
        print("No")
    exit()
if not trace:
    if D<C:
        ans=False
if rock1:
    ans=False
if rock2:
    ans=False
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
ans=True
#ゴールの手前の岩が二個以上連続で並ぶとき
#手前のゴールが岩に挟まれているとき
#ぬかせない状況(.が連続する箇所が2つ以下)のとき、Bのゴールの隣に岩がある
#ぬかせないときD<C　

#ぬかせるかどうかのフラグ
trace=False
count=0
flag=False
for i in range(min(C,D)):
    if S[i]==".":
        if flag:
            count+=1
            if count>=3:
                trace=True
                break
        else:
            flag=True
            count=1
    else:
        flag=False
        count=0
#ゴールの手前の岩が二個以上並ぶかどうか
rock1=False
count=0
flag=False
for i in range(B-1,max(C,D)):
    if S[i]=="#":
        if flag:
            count+=1
            if count>=2:
                rock1=True
                break
        else:
            flag=True
            count=1
    else:
        flag=False
        count=0
#手前のゴールが岩に挟まれているかどうか
rock2=False
m=min(C,D)
if S[m-2]=="#" and S[m]=="#":
    rock2=True

if not trace:
    if D<C:
        ans=False
if rock1:
    ans=False
if rock2:
    ans=False
if ans:
    print("Yes")
else:
    print("No")