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: Accepted

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[A-1:max(C, D)])]
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: Accepted

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-2:d+1]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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[b-2] == "#")|(s[b] == "#"))&((s[d-2] == "#")|(s[d] == "#")):
            print("No")
        else :
            print("Yes")
else:
    print("Yes")

Submission status: Accepted

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 - 2, 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: Accepted

Solution code:
n, a, b, c, d = map(int, input().split())
S = input()
if S.find('##', a, c) != -1 or S.find('##', b, d) != -1:
    print('No')
    exit()

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

print('Yes')

Submission status: Accepted

Solution code:
def solve(a, b, c, d, s):
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    ss = s[a:c + 1]
    fs = s[b:d + 1]
    if '##' in ss:
        return False
    if '##' in fs:
        return False
    if c < d:
        return True
    fs2 = s[b - 1:d + 2]
    if '...' in ss and '...' in fs2:
        return True
    return False
 
 
n, a, b, c, d = list(map(int, input().split()))
s = input()
print('Yes' if solve(a, b, c, d, s) else 'No')

Submission status: Accepted

Solution code:
#a-kenkenlace
n,a,b,c,d=map(int,input().split())
s=input()
s="X"+s+"X"
#i伴目からj番目までに置いて000となることがありうるかということを分析する関数
def judge1(a,b):
    flag=False
    counterx=0
    countero=0
    for i in range(a,b+1):
        if s[i]=="." and s[i-1]=="." and s[i+1]==".":
            flag=True
            break
    return flag
def judge2(a,b):
    flag=True
    for i in range(a-1,b-1):
        if s[i]=="#" and s[i+1]=="#":
            flag=False
            break
    return flag
if c<d:
    if judge2(a,c) and judge2(b,d):
        print("Yes")
    else:
        print("No")
elif d<c:
    if judge1(b,d) and judge2(a,c):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
N, A, B, C, D = map(int,input().split())
A = A - 1
B = B - 1
C = C - 1
D = D - 1
S = input()
if "##" in S[A:C+1] or "##" in S[B:D+1]:
    print("No")
    exit()

if  D < C and (S[D-1] == "#" or S[D+1] == "#"):
    if "..." in S[B-1:D+1]:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
def solve(s, a, b, c, d):
    if '##' in s[a:c + 1]:
        return False
    if '##' in s[b:d + 1]:
        return False

    # A < B < D
    # Cの位置により場合分け

    # A < C < B < D
    if c < b:
        return True

    # A < B < C < D
    if c < d:
        return True

    # A < B < D < C
    return '...' in s[b - 1:d + 2]


if __name__ == '__main__':
    n, *args = map(int, input().split())
    a, b, c, d = map(lambda x: x - 1, args)

    s = input()

    print('Yes' if solve(s, a, b, c, d) else 'No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
A-=1
B-=1
C-=1
D-=1
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: Accepted

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
S = '#' + S
sunuke = A
funuke = B

while funuke < D:
    if S[funuke + 1] == '.':
        funuke += 1
    else:
        if S[funuke + 2] == '.':
            funuke += 2
        else:
            print('No')
            exit()
while sunuke < C:
    if S[sunuke + 1] == '.':
        sunuke += 1
    else:
        if S[sunuke + 2] == '.':
            sunuke += 2
        else:
            print('No')
            exit()

if C < D:
    print('Yes')
else:
    for i in range(B - 1, D):
        if S[i:i + 3] == '...':
            print('Yes')
            exit()
    else:
        print('No')

Submission status: Accepted

Solution code:
def resolve():
    n, a, b, c, d = list(map(int, input().split()))
    s = input()
    if "##" in s[a - 1:c] or "##" in s[b - 1:d]:
        print("No")
        return 0

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

a -= 1; b -= 1; c -= 1; d -= 1

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

#ABDC
elif d < c:
    flag_a = False
    for i in range(b, d+1):
        if s[i-1] == "." and s[i] == "." and s[i+1] == ".":
            flag_a = True

    flag_b = True
    for i in range(a, d-1):
            if s[i] == "#" and s[i+1] == "#":
                flag_b = False

    if flag_a and flag_b:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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

ans='Yes'
if d>c:
    check=0
    for i in range(a,d):
        if s[i]=='.':
            check=0
        else:
            check+=1
            if check==2:
                ans='No'
else:
    check=0
    for i in range(a,c):
        if s[i]=='.':
            check=0
        else:
            check+=1
            if check==2:
                ans='No'
    check=0
    for i in range(b-2,d+1):
        if s[i]=='.':
            check+=1
            if check==3:
                break
        else:
            check=0
    if check!=3:
        ans='No'
print(ans)

Submission status: Accepted

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

ans='Yes'
if d>c:
    check=0
    for i in range(a,d):
        if s[i]=='.':
            check=0
        else:
            check+=1
            if check==2:
                ans='No'
else:
    check=0
    for i in range(a,c):
        if s[i]=='.':
            check=0
        else:
            check+=1
            if check==2:
                ans='No'
    check=0
    for i in range(b-2,d+1):
        if s[i]=='.':
            check+=1
            if check==3:
                break
        else:
            check=0
    if check!=3:
        ans='No'
print(ans)

Submission status: Accepted

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

if '#' in [S[A-1], S[B-1], S[C-1], S[D-1]]:
    ans = 'No'
elif '##' in S[A-1:C] or '##' in S[B-1:D]:
    ans = 'No'
elif A < B and C > D:
    if '...' not in S[B-2:min(C, D)+1]:
        ans = 'No'

print(ans)

Submission status: Accepted

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

if (b-a)*(d-c)>0 and max(a,b) < min(c,d):
  for i in range(min(a,b)-1,max(c,d)):
    if s[i]=='#' and s[i+1]=='#':
      print('No')
      exit()
  print('Yes')

elif (b-a)*(d-c)>0 and max(a,b) > min(c,d):
  for i in range(a-1,c):
    if s[i]=='#' and s[i+1]=='#':
      print('No')
      exit()
  for i in range(b-1,d):
    if s[i]=='#' and s[i+1]=='#':
      print('No')
      exit()
  print('Yes')
 
else:
  for i in range(min(a,b)-1,max(c,d)):
    if s[i]=='#' and s[i+1]=='#':
      print('No')
      exit()
  for i in range(max(a,b)-1,min(c,d)):
    if s[i-1]=='.' and s[i]=='.' and s[i+1]=='.':
      print('Yes')
      exit()
  print('No')

Submission status: Accepted

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

def aa():
    for i in range(a, c):
        if s[i:i+2] == "##":
            return "No"
    for i in range(b, d):
        if s[i:i+2] == "##":
            return "No"
    if c > d:
        for i in range(b-1, d):
            if s[i:i+3] == "...":
                return "Yes"
        return "No"
    else:
        return "Yes"

print(aa())

Submission status: Accepted

Solution code:
N,A,B,C,D=map(int,input().split())
S='.'+input() # 便宜上，S[0]='.'とし，問題文の1-initialに合わせる

if D<C:
    f=False
    for i in range(B-1,D):
        if S[i:i+3]=='...':
            f=True
else:
    f=True

if f:
    for i in range(A+1,C-1):
        if S[i:i+2]=='##':
            f=False
    for i in range(B+1,D-1):
        if S[i:i+2]=='##':
            f=False

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = input().rstrip()
if c < d:
    s = s[a:d]
    for c0, c1 in zip(s, s[1:]):
        if c0 == c1 == '#':
            print('No')
            break
    else:
        print('Yes')
else:
    ok = False
    for i in range(b - 1, d):
        if i + 2 < n and s[i] == s[i + 1] == s[i + 2] == '.':
            ok = True
            break
    else:
        print('No')
    if ok:
        s = s[a:c]
        for c0, c1 in zip(s, s[1:]):
            if c0 == c1 == '#':
                print('No')
                break
        else:
            print('Yes')

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N,A,B,C,D=map(int,input().split())
S=input()
A-=1
B-=1
C-=1
D-=1

"""
ABDCとか順番が逆転するなら3つ以上連続の空きがないとアウト
ABCDならAからDにいけないとアウト ACBDの可能性があるので注意
"""
if C<D:
    if C<B:
        if "##" in S[A:C+1] or "##" in S[B:D+1]:#ACBD
            print("No")
        else:
            print("Yes")
    else:
        if "##" in S[A:D+1]:#ABCD
            print("No")
        else:
            print("Yes")
else:
    if "..." in S[A:C+1] and not "##" in S[A:C+1]:#ABDC
        if S[B+1]=="#" and not "..." in S[B:C+1]:#A.B#..#..#..対策
            print("No")
        elif S[D-1]=="#" and not "..." in S[A:D+1]:#AB.#..#D.C...対策
            print("No")
        else:
            print("Yes")
    else:
        print("No")

Submission status: Accepted

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

if c < b:
    pre = '.'
    for i in range(a, c):
        if pre == '#' and s[i] == '#':
            print('No')
            exit()
        pre = s[i]
    pre = '.'
    for i in range(b, d):
        if pre == '#' and s[i] == '#':
            print('No')
            exit()
        pre = s[i]
elif c < d:
    pre = '.'
    for i in range(a, d):
        if pre == '#' and s[i] == '#':
            print('No')
            exit()
        pre = s[i]
else:
    pre = '.'
    prepre = '#'
    three = False
    for i in range(a, c):
        if pre == '#' and s[i] == '#':
            print('No')
            exit()
        if b <= i <= d and prepre == '.' and pre == '.' and s[i] == '.':
            three = True
        prepre = pre
        pre = s[i]
    if three == False:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

con = True
for i in range(a,d+1):
    if s[i-1]=="#" and s[i]=="#":
        print("No")
        con = False
        break

if (con):
    if (c<b) or (c<d):
        print("Yes")
        con = False

if (con):
    for i in range(b-1,d):
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            print("Yes")
            con = False
            break

if (con):
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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


# A B C D
# A C B D
if C < D:
  print("Yes")
  exit()

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

Submission status: Accepted

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

s=input()

if C<D:
    if not "##" in s[A:D+1]:
        ans="Yes"
    else:
        ans="No"
elif D<C:
    if not "##" in s[A:C+1]:
        if "..." in s[B-1:D+2]:
            ans="Yes"
        else:
            ans="No"
    else:
        ans="No"

print(ans)

Submission status: Accepted

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

s=input()

if A<B<C<D:
    if not "##" in s[B:D+1]:
        if not "##" in s[A:C+1]:
            ans="Yes"
        else:
            ans="No"
    else:
        ans="No"
elif A<B<D<C:
    if not "##" in s[A:C+1]:
        if s[B-1]!="#" and s[B+1]!="#":
            ans="Yes"
        elif "..." in s[B:D+1]:
            ans="Yes"
        elif s[D-1]!="#" and s[D+1]!="#":
            ans="Yes"
        else:
            ans="No"
    else:
        ans="No"
elif A<C<B<D:
    if "##" in s[A:C+1] or "##" in s[B:D+1]:
        ans="No"
    else:
        ans="Yes"
print(ans)

Submission status: Accepted

Solution code:
N,A,B,C,D = map(int,input().split())
s = input()
#print(s)
if "##" in s[B:D] or "##" in s[A:C]:
  print("No")
  exit()
elif C > D and "..." not in s[B-2:D+1]:
  print("No")
  exit() 
print("Yes")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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


def two_rocks(li):
    if "##" in li:
        return True
    else:
        return False


def three_spaces(li):
    if "..." in li:
        return True
    else:
        return False


def solve():
    if two_rocks(s[a-1:c-1]):
        return False
    if two_rocks(s[b-1:d-1]):
        return False
    if d < c:
        if three_spaces(s[b-2:d+1]):
            return True
        else:
            return False
    else:
        return True


ans = "Yes" if solve() else "No"
print(ans)

Submission status: Accepted

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

flag = True
for i in range(min(a-1, b-1), max(c, d)-1):
    if s[i] == '#' and s[i+1] == '#':
        flag = False

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

if flag and flag2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

A -= 1
B -= 1
C -= 1
D -= 1


def moveA(A, dest=True):
    if A == C:
        return A, True
    elif dest is True and A+1 == C and B != A+1:
        A += 1
    elif dest is True and A+2 == C and B != A+2:
        A += 2
    elif A+1 < N and S[A+1] == "." and B != A+1:
        A += 1
    elif A+2 < N and S[A+2] == "." and B != A+2:
        A += 2
    else:
        return A, True

    return A, False


def moveB(B, dest=True):
    if B == D:
        return B, True
    elif dest is True and B+1 == D and A != B+1:
        B += 1
    elif dest is True and B+2 == D and A != B+2:
        B += 2
    elif B+1 < N and S[B+1] == "." and A != B+1:
        B += 1
    elif B+2 < N and S[B+2] == "." and A != B+2:
        B += 2
    else:
        return B, True

    return B, False


if C < D:
    while B != D:
        B, stop = moveB(B)
        if stop:
            break
        # print(A, '=', C, ',', B, '=', D)

    while A != C:
        A, stop = moveA(A)
        if stop:
            break
        # print(A, '=', C, ',', B, '=', D)
else:
    while A < B and A != C:
        A, stop = moveA(A, dest=False)
        if stop:
            B, stop = moveB(B, dest=False)
            if stop:
                # for i in range(-3 + A, 4 + A):
                #     if i == A:
                #         print('A', end='')
                #     elif i == B:
                #         print('B', end='')
                #     else:
                #         print(S[i], end='')
                # print()
                # print(A, B, C, D)
                # print(A+2 < N and S[A+2] == "." and B != A+2)
                # print(S[A+2] == ".")
                # print(B != A+2)
                break
        # print(1, A, '=', C, ',', B, '=', D)

    while A != C:
        A, stop = moveA(A)
        if stop:
            # print('A', S[A-4:A+3], A, '=', C, ',', B, '=', D)
            break
        # print(2, A, '=', C, ',', B, '=', D)

    while B != D:
        B, stop = moveB(B)
        if stop:
            # print('B', S[B-4:B+3], A, '=', C, ',', B, '=', D)
            break
        # print(3, A, '=', C, ',', B, '=', D)

if A == C and B == D:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

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

A -= 1
B -= 1
C -= 1
D -= 1

m = [0] * N
m[A] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[C] == 0:
    print("No")
    exit()

m = [0] * N
m[B] = 1

for i in range(N):
    if m[i] > 0:
        if i + 1 < N and L[i + 1] == ".":
            m[i + 1] = 1

        if i + 2 < N and L[i + 2] == ".":
            m[i + 2] = 1

if m[D] == 0:
    print("No")
    exit()

if C > D:
    for i in range(B, D+1):
        if "#" not in L[i-1:i+2]:
            print("Yes")
            exit()
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
import sys

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(list(sys.stdin.readline())[:-1])

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def main():
    N,A,B,C,D = LI()
    s = S()

    for i in range(B-1,D-1):
        if s[i] == "#" and s[i+1] == "#":
            return "No"

    if C<D:
        for i in range(A-1,C-1):
            if s[i] == "#" and s[i+1] == "#":
                return "No"
        return "Yes"

    flag = False
    for i in range(B-2,D-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            flag = True
    if flag:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
n, a, b, c, d = (int(e) - 1 for e in input().split())
s = input()

if c < d:
    ok1 = not any(s[i] == s[i + 1] == '#' for i in range(a, c))
    ok2 = not any(s[i] == s[i + 1] == '#' for i in range(b, d))
    print('Yes' if ok1 and ok2 else 'No')
else:
    ok1 = not any(s[i] == s[i + 1] == '#' for i in range(a, c))
    ok2 = not any(s[i] == s[i + 1] == '#' for i in range(b, d))
    ok3 = any(s[i - 1] == s[i] == s[i + 1] == '.' for i in range(b, d + 1) if 0 < i and i < n - 1)
    print('Yes' if ok1 and ok2 and ok3 else 'No')

Submission status: Accepted

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

if (A-B)*(C-D) >= 1:  # A>BかつC>D もしくは A<BかつC<D
    if S[min(A, B)-1:max(C, D)].find('##') == -1:
        print('Yes')
    else:
        print('No')
else:
    # print(S[max(A, B)-2:min(C, D)+1])
    if S[min(A, B)-1:max(C, D)].find('##') == -1 and S[max(A, B)-2:min(C, D)+1].find('...') >= 0:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
MOD = 10**9 + 7
N, A, B, C, D = map(int, input().split())
S = input()
# print((A-B)*(C-D))

if (A-B)*(C-D) >= 1:  # A>BかつC>D もしくは A<BかつC<D
    if S[min(A, B)-1:max(C, D)].find('##') == -1:
        print('Yes')
    else:
        print('No')
else:
    # print(S[max(A, B)-2:min(C, D)+1])
    if S[min(A, B)-1:max(C, D)].find('##') == -1 and S[max(A, B)-2:min(C, D)+1].find('...') >= 0:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
N, A, B, C, D = [int(i) for i in input().split()]
S = input()
ans = True
# check if there are two connected rocks
for i in range(A-1, max(C, D)):
    if S[i:i+2] == "##":
        ans = False
        break
else:
    if D < C:
        # check if there are three dots between B and D
        for i in range(B-2, D-1):
            if S[i:i+3] == "...":
                break
        else:
            ans = False
if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

for i in range(A,max(C,D)-1):
    if S[i:i+2] == "##":
        print("No")
        exit(0)

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

    if flag == False:
        print("No")
        exit(0)

print("Yes")

Submission status: Accepted

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

for i in range(A,max(C,D)-1):
    if S[i:i+2] == "##":
        print("No")
        exit(0)

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

    if flag == False:
        print("No")
        exit(0)

print("Yes")

Submission status: Accepted

Solution code:
# 2019/08/29

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

s=input()
if c<d:
    flag=True
else:
    flag=False

if flag:
    for i in range(a,d-1):
        if s[i]==s[i+1]=='#':
            print('No')
            exit()
else:
    for i in range(b-1,d):
        if s[i-1]==s[i]==s[i+1]=='.':
            print('Yes')
            exit()

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

Submission status: Accepted

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

    # for i in range(B-1, D-1):
    #     if S[i] + S[i+1] == "##":
    #         return 'No'
    # for i in range(A-1, C-1):
    #     if S[i] + S[i+1] == "##":
    #         return 'No'

    for i in range(B, D-2):
        if S[i] + S[i+1] == "##":
            return 'No'
    for i in range(A, C-2):
        if S[i] + S[i+1] == "##":
            return 'No'

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

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

    for i in range(B-1, D-1):
        if S[i] + S[i+1] == "##":
            return 'No'
    for i in range(A-1, C-1):
        if S[i] + S[i+1] == "##":
            return 'No'

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

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

c = [1 if S[0] == '#' else -1]
for i in range(1, N):
    if c[-1] > 0:
        if S[i] == '#':
            c.append(c[-1] + 1)
        else:
            c.append(-1)
    else:
        if S[i] == '#':
            c.append(1)
        else:
            c.append(c[-1] - 1)

if A < B < C < D:
    ans = max(c[A:D + 1]) <= 1
elif A < B < D < C:
    ans = max(c[A:C + 1]) <= 1 and min(c[B + 1:D + 2]) <= -3
elif A < C < B < D:
    ans = max(c[A:C + 1]) <= 1 and max(c[B:D + 1]) <= 1
print('Yes' if ans else 'No')

Submission status: Accepted

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

Submission status: Accepted

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

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

for i in range(B, D-1):
    if S[i] == "#" and S[i+1] == "#":
        print("No")
        exit()

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

Submission status: Accepted

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

    for i in range(a-1, d-1):
        if ss[i:i+2] == '##':
            print('No')
            return

    if c < d:
        print('Yes')
    else:
        for i in range(b-2,d-1):
            if ss[i:i+3] == '...':
                print('Yes')
                return
        print('No')
resolve()

Submission status: Accepted

Solution code:
def solve(A,B,C,D,S):  
  if S[C-1] == "#" or S[D-1] == "#" or "##" in S[A:C-1]or "##" in S[B:D-1]:
    print("No")
    exit()
  if (D<C):
    if "..." not in S[B-2:D+1]:
      print("No")
      exit()
  print("Yes")

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline

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

if "##" in S[A:C] or "##" in S[B:D]:
    print("No")
    exit()

if D < C:
#    print(S[A:D])
    if "..." not in S[B-2:D+1]:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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')
    exit(0)

if C > D:
    if '...' not in S[B - 1: D + 2]:
        print('No')
        exit(0)

print('Yes')

Submission status: Accepted

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

for i in range(C - A):
    if S[A + i: A + i + 2] == '##':
        print('No')
        exit(0)
for i in range(D - B):
    if S[B + i: B + i + 2] == '##':
        print('No')
        exit(0)

if C > D:
    if '...' not in S[B - 1: D + 2]:
        print('No')
        exit(0)

print('Yes')

Submission status: Accepted

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

def can_go(instr,l,r):
    s1 = instr[l:r+1]
    res =  all([ len(i) < 2 for i in s1.split(".") if i != ""])
    return res

def can_swap(instr,l,r):
    s1 = instr[l:r+1]
    res = any([ len(i) >= 3 for i in s1.split("#") if i != ""])
    return res

ans = "No"
if can_go(s,a,c) and can_go(s,b,d):
    if c < d:
        ans = "Yes"
    else:
        if can_swap(s,b-1,d+1):
            ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
import sys

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

sl=list(s)

sl[a-1]="A"
sl[b-1]="B"
sl[c-1]="a"
sl[d-1]="b"
#print(sl)

if c>d:
    g_far=c
else:
    g_far=d

#連続して"#"が来た場合はクリア不可
for i in range(a-1,g_far-2):
    if sl[i]=="#" and sl[i+1]=="#":
        print("No")
        sys.exit()

#c>dの場合、連続3マスの"."が必要

if c>d:
    for j in range(b-1-1,d-1):
        #print(sl[j],sl[j+1],sl[j+2])
        if sl[j] !="#" and sl[j+1] !="#" and sl[j+2] !="#":
            print("Yes")
            sys.exit()
else:
    print("Yes")
    sys.exit()

print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# AGC034A - Kenken Race
def main():
    n, a, b, c, d = tuple(map(int, input().rstrip().split()))
    S = input().rstrip()
    flg1 = "##" not in S[a - 1 : c] and "##" not in S[b - 1 : d]
    flg2 = 1 if c < d else "..." in S[b - 2: d + 1]
    print("Yes" if flg1 and flg2 else "No")


if __name__ == "__main__":
    main()