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:
# AGC034A - Kenken Race
def main():
    n, a, b, c, d = tuple(map(int, input().rstrip().split()))
    S = input().rstrip()
    if "##" in S[a - 1 : c] or "##" in S[b - 1 : d]:
        flg = 0
    else:
        if c < d:
            flg = 1
        else:
            flg = "..." in S[b - 2 : d + 1]
    print("Yes" if flg else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from copy import *

N, A, B, C, D = map(lambda x: int(x)-1, input().split())
S = input()
if "##" in S[A:C] or "##" in S[B:D]:
    print('No')
    exit()
if C < D:
    print('Yes')
else:
    if "..." in S[B-1:D+2]:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif D < C:
    for index in range(B-2, D-1):
        if (index != A - 1) and inputs[index] != '#' and inputs[index+1] != '#' and inputs[index+2] != '#':
            flag = True
    flag = flag and compute(A-1, C-1) and compute(B-1, D-1)

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

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

def compute(index, end):
    if inputs[index] == '#' or index > end:
        return False
    if index == end:
        return True
    return compute(index+1, end) or compute(index+2, end)

flag = False
if A < C and C < B:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif B < C < D:
    flag = compute(A-1, C-1) and compute(B-1, D-1)
elif D < C:
    for index in range(B-2, D-1):
        if inputs[index] != '#' and inputs[index+1] != '#' and inputs[index+2] != '#':
            flag = True
    flag = flag and compute(A-1, C-1) and compute(B-1, D-1)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    if '##' in s[a:c + 1] or '##' in s[b:d + 1]:
        return False
    if b < c < d:
        return True  # sfsf
    if c < b < d:
        return True  # ssff
    return '...' in s[b - 1:d + 2]  # sffs


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

s = input()

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

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 S[A:max(C,D)+1].count("##") == 0 :
    if C < D :
        print("Yes")
    else :
        if S[B-1:D+2].count("...") :
            print("Yes")
        else :
            print("No")
else :
    print("No")

Submission status: Accepted

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

if d > c:
    S1 = S[a - 1:c]
    S2 = S[b - 1:d]
    if "##" in S1 or "##" in S2:
        print("No")
        exit()
    else:
        print("Yes")
        exit()

S1 = S[a - 1:c]
S2 = S[b - 1:d]
if "##" in S1 or "##" in S2:
    print("No")
    exit()

S3 = S[b - 2:d + 1]
if "..." in S3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#AGC34-A
import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

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

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    b = LI()
    ans = []
    for j in range(n):
        for i in range(len(b))[::-1]:
            if b[i] == i+1:
                x = b.pop(i)
                ans.append(x)
                break
    if b:
        print(-1)
    else:
        print(*ans[::-1],sep = "\n")
    return

#B
def B():
    n,a,b,c,d = LI()
    s = S()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    k = b
    while b < d:
        if s[b+1] == ".":
            b += 1
        else:
            if s[b+2] == "#":
                print("No")
                return
            b += 2
    b = k
    if c < d:
        while a < c:
            if s[a+1] == ".":
                a += 1
            else:
                if s[a+2] == "#":
                    print("No")
                    return
                a += 2
        print("Yes")
    else:
        for i in range(b-1,d):
            if s[i:i+3].count(".") == 3:
                print("Yes")
                return
        print("No")
    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    B()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n, a, b, c, d = li()
a -= 1
b -= 1
s = ns()

no2_ac = not "##" in s[a:c]
no2_bd = not "##" in s[b:d]
yes3_bd = "..." in s[b-1:d+1]

if c < d:
    print("Yes" if no2_ac and no2_bd else "No")

else:
    print("Yes" if no2_ac and no2_bd and yes3_bd else "No")

Submission status: Accepted

Solution code:
N,A,B,C,D=map(int,input().split())
S=list(input())
a=0
E=N-D
if C>D:
    for i in range(N-3):
        if S[i]=="#":
            for j in range(1,4):
                if S[i]==S[i+j]:
                    a=1
    if E==0:
        for i in range(B-2,D-2):
            if S[i]==".":
                if S[i]==S[i+1] and S[i+1]==S[i+2]:
                    a=0
                    break
    if E>=1:
        for i in range(B-2,D-1):
            if S[i]==".":
                if S[i]==S[i+1] and S[i+1]==S[i+2]:
                    a=0
                    break
for i in range(A,D):
    if S[i]=="#":
        if S[i+1]=="#":
            a=1
if a==0:
    print("Yes")
if a==1:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

def SINGLE_INT(): return int(INPUT())
def MULTIPLE_INT_LIST(): return list(map(int, INPUT().split()))
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())
def SINGLE_STRING(): return INPUT()
def MULTIPLE_STRING(): return INPUT().split()

N, A, B , A_goal, B_goal = MULTIPLE_INT_MAP()
S = SINGLE_STRING()

def surpass():

    if '...' in S[B-2:B_goal+1]:
        return 'Yes'
    else:
        return 'No'


if '##' in S[A-1: A_goal+1] or '##' in S[B-1:B_goal+1]:
    print('No')

else:
    if A_goal < B_goal:
        print('Yes')
    else:
        print(surpass())

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = input()

    if "##" in s[a:c] or "##" in s[b:d]:
        print("No")
        sys.exit()

    if c < d:
        print("Yes")
        sys.exit()

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
N, A, B, C, D = [int(x) for x in input().rsplit()]
S = input()
A = A - 1
B = B - 1
C = C - 1
D = D - 1

sunuke_possible = "##" not in S[A:C + 1]
funuke_possible = "##" not in S[B:D + 1]

if C > D:
    passing = "..." in S[B - 1:D + 2]
    possible = sunuke_possible * funuke_possible * passing
else:
    possible = sunuke_possible * funuke_possible

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

Submission status: Accepted

Solution code:
l = list(map(int,input().split()))
N = l[0]
A = l[1] 
B = l[2]
C = l[3]
D = l[4]
S = input()
S_list = list(S)

if B < C < D :
    count = 0
    for i in range(A, D-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else : 
        print('Yes')
elif C < B < D :
    count = 0
    for i in range(A, C-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1
    for j in range(B, D-1):
        if S_list[j] == S_list[j+1] == '#' :
            count += 1
    if count >= 1:
        print('No')
    else :
        print('Yes')
elif B < D < C:
    count = 0
    for i in range(A, C-2):
        if S_list[i] == S_list[i+1] == '#' :
            count += 1

    cou = 0
    for i in range(B-2, D-1):
        if S_list[i] == S_list[i+1] == S_list[i+2] == '.' :
            cou += 1
    if cou >= 1 and count < 1 :
        print('Yes')  
    else:
        print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N ,A ,B ,C ,D = list(map(int,input().split()))
S = input()
 
def judgeArrive(S, x, y):
    flag = "Yes"
    for i in range(x-1 ,y-2):
        if S[i] ==  S[i+1] == "#":
            flag = "No"
    return flag

def judgeJumpOver(S, x , y):
    flag = "No"
    for i in range(x-1 ,y):
        if S[i-1] ==  S[i] ==  S[i+1] == ".":
            flag = "Yes"
            break
    return flag
 
result = "Yes"
if(C > D):
    result = judgeJumpOver(S, B, D)
if(result == "Yes"):
    result = judgeArrive(S, B, D)
if(result == "Yes"):
    result = judgeArrive(S, A, C)
print(result)

Submission status: Accepted

Solution code:
N ,A ,B ,C ,D = list(map(int,input().split()))
S = input()
 
def judgeArrive(S, x, y):
  flag = "Yes"
  for i in range(x-1 ,y-2):
    if S[i] ==  S[i+1] == "#":
        flag = "No"
  return flag

def judgeJumpOver(S, x , y):
  flag = "No"
  for i in range(x-1 ,y):
    if S[i-1] ==  S[i] ==  S[i+1] == ".":
      flag = "Yes"
      break
 
  return flag
 
result = "Yes"
if(C > D):
  result = judgeJumpOver(S, B, D)
if(result == "Yes"):
  result = judgeArrive(S, B, D)
if(result == "Yes"):
  result = judgeArrive(S, A, C)
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

jump = 0
if c < d:
    for i in range(a, d-1):
        if s[i-1] == s[i] == "#":
            print("No")
            break
    else:
        print("Yes")            
else:
    for i in range(a, c-1):
        if s[i-1] == s[i] == "#":
            print("No")
            break
    else:
        for i in range(b-1, d):
            if s[i-1] == s[i+1] == s[i] ==".":
                print("Yes")
                break
        else:
            print("No")

Submission status: Accepted

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
 
def step(x,y):
    N_last = S[x:y-1]
    return N_last.find('##') == -1

Ans = step(A,C) and step(B,D)
 
if C > D:
    pass_path = False
    for b in range(B-1,D):
        if S[b] == '#':
            continue
        if S[b-1] == '.' and S[b+1] == '.':
            pass_path = True
            break
    Ans = step(A,C) and step(B,D) and  pass_path


if Ans == True:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B,Q,D = map(int,input().split())
S = input()
C = []
for i in range(len(S)):
    C.append(S[i])

if Q<D:
    error = 0
    for i in range(A,D-1):
        if C[i]=="#" and C[i+1]=="#":
            error = 1
            break
else:
    error = 0
    for i in range(B,D-1):
        if C[i]=="#" and C[i+1]=="#":
            error = 1
            break
    flag = 0
    for i in range(B-1,D):
        if C[i-1]=="." and C[i+1]=="." and C[i]==".":
            flag = 1
    if flag==0:
        error = 1

if error==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

if ('##' in s[a-1:max(c,d)]) == True: # そもそも行けるか
    print("No")
else:
    if d < c: # aがbを追い抜く必要があるとき
        # 抜かせるかどうか
        oinuki= s[b-2:d+1]
        if ("..." in oinuki) == True: # 3個以上の連続があれば抜かせる
            print("Yes")
        else: # 抜かせないとき
            print("No")
    else: # 追い抜く必要なし
        print("Yes")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N,A,B,C,D=map(int,input().split())
S=input()
if C<D:
    Slist=S[A-1:D].split(".")
    if S[A-1:D].count("#")==Slist.count("#"):
        print("Yes")
    else:
        print("No")
else:
    if S[A:B-1].split(".").count("#")!=S[A:B-1].count("#"):
        print("No")
    else:
        if S[B-2:D+1].split("#").count(".") \
        +S[B-2:D+1].split("#").count("..")*2 \
        ==S[B-2:D+1].count("."):
            print("No")
        else:
            print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, A, B, C, D = read_int()
S = read_str()

def solve():
    can_reach = not ('##' in S[A:C] or '##' in S[B:D])
    is_comma_suc3 = '...' in S[B - 2 : D + 1]
    if C < D:
        return "Yes" if can_reach else "No"
    else:
        return "Yes" if is_comma_suc3 and can_reach else "No"

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B,C,D = list(map(lambda x: int(x),input().split()))
S = " "+input()
def isAble():
    if "##" in S[A:C+1] or "##" in S[B:D+1]:
        return "No"
    if C>D:
        if "..." not in S[B-1:D+2]:
            return "No"
    return "Yes"

print(isAble())

Submission status: Accepted

Solution code:
N, A, B, C, D = [int(i) for i in input().split()]
road = [i for i in list(input())]

for i in range(D-A):
  if (road[A+i-1] == '#') & (road[A+i] == '#'):
    judge = 0
    break
  else:
    judge = 1
if judge == 1:
  if C < D:
    judge = 1
  else:
    for i in range(D-B+1):
      if (road[B+i-2] == '.') & (road[B+i-1] == '.') & (road[B+i] == '.'):
        judge = 1
        break
      else:
        judge = 0

if judge == 0:
  print("No")
else:
  print("Yes")

Submission status: Accepted

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

for x in S[A:max(C, D)-1].split("."):
    if len(x) > 1:
        print("No")
        sys.exit()
    else:
        pass

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

for x in S[B-2:D+1].split("#"):
    if len(x) > 2:
        print("Yes")
        sys.exit()
    else:
        pass

print("No")

Submission status: Accepted

Solution code:

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

S = input()




flag = True

for i in range(C-A):

    i += A
    i -= 1

    if S[i] == "#" and S[i+1] == "#":
        flag = False

for i in range(D-B):

    i += B
    i -= 1

    if S[i] == "#" and S[i+1] == "#":
        flag = False

flag2 = True

if C > D:

    flag2 = False

    for i in range(D-B+1):

        i += B-1
        i -= 1

        if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
            flag2 = True

        #print (i,i+1,i+2)

if flag and flag2:
    print ("Yes")

else:
    print ("No")

Submission status: Accepted

Solution code:
N, A, B, C, D = map( int, input().split())
b = [ string for string in input()]

Z = True

for i in range ( A, C-3):
  if (b[i] is "#") and (b[i+1] is "#"):
    Z = False
    break

if Z:    
  for i in range ( B, D-3):
    if (b[i] is "#") and (b[i+1] is "#"):
      Z = False
      break
    
if Z and ( C > D):
  for i in range ( B-1, D):
    if (b[i-1] is ".") and (b[i] is ".") and (b[i+1] is "."):
      Z = True
      break
    else :
      Z = False
      
if Z:
  print("Yes")
  
if not Z:
  print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def check_double_block(start, end, S):
    for i in range(start, end):
        if S[i] == "#" and S[i+1] == "#":
            return False
    return True

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

    S = "#" + S + "#"

    if C < D:
        if not check_double_block(A, C, S) or not check_double_block(B, D, S):
            print("No")
        else:
            print("Yes")
    else:
        for i in range(B, D+1):
            if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
                print("Yes")
                exit()
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# AGC034 A-Kenken Race

import sys

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

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

Submission status: Accepted

Solution code:
def solve():
    N,A,B,C,D = [int(s)-1 for s in input().split() if s]
    S = input()
    N += 1
    
    flag = True
    for i in range(A+1, max(C,D)-1):
        if S[i] == '#' and S[i+1] == '#':
            flag = False
    
    if flag and C > D:
        flag = False
        for i in range(B-1, D):
            if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
                flag = True
    
    print('Yes' if flag else 'No')

solve()

Submission status: Accepted

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

Submission status: Accepted

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

s = input()
s = '#' +s

def check(s, a, b):
    return not "##" in s[a:b]


def solve(s,a,b,c,d):
    can_swap = "..." in s[b - 1:d + 2]
    can_reach_each = check(s, a, c) and check(s, b, d)
    if not can_reach_each:
        return False
    if (a < b and c < d) or (b < a and d < c):
        return True
    else:
        if can_swap:
            return True
        else:
            return False

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

Submission status: Accepted

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

def check(l, r):
    return "##" not in s[l:r]

if c < d:
    if check(a, c) and check(b, d):
        print("Yes")
    else:
        print("No")
else: # c > d
    space = "..." in s[b-1:d+2]
    if space and check(a, c) and check(b, d):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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

def check(l, r):
    for i in range(l, r):
        if s[i] == '#' and s[i+1] == '#':
            return False

    return True

if c < d:
    if check(a, c) and check(b, d):
        print("Yes")
    else:
        print("No")
else: # c > d
    space = False

    for i in range(b, d+1):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            space = True
            break

    if space and check(a, c) and check(b, d):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
import sys
from collections import deque
sys.setrecursionlimit(100000)
input = sys.stdin.readline

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

def able(m, n, S):
    for i in range(m+1, n):
        if S[i] == '#' and S[i+1] == '#':
            return False
    return True

def able2(m, n, S):
    if not able(m, n, S):
        return False
    for i in range(m, n+1):
        if S[i] == '.' and S[i-1] == '.' and S[i+1] == '.':
            return True
    return False

if C>D:
    if able(A-1, C-1, S) and able2(B-1, D-1, S):
        print("Yes")
    else:
        print("No")
else:
    if able(A-1, C-1, S) and able(B-1, D-1, S):
        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 = list(input())

iwa2 = []
cnt = 0
for i in range(len(S)-1):
    if S[i] == S[i+1] == "#":
#         iwa2.append(1)
        cnt += 1
#     else:
#         iwa2.append(0)
    iwa2.append(cnt)
    
#長さ揃える
iwa2.append(cnt)        
        
def iwa2_check(s,g):
    if iwa2[s] < iwa2[g]:
        return True
    return False

# aki3は複数あったら、そのどれかに二人でたどり着ければ良い
aki3 = [0]
cnt = 0
for i in range(1,len(S)-1):
    if S[i-1] == S[i] == S[i+1] == ".":
        cnt += 1
    aki3.append(cnt)
aki3.append(cnt)

def aki3_check(B,CORD):
    # AさんがBさんと出会える（iwa2ない）
#     if not iwa2(A,B):
#         return False
    # Bさんがaki3にたどり着ける（最寄りの2つを見るだけで良い）
    # oBoのような状態でもOKなので-1
    if aki3[B-1] < aki3[CORD]:
        return True
    return False

# 順序が入れ替わらないとき
def solve():
    if iwa2_check(A,C) or iwa2_check(B,D):
#         print("1")
        return False
    if C<D:
#         print("2")
        return True
    else:
        if aki3_check(B, D):
#             print("3")
            return True
        else:
#             print("4")
            return False

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

Submission status: Accepted

Solution code:
nabcd = input().split()
n = int(nabcd[0])
a = int(nabcd[1])
b = int(nabcd[2])
c = int(nabcd[3])
d = int(nabcd[4])

course = input()

if '##' in course[a-1:c-1] or '##' in course[b-1:d-1]:
  print('No')

else:
  if c > d:
    if not '...' in course[b-2:d+1]:
      print('No')
    elif (not '...' in course[b-2:d-1]) and course[d-2]=='#':
      print('No')
    else:
      print('Yes')
  else:
    print('Yes')