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())
A,B,C,D=A-1,B-1,C-1,D-1
S=input()

Aleft=A
Aright=min(S.find("##",A,-1) if S.find("##",A,-1)>=0 else len(S)-1,C)
Bleft=B
Bright=min(S.find("##",B,-1) if S.find("##",B,-1)>=0 else len(S)-1,D)

ans=True
if C<Aleft or Aright<C:
  ans=False
if D<Bleft or Bright<D:
  ans=False
  
if (A-B)*(C-D)<0:
  commonL=max(Aleft,Bleft)
  commonR=min(Aright,Bright)
  if commonR<commonL:
    ans=False
  elif "..." not in S[commonL:commonR+1]:
    ans=False

print(("No","Yes")[ans])

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

Aleft=A
Aright=S.find("##",A,-1) if S.find("##",A,-1)>=0 else C
Bleft=B
Bright=S.find("##",B,-1) if S.find("##",B,-1)>=0 else D

ans=True
if C<Aleft or Aright<C:
  ans=False
if D<Bleft or Bright<D:
  ans=False
  
if (A-B)*(C-D)<0:
  commonL=max(Aleft,Bleft)
  commonR=min(Aright,Bright)
  if commonR<commonL:
    ans=False
  elif "..." not in S[commonL:commonR+1]:
    ans=False

print(("No","Yes")[ans])

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

Aleft=max(S[:A].rfind("##"),0)
Aright=S.find("##",A,-1) if S.find("##",A,-1)>=0 else len(S)-1

Bleft=max(S[:B].rfind("##"),0)
Bright=S.find("##",B,-1) if S.find("##",B,-1)>=0 else len(S)-1

ans=True
if C<Aleft or Aright<C:
  ans=False
if D<Bleft or Bright<D:
  ans=False
  
if (A-B)*(C-D)<0:
  commonL=max(Aleft,Bleft)
  commonR=min(Aright,Bright)
  if commonR<commonL:
    ans=False
  elif "..." not in S[commonL:commonR+1]:
    ans=False

print(("No","Yes")[ans])

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

Aleft=max(S[:A].rfind("##"),0)
Aright=S.find("##",A,-1) if S.find("##",A,-1)>=0 else len(S)-1

Bleft=max(S[:B].rfind("##"),0)
Bright=S.find("##",B,-1) if S.find("##",B,-1)>=0 else len(S)-1

ans=True
if C<Aleft or Aright<C:
  ans=False
if D<Bleft or Bright<D:
  ans=False
  
if (A-B)*(C-D)<0:
  commonL=max(Aleft,Bleft)
  commonR=min(Aright,Bright)
  if "..." not in S[commonL:commonR+1]:
    ans=False

print(("No","Yes")[ans])

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

Aleft=max(S[:A].rfind("##"),0)
Aright=S.find("##",A,-1) if S.find("##",A,-1)>=0 else len(S)-1

Bleft=max(S[:B].rfind("##"),0)
Bright=S.find("##",B,-1) if S.find("##",B,-1)>=0 else len(S)-1

ans=True
if C<Aleft or Aright<C:
  ans=False
if D<Bleft or Bright<D:
  ans=False
  
if C>D:
  commonL=max(Aleft,Bleft)
  commonR=min(Aright,Bright)
  if "..." not in S[commonL:commonR+1]:
    ans=False

print(("No","Yes")[ans])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '#' + sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '#' + sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '#' + sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '#' + sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '#' + sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '#' + sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '#' + sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '#' + sys.stdin.readline().rstrip() + '#'

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '-' + sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '#' + sys.stdin.readline().rstrip()

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '#' + sys.stdin.readline().rstrip()

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '#' + sys.stdin.readline().rstrip()

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = sys.stdin.readline().rstrip()


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '#' + sys.stdin.readline().rstrip()


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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s =  sys.stdin.readline().rstrip()

    # if a < b < c < d or a < b < d < c:
    #     if '##' in s[a+1:max(c, d)-1]:
    #         print('No')
    #         sys.exit()
    # if a < c < b < d:
    #     if '##' in s[a+1:c-1] or '##' in s[b+1:d-1]:
    #         print('No')
    #         sys.exit()
    
    # if c < d:
    #     ans = 'Yes'
    # elif c > d:
    #     if '...' in s[b-1:d]:
    #         ans = 'Yes'
    #     else:
    #         ans = 'No'

    if a < b < c < d or a < b < d < c:
        if '##' in s[a:max(c-1, d-1)-1]:
            print('No')
            sys.exit()
    if a < c < b < d:
        if '##' in s[a:c-2] or '##' in s[b:d-2]:
            print('No')
            sys.exit()
    
    if c < d:
        ans = 'Yes'
    elif c > d:
        if '...' in s[b-2:d-1]:
            ans = 'Yes'
        else:
            ans = 'No'
    
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s =  '#' + sys.stdin.readline().rstrip()

    if a < b < c < d or a < b < d < c:
        if '##' in s[a+1:max(c, d)-1]:
            print('No')
            sys.exit()
    if a < c < b < d:
        if '##' in s[a+1:c-1] or '##' in s[b+1:d-1]:
            print('No')
            sys.exit()
    
    if c < d:
        ans = 'Yes'
    elif c > d:
        if '...' in s[b-1:d]:
            ans = 'Yes'
        else:
            ans = 'No'
    
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# 2019-11-22 19:46:21(JST)
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s =  '#' + sys.stdin.readline().rstrip()
    if '##' in s[a+1:max(c, d)-1]:
        ans = 'No'
    else:
        # そうでなければFnukeはどこでもいける
        # '...'があればSnukeが追い越すことも可能
        if c < d:
            ans = 'Yes'
        elif c > d:
            if '...' in s[b-1:d]:
                ans = 'Yes'
            else:
                ans = 'No'
    
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.buffer.readline


def main():
    N, A, B, C, D = map(int, readline().split())
    S = readline().decode('UTF-8')
    A -= 1
    B -= 1
    C -= 1
    D -= 1

    if C < D:
        s = A
        g = D
        for i in range(s, g):
            if S[i:i+2] == "##":
                print('No')
                sys.exit()
        else:
            print('Yes')

    else:
        s = A
        g = C
        for i in range(s, g):
            if S[i:i+2] == "##":
                print(S[i:i+2])
                print('No')
                sys.exit()

        s = B
        g = D
        for i in range(s, g):
            if S[i:i+3] == "...":
                print('Yes')
                sys.exit()
        else:
            print('No')


main()

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.buffer.readline


def main():
    N, A, B, C, D = map(int, readline().split())
    S = readline().decode('UTF-8')
    A -= 1
    B -= 1
    C -= 1
    D -= 1

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

    else:
        s = min(A, B)
        g = max(C, D)
        for i in range(s, g-1):
            if S[i:i+2] == "##":
                print(S[i:i+2])
                print('No')
                sys.exit()

        s = max(A, B)
        g = min(C, D)
        for i in range(s, g):
            if S[i:i+3] == "...":
                print('Yes')
                sys.exit()
        else:
            print('No')


main()

Submission status: Wrong Answer

Solution code:
import sys

readline = sys.stdin.buffer.readline


def main():
    N, A, B, C, D = map(int, readline().split())
    S = readline().decode('UTF-8')
    A -= 1
    B -= 1
    C -= 1
    D -= 1

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

    else:
        s = min(A, B)
        g = max(C, D)
        for i in range(s, g-3):
            if S[i:i+2] == "##":
                print('No')
                sys.exit()

        s = max(A, B)
        g = min(C, D)
        for i in range(s, g-3):
            if S[i:i+3] == "...":
                print('Yes')
                sys.exit()
        else:
            print('No')


main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from itertools import groupby
import sys

n, A, B, C, D = map(int, input().split())
s = input()
if D < C:
    a = [[k, len(list(g))] for k, g in groupby(s[B-2:D+1])]
    for i in range(len(a)):
        if a[i][0] == "." and a[i][1] >= 3:
            break
        if i == len(a)-1:
            print("No")
            sys.exit()
b = [[k, len(list(g))] for k, g in groupby(s)]
for i in range(len(b)):
        if b[i][0] == "#" and b[i][1] >= 2:
            break
        if i == len(b)-1:
            print("Yes")
            sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from itertools import groupby
import sys

n, a, b, c, d = map(int, input().split())
s = input()
if d < c:
    a = [[k, len(list(g))] for k, g in groupby(s[b-2:d+1])]
    for i in range(len(a)):
        if a[i][0] == "." and a[i][1] >= 3:
            break
        if i == len(a)-1:
            print("No")
            sys.exit()
b = [[k, len(list(g))] for k, g in groupby(s)]
for i in range(len(b)):
        if b[i][0] == "#" and b[i][1] >= 2:
            break
        if i == len(b)-1:
            print("Yes")
            sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from itertools import groupby
import sys

n, a, b, c, d = map(int, input().split())
s = input()
if d < c:
    a = [[k, len(list(g))] for k, g in groupby(s[b-2:c+1])]
    for i in range(len(a)):
        if a[i][0] == "." and a[i][1] >= 3:
            break
        if i == len(a)-1:
            print("No")
            sys.exit()
b = [[k, len(list(g))] for k, g in groupby(s)]
for i in range(len(b)):
        if b[i][0] == "#" and b[i][1] >= 2:
            break
        if i == len(b)-1:
            print("Yes")
            sys.exit()
print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
from itertools import groupby
import sys

n, a, b, c, d = map(int, input().split())
s = input()
if d != n:
    a = [[k, len(list(g))] for k, g in groupby(s[b-2:c+1])]
    for i in range(len(a)):
        if a[i][0] == "." and a[i][1] >= 3:
            break
        if i == len(a)-1:
            print("No")
            sys.exit()
b = [[k, len(list(g))] for k, g in groupby(s)]
for i in range(len(b)):
        if b[i][0] == "#" and b[i][1] >= 2:
            break
        if i == len(b)-1:
            print("Yes")
            sys.exit()
print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import re
n,a,b,c,d=map(int,input().split())
s=input()
if re.search('##',s[a:c+1]) or re.search('##',s[b:d+1]):
    print('No')
if c > d:
    if re.search('\.\.\.', s[b-2:d+1]):
        print('Yes')
    else:
        print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
import re
n,a,b,c,d = map(int,input().split())
s = input()

ts = s[a-1:max(c,d)]
if (re.search(r"##",ts)):
    print("No")
    exit()

# 追い越す場合
if (c > d):
    # 追い越せるポイント[...]が存在
    if (re.search(r"\.\.\.",s[b-1:d])):
        print("Yes")
    else :
        if (s[d-2] == "#")|(s[d] == "#"):
            print("No")
        else :
            print("Yes")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
import re
n,a,b,c,d = map(int,input().split())
s = input()

ts = s[a-1:max(c,d)]
if (re.search(r"##",ts)):
    print("No")
    exit()

# 追い越す場合
if (c > d):
    # 追い越せるポイント[...]が存在
    if (re.search(r"\.\.\.",s[b-1:d])):
        print("Yes")
    else :
        if (s[d-2] == "#"):
            print("No")
        else :
            print("Yes")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
import re
n,a,b,c,d = map(int,input().split())
s = input()

ts = s[a-1:max(c,d)]
if (re.search(r"##",ts)):
    print("No")
    exit()

if (c > d):
    # 追い越す場合
    # 追い越せるポイントが存在
    if (re.search(r"\.\.\.",s[b-1:d])):
        print("Yes")
    else :

        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
import re
n,a,b,c,d = map(int,input().split())
s = input()

ts = s[a-1:max(c,d)]
if (re.search(r"##",ts)):
    print("No")
    exit()

if (c > d):
    print(s[b-1:d])
    # 追い越す場合
    # 追い越せるポイントが存在
    if (re.search(r"\.\.\.",s[b-1:d])):
        print("Yes")
    else :

        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
import re
n,a,b,c,d = map(int,input().split())
s = input()

if (re.search(r"##",s)):
    print("No")
    exit()

if (c > d):
    # 追い越す場合
    if (re.search(r"\.\.\.",s[b-1:d])):
        print("Yes")
    else :
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
# A - Kenken Race
import re
n,a,b,c,d = map(int,input().split())
s = input()

if (re.search(r"##",s)):
    print("No")
    exit()

if (c > d):
    # 追い越す場合
    if (re.search(r"\.\.\.",s)):
        print("Yes")
    else :
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
def existsDoubleSharp(S, x, y):
  for i in range(x+1, y):
    if S[i-1]=="#" and S[i]=="#":
      return True
  return False

def existsTriplePeriod(S, x, y):
  for i in range(x+2, y):
    if S[i-2]=="." and S[i-1]=="." and S[i]==".":
      return True
  return False

N, A, B, C, D=map(int, input().split())
S=input()
ans="Yes"
if C<B:
  ans="No" if existsDoubleSharp(S, A, B) or existsDoubleSharp(S, C, D) else "Yes"
elif C<D:
  ans="No" if existsDoubleSharp(S, A, D) else "Yes"
else:
  ans="No" if existsDoubleSharp(S, A, C) or not existsTriplePeriod(S, A, C) else "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
def existsDoubleSharp(S, x, y):
  for i in range(x+1, y):
    if S[i-1]=="#" and S[i]=="#":
      return True
  return False

def existsTriplePeriod(S, x, y):
  if x<2:
    x=2
  for i in range(x, y):
    if S[i-2]=="." and S[i-1]=="." and S[i]==".":
      return True
  return False

N, A, B, C, D=map(int, input().split())
S=input()
ans="Yes"
if C<B:
  ans="No" if existsDoubleSharp(S, A, B) or existsDoubleSharp(S, C, D) else "Yes"
elif C<D:
  ans="No" if existsDoubleSharp(S, A, D) else "Yes"
else:
  ans="No" if existsDoubleSharp(S, A, C) or not existsTriplePeriod(S, B, D) else "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
def existsDoubleSharp(S, x, y):
  for i in range(x+1, y):
    if S[i-1]=="#" and S[i]=="#":
      return True
  return False

def existsTriplePeriod(S, x, y):
  for i in range(x+2, y):
    if S[i-2]=="." and S[i-1]=="." and S[i]==".":
      return True
  return False

N, A, B, C, D=map(int, input().split())
S=input()
ans="Yes"
if C<B:
  ans="No" if existsDoubleSharp(S, A, B) or existsDoubleSharp(S, C, D) else "Yes"
elif C<D:
  ans="No" if existsDoubleSharp(S, A, D) else "Yes"
else:
  ans="No" if existsDoubleSharp(S, A, C) or not existsTriplePeriod(S, B, D) else "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

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

is_ok = True

for i in range(A - 1, max(C, D) - 2):
    if S[i] == "#" and S[i + 1] == "#":
        is_ok = False
        break

if is_ok:
    if C > D:
        is_ok = False
        for i in range(B - 1, D - 1):
            if S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
                is_ok = True
                break

ans = "Yes" if is_ok else "No"

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

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

is_ok = True

for i in range(A, max(C, D) - 1):
    if S[i] == "#" and S[i + 1] == "#":
        is_ok = False
        break

if is_ok:
    if C > D:
        is_ok = False
        for i in range(B, D - 1):
            if S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
                is_ok = True
                break

ans = "Yes" if is_ok else "No"

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

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

is_ok = True

for i in range(N - 1):
    if S[i] == "#" and S[i + 1] == "#":
        is_ok = False
        break

if is_ok:
    if C > D:
        is_ok = False
        for i in range(B, D - 1):
            if S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
                is_ok = True
                break

ans = "Yes" if is_ok else "No"

print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

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

is_ok = True

for i in range(N, N - 1):
    if S[i] == "#" and S[i + 1] == "#":
        is_ok = False
        break

if is_ok:
    if C > D:
        is_ok = False
        for i in range(B, D - 1):
            if S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
                is_ok = True
                break

ans = "Yes" if is_ok else "No"

print(ans)

Submission status: Wrong Answer

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

if S.find('##', a-1, c-1) != -1 or S.find('##', b-1, d-1) != -1:
    print('No')
    exit()

if c > d:
    if S.find('...', b-2, d) == -1:
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
S.insert(0,"#")
S.append("#")
N+=2
A+=1
B+=1
C+=1
D+=1

L=[0]*N
c=0
d=0
for i in range(N):
    if(S[i]=="#"):
        d+=-1
        c=0
        L[i]=d
    else:
        c+=1
        d=0
        L[i]=c


if((min(L[A-1:C-1])<-1)):
    print("No")
    exit()
if((min(L[B-1:D-1])<-1)):
    print("No")
    exit()

if(C<D):
    print("Yes")
    exit()
else:
    if(max(L[B:D])>2):
        print("Yes")
        exit()
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
S.insert(0,"#")
S.append("#")
N+=2
A+=1
B+=1
C+=1
D+=1

L=[0]*N
c=0
d=0
for i in range(N):
    if(S[i]=="#"):
        d+=-1
        c=0
        L[i]=d
    else:
        c+=1
        d=0
        L[i]=c


if((min(L[A-1:C-1])<-1)):
    print("No")
    exit()
if((min(L[B-1:D-1])<-1)):
    print("No")
    exit()

if(C<D):
    print("Yes")
    exit()
else:
    if(max(L[B:D])>2):
        print("Yes")
        exit()
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
S.insert(0,"#")
S.append("#")
N+=2
A+=1
B+=1
C+=1
D+=1

L=[0]*N
c=0
d=0
for i in range(N):
    if(S[i]=="#"):
        d+=-1
        c=0
        L[i]=d
    else:
        c+=1
        d=0
        L[i]=c


if((min(L[A-1:C-1])<-1)):
    print("No")
    exit()
if((min(L[B-1:D-1])<-1)):
    print("No")
    exit()

if(C<D):
    print("Yes")
    exit()
else:
    if(max(L[B:D-1])>2):
        print("No")
        exit()
    else:
        print("No")