Problem:


Score : 400 points

Problem Statement

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

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

You can repeat the following operation any number of times:

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

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

Determine whether this is possible.

Constraints

4 \leq N \leq 200\ 000

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

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

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

A, B, C and D are all different.

A < B

A < C

B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

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

Sample Input 1

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

Sample Output 1

Yes

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

A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB

Sample Input 2

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

Sample Output 2

No

Sample Input 3

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

Sample Output 3

Yes



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


Sample output:
Yes

Submission status: Wrong Answer

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

"""
基本的にはシャープが2連続するとだめ
ただし，片方が間に必ず入っている場合は，...が三連続するところがないとダメ
"""

if A<B and C>D:
    for i in range(B,D-2):
        if S[i:i+3] == [".", ".", "."]:
            print("Yes")
            exit()
    print("No")
    exit()
elif A>B and C<D:
    for i in range(A,C-2):
        if S[i:i+3] == [".", ".", "."]:
            print("Yes")
            exit()
    print("No")
    exit()
else:
    for i in range(min(A,B), max(C,D)-1):
        if S[i] == S[i+1] == "#":
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

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

# A < B < D, A < B < C
# A < D, B < C の間に # が2マス連続にあったらNo
# さらに D < C なら すぬけくんとふぬけくんが入れ替わる必要がある。
# すなわち3マス連続...が続いている必要がある(#が2マス連続ないことも注意)

if C < D:
    left = A
    right = D
else:
    idx = []
    for i in range(len(S) - 2):
        if S[i] == '.' and S[i + 1] == '.' and S[i + 2] == '.':
            idx.append(i)
    if not idx:
        print('No')
        exit()
    if max(idx) < A:
        left = max(idx)
    else:
        left = A
    if min(idx) + 2 > C:
        right = min(idx)
    else:
        right = C

T = S[left - 1:right + 1]
# print('T', T)
for i in range(len(T) - 1):
    if T[i] == '#' and T[i + 1] == '#':
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

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

# A < B < D, A < B < C
# A < D, B < C の間に # が2マス連続にあったらNo
# さらに D < C なら すぬけくんとふぬけくんが入れ替わる必要がある。
# すなわち3マス連続...が続いている必要がある(#が2マス連続ないことも注意)

if C < D:
    T = S[A - 1:D + 1]
    # print('T', T)
    for i in range(len(T) - 1):
        if T[i] == '#' and T[i + 1] == '#':
            print('No')
            exit()
else:
    j = -1
    for i in range(len(S) - 2):
        if S[i] == '.' and S[i + 1] == '.' and S[i + 2] == '.':
            j = i
            break
    else:
        print('No')
        exit()
    if j < A:
        T = S[j - 1:C + 1]
    elif A <= j < C:
        T = S[A - 1:C + 1]
    else:
        T = S[A - 1:j + 1]
    # print('T', T)
    for i in range(len(T) - 1):
        if T[i] == '#' and T[i + 1] == '#':
            print('No')
            exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
# A - Kenken Race

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

should_change = int(C>D)
can_change = 0
space = 1
ans = 'Yes'

for i in range(A,C):
    if S[i]=='.':
        space += 1
        if B<=i<=D and space==3:
            can_change = 1
    else:
        if space==0:
            ans = 'No'
            break
        space = 0

if can_change<should_change:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
# A - Kenken Race

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

should_change = int(C>D)
can_change = 0
space = 1
ans = 'Yes'

for i in range(A,C-1):
    if S[i]=='.':
        space += 1
        if B<=i<=D and space==3:
            can_change = 1
    else:
        if space==0:
            ans = 'No'
            break
        space = 0

if can_change<should_change:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
N,A,B,C,D=map(int,input().split())
S=input()
if C<D:
  for i in range(A-1,D-1):
    if S[i]=="#" and S[i+1]=="#":
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()
else:
  for i in range(A-1,C-1):
    if S[i]=="#" and S[i+1]=="#":
      print("No")
      sys.exit()  
  for i in range(B-1,D-1):
    if S[i]=="." and S[i+1]=="." and S[i+2]==".":
      print("Yes")
      sys.exit()
    if i==D-2:
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N,A,B,C,D=map(int,input().split())
S=input()
if C<D:
  for i in range(D-1):
    if S[i]=="#" and S[i+1]=="#":
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()
else:
  for i in range(C-1):
    if S[i]=="#" and S[i+1]=="#":
      print("No")
      sys.exit()  
  for i in range(B-1,D-1):
    if S[i]=="." and S[i+1]=="." and S[i+2]==".":
      print("Yes")
      sys.exit()
    if i==D-2:
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N,A,B,C,D=map(int,input().split())
S=input()
if C<D:
  for i in range(D-1):
    if S[i]=="#" and S[i+1]=="#":
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()
else:
  for i in range(C-1):
    if S[i]=="#" and S[i+1]=="#":
      print("No")
      sys.exit()  
  for i in range(D-1):
    if S[i]=="." and S[i+1]=="." and S[i+2]==".":
      print("Yes")
      sys.exit()
    if i==D-2:
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N,A,B,C,D=map(int,input().split())
S=input()
if C<D:
  for i in range(D-1):
    if S[i]=="#" and S[i+1]=="#":
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()
else:
  for i in range(C-1):
    if S[i]=="#" and S[i+1]=="#":
      print("No")
      sys.exit()  
  for i in range(D-1):
    if S[i]=="." and S[i+1]=="." and S[i+2]==".":
      print("Yes")
      sys.exit()
    if i==D-3:
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
N,A,B,C,D=map(int,input().split())
S=input()
if C<D:
  for i in range(D-1):
    if S[i]=="#" and S[i+1]=="#":
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()
else:
  for i in range(C-1):
    if S[i]=="#" and S[i+1]=="#":
      print("No")
      sys.exit()  
  for i in range(D-2):
    if S[i]=="." and S[i+1]=="." and S[i+2]==".":
      print("Yes")
      sys.exit()
    if i==D-3:
      print("No")
      sys.exit()
  print("Yes")
  sys.exit()

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 "..." not in s[min(0,b-2):d+1]:print("No");exit()
  if "##"in s[a-1:c] or"##"in s[b-1:d]: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[a-1:c] or"##"in s[b-1:d]:print("No")
  else:print("Yes")
else:
  if "..." not in s[b-1:d]:print("No");exit()
  if "##"in s[a-1:c] or"##"in s[b-1:d]: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[a-1:c] or"##"in s[b-1:d]:print("No")
  else:print("Yes")
else:
  if "..." not in s[b-1:d]:print("No");exit()
  if "##"in s[a-1:max(c,d)]:print("No")
  else:print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
if S.count("##", A, D):
    print("No")
elif C < D:
    print("Yes")
elif S.count("...", B - 1, D + 2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
if S.count("##"):
    print("No")
elif C < D:
    print("Yes")
elif S.count("...", B - 1, D + 2):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

s = A
f = B
flag = True
if C < D:
    if '##' in S[A-1:C]:
        flag = False
    if '##' in S[B-1:D]:
        flag = False

else:
    if S[D - 2] == '#':
        if '...' not in S[:D]:
            flag = False
    if '##' in S[A-1:C]:
        flag = False
    if '##' in S[B-1:D]:
        flag = False
ans = 'Yes' if flag else 'No'
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
S = input()
if c < d:
    if "##" in S[a-1:d-1]:
        print("No")
    else:
        print("Yes")
else:
    f = S[b-2:d-1].find("...")
    if f != -1 and f < (d-1) and f+1 < (c-1) and ("##" not in S[a-1:d-1]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
S = input()
if c < d:
    if "##" in S[a:d-3]:
        print("No")
    else:
        print("Yes")
else:
    f = S[b-2:].find("...")
    if f != -1 and f < (d-1) and f+1 < (c-1) and ("##" not in S[a:d-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[a:d-3]:
        print("No")
    else:
        print("Yes")
else:
    f = S[b-2:].find("...")
    if f != -1 and f < (d-1) and f+1 < (a-1) and ("##" not in S[a:d-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[a:d-3]:
        print("No")
    else:
        print("Yes")
else:
    f = S[b-2:].find("...")
    if f != -1 and f < (d-1) and ("##" not in S[a:d-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[a:d-3]:
        print("No")
    else:
        print("Yes")
else:
    f = S[b-2:].find("...")
    if f != -1 and f != (d-1) and ("##" not in S[a:d-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[(a-1):(d-2)]:
        print("No")
    else:
        print("Yes")
else:
    if ("..." in S[(b-2):]) and "##" not in S[(a-1):(d-2)]:
        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):]:
        print("No")
    else:
        print("Yes")
else:
    if "..." in S[(b-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-1:d]:
    print('No')
  else:
    print('Yes')
else:
  if '...' in s[b-1:d] or s[b-2:b+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-1:d]:
    print('No')
  else:
    print('Yes')
else:
  if '...' in s[b-1:d] or s[b-1:b+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-1:d]:
    print('No')
  else:
    print('Yes')
else:
  if '...' in s[b-1:d]:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,a,b,c,d=mp()
s=input()
if s[a-1]=="#" or s[b-1]=="#" or s[c-1]=="#" or s[d-1]=="#":
    print("No")
    exit()
for i in range(min(a,b)-1,max(c,d)):
    if s[i]=="#" and s[i+1]=="#":
        print("No")
        exit()
if d<c:
    ch=False
    for i in range(b-1,d-1):
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            ch=True
    if ch:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,a,b,c,d=mp()
s=input()
if s[a-1]=="#" or s[b-1]=="#" or s[c-1]=="#" or s[d-1]=="#":
    print("No")
    exit()
for i in range(min(a,b)-1,max(c,d)-1):
    if s[i]=="#" and s[i+1]=="#":
        print("No")
        exit()
if d<c:
    ch=False
    for i in range(b-1,d-1):
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            ch=True
    if ch:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n,a,b,c,d=mp()
s=input()
if s[a-1]=="#" or s[b-1]=="#" or s[c-1]=="#" or s[d-1]=="#":
    print("No")
    exit()
for i in range(min(a,b)-1,max(c,d)-1):
    if s[i]=="#" and s[i+1]=="#":
        print("No")
        exit()
if d<c:
    ch=False
    for i in range(b-1,d-2):
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            ch=True
    if ch:
        print("Yes")
        exit()
    else:
        print("No")
        exit()
else:
    print("Yes")

Submission status: Wrong Answer

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

if C < D:
    print('Yes' if '##' not in S else 'No')
else:
    print('Yes' if '...' in S[B-1:D] else 'No')

Submission status: Wrong Answer

Solution code:
import numpy as np

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

a = np.zeros(N+1)
b = np.zeros(N+1)
a[A-1] = 1
b[B-1] = 1

for i in range(N-1):
    if a[i] == 1:
        if S[i+1] == '.':
            a[i+1] = 1
        if S[i+2] == '.':
            a[i+2] = 1
    if b[i] == 1:
        if S[i+1] == '.':
            b[i+1] = 1
        if S[i+2] == '.':
            b[i+2] = 1
if C < D:
    # B
    print('Yes' if a[C-1] and b[D-1] else 'No')
else:
    print('Yes' if a[C-1] and b[D-1] and '...' in S else 'No')

Submission status: Wrong Answer

Solution code:
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,a,b,c,d = map(int, stdin.readline().rstrip().split())
#numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
#zeros = [[0] * w for i in range(h)]
s = str(stdin.readline().rstrip())

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

Submission status: Wrong Answer

Solution code:
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,a,b,c,d = map(int, stdin.readline().rstrip().split())
#numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
#zeros = [[0] * w for i in range(h)]
s = str(stdin.readline().rstrip())

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

Submission status: Wrong Answer

Solution code:
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,a,b,c,d = map(int, stdin.readline().rstrip().split())
#numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
#zeros = [[0] * w for i in range(h)]
s = str(stdin.readline().rstrip())

for i in range(min(a,b),max(c,d)-1):
    if s[i-1] == s[i] == "#":
        print("No")
        exit()

if c>d:
    for i in range(b,d-2):
        if s[i-1] == s[i] == s[i+1] == ".":
            print("Yes")
            exit()
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

#n = int(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
n,a,b,c,d = map(int, stdin.readline().rstrip().split())
#numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
#zeros = [[0] * w for i in range(h)]
s = str(stdin.readline().rstrip())

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

for i in range(b,d):
    if s[i-1] == s[i] == "#":
        print("No")
        exit()

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

Submission status: Wrong Answer

Solution code:
n,ss,fs,sg,fg=map(int,input().split())
s=input()
sway,fway=set([ss-1]),set([fs-1])
for i in range(ss-1,sg):
    if s[i]!="#"and (i-1 in sway or i-2 in sway):
        sway.add(i)
for i in range(fs-1,fg):
    if s[i]!="#"and (i-1 in fway or i-2 in fway):
        fway.add(i)
if sg<fg:
    if sg-1 in sway and fg-1 in fway:print("Yes")
    else:print("No")
else:
    if not(sg-1 in sway and fg-1 in fway):print("No");exit()
    for f in fway:
        for i in range(-1,2):
            if f+i not in fway:break
        else:print("Yes");exit()
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int, input().split())
a-=1
b-=1
c-=1
d-=1
s = input()
s+='X'
ch=1
v=[]
st=[]
if s[0]=='#':
    v.append((0,0))
for i in range(1,n+1):
    if s[i]==s[i-1]:
        ch+=1
    else:
        v.append((ch,i-ch))
        ch=1
judge=[]
for i in range(len(v)):
    if i%2==1:
        x,y=v[i]
        if x>=2 and ((a < y and y < c) or (b < y and y < d)):
            print('No')
            exit()
    else:
        x,y=v[i]
        if x>=3:
            judge.append(y)
check=1
if (a<b and d<c) or (b<a and c<d):
    check = 0
    while judge:
        t=judge.pop()
        if t>a and t>b and t<c and t<d:
            check = 1
if check == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int, input().split())
a-=1
b-=1
c-=1
d-=1
s = input()
s+='X'
ch=1
v=[]
st=[]
if s[0]=='#':
    v.append((0,0))
for i in range(1,n+1):
    if s[i]==s[i-1]:
        ch+=1
    else:
        v.append((ch,i-ch))
        ch=1
judge=[]
for i in range(len(v)):
    if i%2==1:
        x,y=v[i]
        if x>=2 and ((a < y and y < c) or (b < y and y < d)):
            print('No')
            exit()
    else:
        x,y=v[i]
        if x>=3:
            judge.append(y)
check=1
if (a<b and d<c) or (b<a and c<d):
    check = 0
    while judge:
        t=judge.pop()
        if t>a and t>b:
            check = 1
if check == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int, input().split())
s = input()
s+='X'
ch=1
v=[]
st=[]
if s[0]=='#':
    v.append((0,0))
for i in range(1,n+1):
    if s[i]==s[i-1]:
        ch+=1
    else:
        v.append((ch,i-ch))
        ch=1
judge=[]
for i in range(len(v)):
    if i%2==1:
        x,y=v[i]
        if x>=2 and ((a < y and y < c) or (b < y and y < d)):
            print('No')
            exit()
    else:
        x,y=v[i]
        if x>=3:
            judge.append(y)
check=1
if (a<b and d<c) or (b<a and c<d):
    check = 0
    while judge:
        t=judge.pop()
        if t>a and t>b:
            check = 1
if check == 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 '##' not in S[A:D - 1]:
        print('Yes')
    else:
        print('No')
else:
    if '...' in S[B - 2:D] and '##' not in S[A:C - 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 '##' not in S[A:D - 1]:
        print('Yes')
    else:
        print('No')
else:
    if '...' in S[B - 2:D - 1] and '##' not in S[A:C - 1]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
cont_cnt = 1
max_block_cnt = 1
has_enough_space_for_flip = False
for i in range(A - 1, max(C, D) - 1):
    if S[i]  != S[i + 1]:
        if S[i] == '#':
            max_block_cnt = max(max_block_cnt, cont_cnt)
        cont_cnt = 1
    elif S[i] == '#':
        cont_cnt += 1
    elif B <= i < D - 1:
        cont_cnt += 1
        if cont_cnt >= 3:
            has_enough_space_for_flip = True
if C < D:
    if max_block_cnt <= 1:
        print('Yes')
    else:
        print('No')
else:
    if max_block_cnt <= 1 and has_enough_space_for_flip:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
cont_cnt = 1
max_block_cnt = 1
has_enough_space_for_flip = False
for i in range(A - 1, max(C, D) - 1):
    if S[i] != S[i + 1]:
        if S[i] == '#':
            max_block_cnt = max(max_block_cnt, cont_cnt)
        cont_cnt = 1
    else:
        cont_cnt += 1
        if S[i] == '.' and cont_cnt >= 3 and B - 1 <= i < D - 1:
            has_enough_space_for_flip = True
if C < D:
    if max_block_cnt <= 1:
        print('Yes')
    else:
        print('No')
else:
    if max_block_cnt <= 1 and has_enough_space_for_flip:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
cont_cnt = 1
max_block_cnt = 1
has_enough_space_for_flip = False
for i in range(A - 1, max(C, D) - 1):
    if S[i] != S[i + 1]:
        if S[i] == '#':
            max_block_cnt = max(max_block_cnt, cont_cnt)
        cont_cnt = 1
    else:
        cont_cnt += 1
        if S[i] == '.' and cont_cnt >= 3 and i < D - 1:
            has_enough_space_for_flip = True
if C < D:
    if max_block_cnt <= 1:
        print('Yes')
    else:
        print('No')
else:
    if max_block_cnt <= 1 and has_enough_space_for_flip:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
cont_cnt = 1
max_block_cnt = 1
has_enough_space_for_flip = False
for i in range(A - 1, max(C, D) - 1):
    if S[i] != S[i + 1]:
        if S[i] == '#':
            max_block_cnt = max(max_block_cnt, cont_cnt)
        cont_cnt = 1
    else:
        cont_cnt += 1
        if S[i] == '.' and cont_cnt >= 3:
            has_enough_space_for_flip = True

if C < D:
    if max_block_cnt <= 1:
        print('Yes')
    else:
        print('No')
else:
    if max_block_cnt <= 1 and has_enough_space_for_flip:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
cont_cnt = 1
max_block_cnt = 1
has_enough_space_for_flip = False
for i in range(A - 1, max(C, D) - 1):
    if S[i] == '.' and cont_cnt >= 3:
        has_enough_space_for_flip = True
    if S[i] != S[i + 1]:
        if S[i] == '#':
            max_block_cnt = max(max_block_cnt, cont_cnt)
        cont_cnt = 1
    else:
        cont_cnt += 1

if C < D:
    if max_block_cnt <= 1:
        print('Yes')
    else:
        print('No')
else:
    if max_block_cnt <= 1 and has_enough_space_for_flip:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
max_cont_cnt = {'.': 1, '#': 1}
cont_cnt = 1
for i in range(A - 1, max(C, D) - 1):
    if S[i] != S[i + 1]:
        max_cont_cnt[S[i]] = max(max_cont_cnt[S[i]], cont_cnt)
        cont_cnt = 1
    else:
        cont_cnt += 1

if C < D:
    if max_cont_cnt['#'] <= 1:
        print('Yes')
    else:
        print('No')
else:
    if max_cont_cnt['#'] <= 1 and max_cont_cnt['.'] >= 3:
        print('Yes')
    else:
        print('No')