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

c1=S[B-2:C].count('...')
c2=S[A-1:D].count('##')

if c2>=1:
    print('No')
    exit()
else:
    pass

if C>D and c1==0:
    print('No')
    exit()
else:
    pass


print('Yes')

Submission status: Wrong Answer

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

c1=S[B-2:C].count('...')
c2=S[A-1:D].count('##')

if c2>=1:
    print('No')
    exit()
else:
    pass

if C>D:
    if c1==0:
        print('No')
        exit()
    else:
        print('Yes')
        exit()

Submission status: Wrong Answer

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

c1=S[B-2:C-1].count('...')
c2=S[A-1:D].count('##')

if c2>=1:
    print('No')
    exit()
else:
    pass

if C>D and c1==0:
    print('No')
    exit()
else:
    print('Yes')
    exit()

Submission status: Wrong Answer

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

c1=S[B-2:C+1].count('...')
c2=S[A-1:D].count('##')

if c2>=1:
    print('No')
    exit()
else:
    pass

if C>D and c1==0:
    print('No')
    exit()
else:
    print('Yes')
    exit()

Submission status: Wrong Answer

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

c1=S[B-2:C].count('...')
c2=S[A-1:D].count('##')

if c2>=1:
    print('No')
    exit()
else:
    pass

if C>D and c1==0:
    print('No')
    exit()
else:
    print('Yes')
    exit()

Submission status: Wrong Answer

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

c1=S[B-2:D].count('...')
c2=S[A-1:D].count('##')

if c2>=1:
    print('No')
    exit()
else:
    pass

if C>D and c1==0:
    print('No')
    exit()
else:
    print('Yes')
    exit()

Submission status: Wrong Answer

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

c1=S[B:D].count('...')
c2=S[A:D].count('##')

if c2>=1:
    print('No')
    exit()
else:
    pass

if C>D and c1==0:
    print('No')
    exit()
else:
    print('Yes')
    exit()

Submission status: Wrong Answer

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

c1=S[B-1:D].count('...')
c2=S[A-1:D].count('##')

if c2>=1:
    print('No')
    exit()
else:
    pass

if C>D and c1==0:
    print('No')
    exit()
else:
    print('Yes')
    exit()

Submission status: Wrong Answer

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

c1=S[A-1:D].count('...')
c2=S[A-1:D].count('##')

if c2>=1:
    print('No')
    exit()
else:
    pass

if C>D and c1==0:
    print('No')
    exit()
else:
    print('Yes')
    exit()

Submission status: Wrong Answer

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

c1=S[A-1:D].count('...')
c2=S[A-1:D].count('##')

if c2>=1:
    print('No')
else:
    pass

if C>D and c1==0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

c1=S[A:D].count('...')
c2=S[A:D].count('##')

if c2>=1:
    print('No')
else:
    pass

if C>D and c1==0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, a, b, c, d = rm()
s = rr()
three = '...' in s[max(0, b-2):min(n-1, d+2)]
sha = '##'in s[b-1:d]
sha1 = '##' in s[a-1:c]
if c < d:
    if sha or sha1:
        print('No')
    else:
        print('Yes')
elif not sha and three and not sha1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7


n, a, b, c, d = rm()
s = rr()
three = '...' in s[b-1:]
sha = '##'in s[min(b-1, a-1):max(d, c)]
if c < d:
    if sha:
        print('No')
    else:
        print('Yes')
elif not sha and three:
    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:
    for i in range(b,d):
        if s[i:i+2]=='##':
            print('No')
            exit()
    for i in range(a,c):
        if s[i:i+2]=='##':
            print('No')
            exit()
    print('Yes')
else:
    for i in range(b,d):
        if s[i:i+2]=='##':
            print('No')
            exit()
    for i in range(a,c):
        if s[i:i+2]=='##':
            print('No')
            exit()
    for i in range(b,d):
        if s[i:i+3]=='...':
            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:
    rock_flag=False
    ans='Yes'
    for i in range(a,d):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False

else:
    ans='Yes'
    cnt=0
    cd_flag=False
    for i in range(b,d):
        if cnt>=3:
            cd_flag=True
            break
        if s[i]=='.':
            cnt+=1
        else:
            cnt=0
    if not cd_flag:
        ans='No'

    rock_flag=False
    for i in range(a,d):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False
print(ans)

Submission status: Wrong Answer

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

if c<d:
    rock_flag=False
    ans='Yes'
    for i in range(a,d):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False

else:
    ans='Yes'
    cnt=0
    cd_flag=False
    for i in range(b-1,d+1):
        if cnt>=3:
            cd_flag=True
            break
        if s[i]=='.':
            cnt+=1
        else:
            cnt=0
    if not cd_flag:
        ans='No'

    rock_flag=False
    for i in range(a,d):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False
print(ans)

Submission status: Wrong Answer

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

if c<d:
    rock_flag=False
    ans='Yes'
    for i in range(b-1,d):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False

    rock_flag=False
    for i in range(a-1,c):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False
else:
    rock_flag=False
    ans='Yes'
    for i in range(b-1,d):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False

    rock_flag=False
    for i in range(a-1,c):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False

    cnt=0
    cd_flag=False
    for i in range(b-1,d):
        if cnt>=3:
            cd_flag=True
            break
        if s[i]=='.':
            cnt+=1
        else:
            cnt=0
    if not cd_flag:
        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:
    rock_flag=False
    ans='Yes'
    for i in range(b-1,d):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False

    rock_flag=False
    for i in range(a-1,c):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False
else:
    rock_flag=False
    ans='Yes'
    for i in range(b-1,d):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False

    rock_flag=False
    for i in range(a-1,c):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False

    cnt=0
    cd_flag=False
    for i in range(b-1,c):
        if cnt>=3:
            cd_flag=True
            break
        if s[i]=='.':
            cnt+=1
        else:
            cnt=0
    if not cd_flag:
        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:
    rock_flag=False
    ans='Yes'
    for i in range(b-1,d):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False

    for i in range(a-1,c):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False
else:
    rock_flag=False
    ans='Yes'
    for i in range(b-1,d):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False

    for i in range(a-1,c):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False

    cnt=0
    cd_flag=False
    for i in range(b-1,c):
        if cnt>=3:
            cd_flag=True
            break
        if s[i]=='.':
            cnt+=1
        else:
            cnt=0
    if not cd_flag:
        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:
    rock_flag=False
    ans='Yes'
    for i in range(b-1,d):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False

    for i in range(a-1,c):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False
else:
    rock_flag=False
    ans='Yes'
    for i in range(b-1,d):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False

    for i in range(a-1,c):
        if s[i]=='#':
            if rock_flag:
                ans='No'
                break
            else:
                rock_flag=True
        else:
            rock_flag=False

    cnt=0
    cd_flag=False
    for i in range(b-1,c):
        if cnt>=3:
            cd_flag==True
            break
        if s[i]=='.':
            cnt+=1
        else:
            cnt=0
    if not cd_flag:
        ans='No'

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
if s[b-1: d].count("##") or (d < c and s[b-1: d].count("...") == 0):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
ss = s[min(a-1, b-1): max(c, d)]
if ss.count("##") == 0 and (d < c and ss.count("...") == 0):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if d>c:
  #B→Aの順番でチェック
  for i in range(b-1,d-3):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()

  for i in range(a-1,c-3):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()
  #問題なければ終了
  print("Yes")

else:
  flag=False
  #BからDの間に3マス連続で空きがあるかチェック（AがBを抜かせるかどうか）
  for i in range(b-2, d-2):
    if "".join(s[i:i+3])=="...":
      flag=True
      break
  #抜かせる
  if flag:
    for i in range(a-1,c-3):
      if "".join(s[i:i+2])=="##":
        print("No")
        exit()
    print("Yes")
  #抜かせない
  else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if d>c:
  #B→Aの順番でチェック
  for i in range(b-1,d-3):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()

  for i in range(a-1,c-3):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()
  #問題なければ終了
  print("Yes")

else:
  flag=False
  #BからDの間に3マス連続で空きがあるかチェック（AがBを抜かせるかどうか）
  for i in range(b-2, d-3):
    if "".join(s[i:i+3])=="...":
      flag=True
      break
  #抜かせる
  if flag:
    for i in range(a-1,c-3):
      if "".join(s[i:i+2])=="##":
        print("No")
        exit()
    print("Yes")
  #抜かせない
  else:
    print("No")
    exit()

Submission status: Wrong Answer

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

if d>c:
  #B→Aの順番でチェック
  for i in range(b-1,d-3):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()

  for i in range(a-1,c-3):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()
  #問題なければ終了
  print("Yes")

else:
  flag=False
  #BからDの間に3マス連続で空きがあるかチェック（AがBを抜かせるかどうか）
  for i in range(b-2, d-2):
    if "".join(s[i:i+3])=="...":
      flag=True
      break
  #抜かせる
  if flag:
    for i in range(a-1,c-3):
      if "".join(s[i:i+2])=="##":
        print("No")
        exit()
    print("Yes")
  #抜かせない
  else:
    print("No")
    exit()

Submission status: Wrong Answer

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

if d>c:
  #B→Aの順番でチェック
  for i in range(b-1,d-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()

  for i in range(a-1,c-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()
  #問題なければ終了
  print("Yes")

else:
  flag=False
  #BからDの間に3マス連続で空きがあるかチェック（AがBを抜かせるかどうか）
  for i in range(b-1, d-2):
    if "".join(s[i:i+3])=="...":
      flag=True
      break
  #抜かせる
  if flag:
    for i in range(a-1,c-1):
      if "".join(s[i:i+2])=="##":
        print("No")
        exit()
    print("Yes")
  #抜かせない
  else:
    print("No")
    exit()

Submission status: Wrong Answer

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

if d>c:
  #B→Aの順番でチェック
  for i in range(b-1,d-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()

  for i in range(a-1,c-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()
  #問題なければ終了
  print("Yes")

else:
  flag=False
  #BからDの間に3マス連続で空きがあるかチェック（AがBを抜かせるかどうか）
  for i in range(b-2, d-2):
    if "".join(s[i:i+3])=="...":
      flag=True
      break
  #抜かせる
  if flag:
    for i in range(a-1,c-1):
      if "".join(s[i:i+2])=="##":
        print("No")
        exit()
    print("Yes")
  #抜かせない
  else:
    print("No")
    exit()

Submission status: Wrong Answer

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

if d>c:
  #B→Aの順番でチェック
  for i in range(b-1,d-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()

  for i in range(a-1,c-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()
  #問題なければ終了
  print("Yes")

else:
  flag=False
  #BからDの間に3マス連続で空きがあるかチェック（AがBを抜かせるかどうか）
  for i in range(b-2, d-2):
    if "".join(s[i:i+3])=="...":
      flag=True
      break
  #抜かせる
  if flag:
    for i in range(c-1):
      if "".join(s[i:i+2])=="##":
        print("No")
        exit()
    print("Yes")
  #抜かせない
  else:
    print("No")
    exit()

Submission status: Wrong Answer

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

if d>c:
  #B→Aの順番でチェック
  for i in range(b-1,d-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()

  for i in range(a-1,c-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()
  #問題なければ終了
  print("Yes")

else:
  flag=False
  #BからDの間に3マス連続で空きがあるかチェック（AがBを抜かせるかどうか）
  for i in range(b-2, d-2):
    if "".join(s[i:i+3])=="...":
      flag=True
      break
  #抜かせる
  if flag:
    for i in range(n-1):
      if "".join(s[i:i+2])=="##":
        print("No")
        exit()
    print("Yes")
  #抜かせない
  else:
    print("No")
    exit()

Submission status: Wrong Answer

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

if d>c:
  #B→Aの順番でチェック
  for i in range(b-1,d-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()

  for i in range(a-1,c-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()
  #問題なければ終了
  print("Yes")

else:
  flag=False
  #BからDの間に3マス連続で空きがあるかチェック（AがBを抜かせるかどうか）
  for i in range(b, d-4):
    if "".join(s[i:i+3])=="...":
      flag=True
      break
  #抜かせる
  if flag:
    for i in range(n):
      if "".join(s[i:i+2])=="##":
        print("No")
        exit()
    print("Yes")
  #抜かせない
  else:
    print("No")
    exit()

Submission status: Wrong Answer

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

if d>c:
  #B→Aの順番でチェック
  for i in range(b-1,d-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()

  for i in range(a-1,c-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()
  #問題なければ終了
  print("Yes")

else:
  flag=False
  #BからDの間に3マス連続で空きがあるかチェック（AがBを抜かせるかどうか）
  for i in range(b-2, d-2):
    if "".join(s[i:i+3])=="...":
      flag=True
      break
  #抜かせる
  if flag:
    for i in range(n):
      if "".join(s[i:i+2])=="##":
        print("No")
        exit()
    print("Yes")
  #抜かせない
  else:
    print("No")
    exit()

Submission status: Wrong Answer

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

if d>c:
  #B→Aの順番でチェック
  for i in range(b-1,d-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()

  for i in range(a-1,c-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()
  #問題なければ終了
  print("Yes")

else:
  flag=False
  #BからDの間に3マス連続で空きがあるかチェック（AがBを抜かせるかどうか）
  for i in range(b-1, d-1):
    if "".join(s[i:i+3])=="...":
      flag=True
      break
  #Bの両隣に石があるときも抜かせない
  if s[b-2]=="#" or s[b]=="#":
    flag=False
  #抜かせる
  if flag:
    for i in range(n):
      if "".join(s[i:i+2])=="##":
        print("No")
        exit()
    print("Yes")
  #抜かせない
  else:
    print("No")
    exit()

Submission status: Wrong Answer

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

if d>c:
  #B→Aの順番でチェック
  for i in range(b-1,d-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()

  for i in range(a-1,c-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()
  #問題なければ終了
  print("Yes")

else:
  flag=False
  #BからDの間に3マス連続で空きがあるかチェック（AがBを抜かせるかどうか）
  for i in range(b-1, d-1):
    if "".join(s[i:i+3])=="...":
      break
  #Bの両隣に石があるときも抜かせない
  if s[b-2]!="#" and s[b]!="#":
    flag=True
  #抜かせる
  if flag:
    for i in range(n):
      if "".join(s[i:i+2])=="##":
        print("No")
        exit()
    print("Yes")
  #抜かせない
  else:
    print("No")
    exit()

Submission status: Wrong Answer

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

if d>c:
  for i in range(b-1,d-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()
  #OKだったらB(石)を配置
  s[d-1]="#"
  for i in range(a-1,c-1):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()
  #OKだったら終了
  print("Yes")

else:
  flag=False
  #BからDの間に3マス連続で空きがあるかチェック（AがBを抜かせるかどうか）
  for i in range(b-1, d-1):
    if "".join(s[i:i+3])=="...":
      flag=True
      break
  #抜かせる
  if flag:
    for i in range(n):
      if "".join(s[i:i+2])=="##":
        print("No")
        exit()
    print("Yes")
  #抜かせない
  else:
    print("No")
    exit()

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,A,B,C,D = I()
maze = list(s())
if maze[0] == maze[1] == '#':
    print('No')
    exit()
Flag = 0
for i in range(N-2):
    if maze[i+1] == maze[i+2] == '#' and A-1 <= i+1 <= max(C,D)-1:
        print('No')
        exit()
    if maze[i] == maze[i+1] == maze[i+2] == '.' and B-1 <= i+1 <= D-1:
        Flag = 1
        break
if C > D:
    if Flag == 0:
        print('No')
    else:
        print('Yes')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,A,B,C,D = I()
maze = list(s())
if maze[0] == maze[1] == '#':
    print('No')
    exit()
Flag = 0
for i in range(N-2):
    if maze[i+1] == maze[i+2] == '#' and A-1 <= i+1 <= max(C,D)-1:
        print('No')
        exit()
    if maze[i] == maze[i+1] == maze[i+2] == '.' and B-1 <= i+1 <= C-1:
        Flag = 1
        break
if C > D:
    if Flag == 0:
        print('No')
    else:
        print('Yes')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
A_start = True
if C < D:
  space1 = S[A-1:D]
  if ('##' in space1) != True:
    print('Yes')
  else:
    print('No')
else:
  space1 = S[A-1:C]
  space2 = S[B-1:D+1]
  if ('##' in space1) != True and ('...' in space2) == True:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
A_start = True
if C < D:
  space1 = S[A:D+1]
  if ('##' in space1) != True:
    print('Yes')
  else:
    print('No')
else:
  space1 = S[A:C+1]
  space2 = S[B-1:D+1]
  if ('##' in space1) != True and ('...' in space2) == True:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
A_start = True
if C < D:
  space1 = S[A-1:D+1]
  if ('##' in space1) != True:
    print('Yes')
  else:
    print('No')
else:
  space1 = S[A-1:D+1]
  space2 = S[B-1:D+1]
  if ('##' in space1) != True and ('...' in space2) == True:
    print('Yes')
  else:
    print('No')