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:
import sys
n, a, b, c, d = map(int,input().split())
s = input()
judgesharp = False
judgepass = False
threepoint = 0
count = 0
a -= 1
b -= 1
c -= 1
d -= 1
if c < d:
  for i in s:
    if count < a or count > d:
      pass
    elif i == "#":
      if judgesharp == True:
        print("No")
        sys.exit()
      else:
        judgesharp = True
    else:
      judgesharp = False
    count += 1
  print("Yes")
else:
  for i in s:
    if count < a or count > c:
      pass
    elif i == "#":
      threepoint = 0
      if judgesharp == True:
        print("No")
        sys.exit()
      else:
        judgesharp = True
    else:
      if b-1 <= count and count <= d+1:
        threepoint += 1
      judgesharp = False
    if threepoint == 3:
      judgepass = True
    count += 1
  if judgepass:
    print("Yes")
  else:
    print("No")

Submission status: Accepted

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

def judge(start,goal):
    for i in range(start,goal-1):
        if s[i] == "#" and s[i+1] == "#":
            return 0
    return 1

def full_judge (start,obst,obfin,goal):
    if s[obst-2] == "." and s[obst] == "." :
        return 1
    for i in range(obst-1,obfin-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            return 1
    return 0


if c<b:
    if (judge(a,c) and judge(b,d)):
        print("Yes")
    else:
        print("No")
elif c<d:
    if (judge(a,c) and judge(b,d)):
        print("Yes")
    else:
        print("No")
else:
    if judge(b,d) and full_judge(a,b,d,c) and judge(a,c):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
import sys
from collections import deque
from collections import defaultdict
import math
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline
 
n,a,b,c,d = map(int,input().split())
a-=1;b-=1;c-=1;d-=1
s = input()
if (a < b and c<d):
        if  "##" in s[a:c+1]:
                print("No")
                exit()
        if   "##" in s[b:d+1]:
                print("No")
                exit()
        print("Yes")
else:
        if  "##" in s[a:c+1]:
                print("No")
                exit()
        if   "##" in s[b:d+1]:
                print("No")
                exit()
        if  "..." in s[b-1:d+2]:
                print("Yes")
                exit()
        print("No")

Submission status: Accepted

Solution code:
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
n, a, b, c, d  = map(int, input().split())
a = a-1
b = b-1
c = c-1
d = d-1
s2 = input()
s = list(s2)

if '...' in s2[(b-1):(d+1)] and not ('##' in s2[a:c]):
    print('Yes')
    exit()


if all(s[i] == '.' or s[i+1] == '.' for i in range(b,d)):
    s[d] = '#'
    if all(s[i] == '.' or s[i+1] == '.' for i in range(a,c)):
        print('Yes')
        exit()

print('No')

Submission status: Accepted

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

rock=0
blank=0
for i in range(a,c):
    if path[i-1]=='#' and path[i]=='#':
        rock=1
for i in range(b,d):
    if path[i-1]=='#' and path[i]=='#':
        rock=1

for i in range(max(a,b),min(c,d)+1):
    if path[i-2]=='.' and path[i-1]=='.' and path[i]=='.':
        blank=1

if rock==0 and ((a-b)*(c-d)>0 or (blank==1 and (a-b)*(c-d)<0)):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD=10**9+7

N,A,B,C,D=rl()
S=input()
M=[0]*(N+1)
for i in range(N):
    M[i] = 0 if S[i]=='.' else 1

ans = 1

flag_2 = 0
cnt = 0
for i in range(A-1,D):
    if M[i] == 1:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 2:
        flag_2 = 1
        break
if flag_2==1:
    ans = 0

flag_3 = 0
cnt = 0
if C > D:
    for i in range(B-2,D+1):
        if M[i] == 0:
            cnt += 1
        else:
            cnt = 0
        if cnt>=3:
            flag_3 = 1
            break
    if flag_3 == 0:
        ans = 0

yn(ans)

Submission status: Accepted

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

if C < D:
    lst = []
    for i in range(N-1):
        if S[i] == '#' and S[i+1] =='#': #岩が連続である場所
            if (A-1 <= i and i <= C-1) or (B-1 <= i and i <= D-1):
                print ('No')
                sys.exit()
    print ('Yes')
    sys.exit()
        
if C > D:
    flag1 = False
    lst = []
    for i in range(1,N-1): 
        if S[i] == '#' and S[i+1] =='#': #岩が連続である場所が一つでもあればダメ
            if (A-1 <= i and i <= C-1) or (B-1 <= i and i <= D-1):
                print ('No')
                sys.exit()
        if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.' and B-1 <= i and i <= D-1: #3個以上連続になっているBの避難スペースがあるかどうか
            flag1 = True


if flag1:
    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()
m=[0 for i in range(n)]
#a-c,b-d
#abcd
#abdc
for i in range(n):
  if s[i]=="#":
    m[i]=1
if c<d:#abcd
  if "##" in s[a:d]:
    print("No")
  else:
    print("Yes")
else:#d<c abdc
  if "##" in s[a:c]:
    print("No")
  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()

c_swap = True 
# 飛び越し条件整理
if C > D:
    # 飛び越せるか
    if "..." in S[B-2:min(C, D+1)]:
        reset = S.find("...") + 1
        A = reset + 1
        B = reset + 2
    else:
        c_swap = False
    
# funukeとDの間に##がないかチェック
is_f_ok = "##" not in S[B-1:D]

# sunukeとCの間に##がないかチェック
is_s_ok = "##" not in S[A-1:C]

print("Yes") if (is_f_ok & is_s_ok & c_swap) else print("No")

Submission status: Accepted

Solution code:

n, a, b, c, d = map(int, input().split())
s = "#"+input()
#print(s)

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

Submission status: Accepted

Solution code:
N,A,B,C,D = map(int, raw_input().split())
S = raw_input()
i = 1
flagskip = 0
flagskip2 = 0
flagerror = 0
flags = 0
flagstop = 0
flagstop2 = 0
for c in S:
	if(flagstop2 == 1):
		if(c =='#'):
			flagstop += 1
		flagstop2 = 0
	if(i <= A):
		i += 1
		continue
	elif(i == B or (i == D and D < C)):
		if(flags == 1):
			flagstop += 1
		else:
			flagstop2 = 1
	if(c == '#'):
		if(flags == 1):
			flagerror = 1
			break
		flags = 1
		flagskip2 = 0
	else:
		if(flagskip2 == 1):
			flagskip = 1
		elif(flags == 0 and flagskip == 0 and i > B-1 and i < D+1):
			flagskip2 = 1
		flags = 0
	if(i == max(C,D)):
		break
	i += 1
if(flagstop == 2 and flagskip == 0):
	flagerror = 1
if(flagerror == 0):
	print("Yes")
else:
	print("No")

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

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

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

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

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

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

Submission status: Accepted

Solution code:
N, A, B, C, D = list(map(int, input().split()))
S = input()
X = [".", "#"]
Ans = ["Yes", "No"]

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

f = 0
if A < B:
  if B < C and D < C:
    f = 1

a, b = A, C
s = 0
for i in range(a, b + 1):
  if S[i] == X[1]:
    if s == 1:
      print(Ans[1])
      exit()
    s = 1
  else:
    s = 0

a, b = B, D
s = 0
for i in range(a, b + 1):
  if S[i] == X[1]:
    if s == 1:
      print(Ans[1])
      exit()
    s = 1
  else:
    s = 0

if f == 0:
  print(Ans[0])
  exit()

s = 0
for i in range(B - 1, min(D + 2, N)):
  if S[i] == X[1]:
    if s == 1:
      break
    else:
      s = 1
  else:
    if s == 1:
      s = -1
    else:
      s -= 1
      if s == -3:
        print(Ans[0])
        exit()

print(Ans[1])

Submission status: Accepted

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

s = input()

for i in range(A + 1, C - 2 + 1):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        exit()
for i in range(B + 1, D - 2 + 1):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        exit()

if A < C < B < D:
    # ふぬけとすぬけは独立
    # 先にふぬけ(B,D)から処理
    print('Yes')
    exit()
elif A < B < C < D:
    # ふぬけから移動させる
    print('Yes')
    exit()
else:
    # A < B < D < C:
    # すぬけから移動させる
    # 3連続空欄が必要で
    # boo
    # obo
    # ならOK
    # oDoまでOKで、ooDはダメ
    for i in range(B - 1, D - 1 + 1):
        # 連続3マスの起点マス
        if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
            print('Yes')
            exit()
print('No')

Submission status: Accepted

Solution code:
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,A,B,C,D = Is()
s = S()
if "##" in s[A-1:C] or "##" in s[B-1:D]:
    print("No")
elif C < D:
    print("Yes")
elif C > D:
    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())

S = [1] + [ 1 if x == "#" else 0 for x in input()]

S[A] = 2
S[B] = 3


if B < A:
    A, B = B, A
    C, D = D, C

enable = True

for i in range(min(A, B)+1, max(C, D)-1):
    if S[i] == S[i+1] == 1:
        enable = False
        break

if A < B < D < C:
    vcnt = 0
    for i in range(B-1, D+1+1):
        if S[i] != 1:
            vcnt += 1
            if vcnt >= 3:
                break
        else:
            vcnt = 0
    else:
        enable = False

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

Submission status: Accepted

Solution code:
n,a,b,c,d=map(lambda x: int(x)-1,input().split())
n+=1
s=input()

def check(x,y,s): #O(n)
    if '##' in s[x:y+1]:
        return False
    return True

def solve():
    if c<d:
        return check(a,c,s) and check(b,d,s)
    t=list(s)
    t[b]='#'
    t=''.join(t)
    if check(a,c,t):
        return check(b,d,s)
    if c>d+1:
        if '...' in s[b:d+2]:
            return check(a,b,s)
    else:
        if '...' in s[b:d+1]:
            return check(a,b,s)
    
print('Yes' if solve() else 'No')

Submission status: Accepted

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,A,B,C,D=MAP()
S='#'+input()+'#'

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

Submission status: Accepted

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

flag = 0

if D > C:
    for i in range(D-B-2):
        if S[B+i] == '#' and S[B+i+1] == '#':
            print('No')
            flag = 1
            break
    if flag == 0:
        for j in range(C-A-2):
            if S[A+j] == '#' and S[A+j+1] == '#':
                print('No')
                flag = 1
                break        
        if flag == 0:
            print('Yes')
else:
    count = 0
    for i in range(D-B+3):
        if S[B-2+i] == '.':
            count += 1
        else:
            count = 0
        if count == 3:
            flag = 1
            break
    if flag == 0:
        print('No')
    else:
        for j in range(C-A-2):
            if S[A+j] == '#' and S[A+j+1] == '#':
                print('No')
                flag = 0
                break        
        if flag == 1:
            print('Yes')

Submission status: Accepted

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

lbound = min(a, b) - 1

if "##" in s[a - 1 : c] or "##" in s[b - 1 : d]:
    print("No")
elif ((a > b) ^ (c > d)) and "..." not in s[max(a, b) - 2 : min(c, d) + 1]:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
def getlist():
	return map(int, input().split())

N, A, B, C, D = getlist()
S = list(input())

a = A - 1
b = B - 1
c = C - 1
d = D - 1

if c < b:
	judge1 = "YES"
	j = 0
	val = 0
	for i in range(a, c):
		if S[i] == ".":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j >= 2:
		judge1 = "NO"

	judge2 = "YES"
	j = 0
	val = 0
	for i in range(b, d):
		if S[i] == ".":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j >= 2:
		judge2 = "NO"

	if judge1 == "YES" and judge2 == "YES":
		print("Yes")
	else:
		print("No")


elif c < d:
	judge = "Yes"
	j = 0
	val = 0
	for i in range(a, d):
		if S[i] == ".":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j >= 2:
		judge = "No"
	print(judge)

else:
	judge1 = "YES"
	j = 0
	val = 0
	for i in range(a, c):
		if S[i] == ".":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j >= 2:
		judge1 = "NO"

	judge2 = "YES"
	j = 0
	val = 0
	for i in range(b - 1, d + 2):
		if S[i] == "#":
			val = 0
		else:
			val += 1
			if val > j:
				j = val
	if j <= 2:
		judge2 = "NO"

	if judge1 == "YES" and judge2 == "YES":
		print("Yes")
	else:
		print("No")

Submission status: Accepted

Solution code:
import bisect
from operator import itemgetter
import math
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,sunke,hunke,Gs,Gh = IL()
s = S()

f = 0
for i in range(sunke-1,max(Gs,Gh)):
    if f == 0:
        if s[i]=="#":
            f = 1
    else:
        if s[i]=="#":
            print("No")
            exit()
        else:
            f = 0

cnt = 0
cntf = 0
for i in range(hunke-2,min(Gs,Gh)+1):
    if s[i]=="#":
        cnt = 0
    else:
        cnt += 1
    if cnt == 3:
        cntf = 1
        break

if (sunke < hunke) and (Gs > Gh):
    if cntf == 1:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
# coding:utf-8

import math

def main():
    n,a,b,c,d = map(int, raw_input().split())
    s = list(raw_input())
    chk = True
    cnt = 1
    hurdleA = 0
    hurdleB = 0
    three = 0
    threeChk = False
    for i in s:
        if cnt >= b-1 and cnt <= d+1:
            if i == '.':
                three += 1
            else:
                three = 0
            if three >= 3:
                threeChk = True
        if cnt > a and cnt < c:
            if i == '#':
                hurdleA += 1
            else:
                hurdleA = 0
            if hurdleA >= 2:
                chk = False
                break
        if cnt > b and cnt < d:
            if i == '#':
                hurdleB += 1
            else:
                hurdleB = 0
            if hurdleB >= 2:
                chk = False
                break
        cnt += 1
    if c > d and (s[d-2] == '#' or s[d] == '#') and threeChk == False:
        print "No"
    elif chk == False:
        print "No"
    else:
        print "Yes"

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

s_list = [c for c in s]

def check(start, end , s):
    kukan = "".join(s_list[start - 1 : end])
    if "##" in kukan:
        return False
    if kukan[0] == "#" or kukan[-1] == "#":
        return False
    return True

def check2(start, end, s):
    kukan = "".join(s_list[start - 1 : end])
    if "..." in kukan:
        return True
    else:
        return False

ans = check(a, c, s) and check(b, d, s)

if c > d:
    ans = ans and check2(b - 1, d + 1, s)

if ans:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,a,b,c,d = f()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = input()

    has_2_consecu = 0
    for i in range(a+1, max(c,d)-1):
        if s[i]=='#' and s[i+1] == '#':
            has_2_consecu = 1
            break



    if has_2_consecu:
        print('No')
        return

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




solve()

Submission status: Accepted

Solution code:
def has_path(start, goal):
    for step in range(start, goal):
        if (not isRoad[step]) and (not isRoad[step-1]):
            return False
    return True


N, A, B, C, D = map(int, input().split())
S = input()
isRoad = [True if c == "." else False for c in S]

if C <= B:      # すぬけ・ふぬけの二人が独立になっているとき
    if has_path(A, C) and has_path(B, D):
        print("Yes")
    else:
        print("No")
    exit()
elif C < D:    # ふぬけを動かしてからすぬけを動かせば良いとき
    if has_path(A, C) and has_path(B, D):
        print("Yes")
    else:
        print("No")
    exit()
else:       # どこかでふぬけがすぬけを追い越さなければいけない場合
    for i in range(B - 1, D):   # 追い抜く場所があるかどうかを探索
        if isRoad[i - 1] and isRoad[i] and isRoad[i + 1]:
            print("Yes")
            exit()
    print("No")

Submission status: Accepted

Solution code:
import numpy as np

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

reachable_C = np.full(N+2, False, np.bool)
reachable_D = np.full(N+2, False, np.bool)

reachable_C[C] = True
reachable_D[D] = True

for i in range(N)[::-1]:
	if S[i] == '#':
		continue
	
	if reachable_C[i+1] or reachable_C[i+2]:
		reachable_C[i] = True
	if reachable_D[i+1] or reachable_D[i+2]:
		reachable_D[i] = True

l = max(A, B)
r = min(C, D) + 1

print('Yes'
	if reachable_C[A]
		and reachable_D[B]
		and (
			(A < B and C < D or B < A and D < C)
			or "..." in S[l-1:r+1])
	else 'No')

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

if not(S[A:C-1].find('##')!=-1 or S[B:D-1].find('##')!=-1):
  if C<D:
    print('Yes')
  elif S[B-2:D+1].find('...')!=-1:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Accepted

Solution code:
# 1.A_C間,B_D間に##となっているマスがないこと
# 2.D>CまたはDの周辺に#がないまたはB_D間に...があること
n, a, b, c, d = map(int, input().split())
s = " " + input()
Triple_floor = False
before_stat = ""
floor_num = 0
counter = a
for char in s[a:]:
    if(counter > max(c,d)):
        # この先はどうでもいい.
        break
    if(char == "."):
        floor_num += 1
        if(floor_num >= 3 and counter >= (b+1) and counter <= (d+1)):
            Triple_floor = True
    else:
        floor_num = 0
        if(before_stat == "#"):
            c=d
            Triple_floor = False
            break
    before_stat = char
    counter += 1
if(c<d or Triple_floor):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split())
L=input()[a-1:max(c,d)]
f=0
r="."
for i in list(L):
  if r=="#" and i=="#":
    f=1
    break
  r=i

if c < d:
  print('No' if f==1 else 'Yes')
else:
  g=0
  t="#"
  s="#"
  for i in range(b-1,d):
    if L[i-1:i+2]=="...":
      g=1
      break
    s=i
  print('No' if f==1 or g==0 else 'Yes')

Submission status: Accepted

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

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

Submission status: Accepted

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

def check_movable(s):
    cnt = 0
    for v in s:
        if v == '#':
            cnt += 1
        elif v == '.':
            cnt = 0
        if cnt >= 2:
            return False
    return True
def check_throughable(s):
    cnt = 0
    for v in s:
        if v == '.':
            cnt += 1
        elif v == '#':
            cnt = 0
        if cnt >= 3:
            return True
    return False
if C < B:
    if check_movable(S[B:D]) and check_movable(S[A:C]):
        print('Yes')
    else:
        print('No')
elif C < D:
    if check_movable(S[B:D]) and check_movable(S[A:B]):
        print('Yes')
    else:
        print('No')
else:
    if check_throughable(S[B-2:D+1]) and check_movable(S[A:C]):
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
N, A, B, C, D = map(int, input().split())
S = '.' + input()
ans = True
if C > D:
  s = B - 1
  while s < D:
    if S[s] == '#':
      _s = s + 1
    elif S[s + 1] == '#':
      _s = s + 2
    elif S[s + 2] == '#':
      _s = s + 3
    else:
      break
    s = _s
  if s >= D:
    ans = False
s = A + 1
while s < C:
  if S[s] != '#':
    _s = s + 1
  elif S[s + 1] != '#':
    _s = s + 2
  else:
    ans = False
    break
  s = _s
s = B + 1
while s < D:
  if S[s] != '#':
    _s = s + 1
  elif S[s + 1] != '#':
    _s = s + 2
  else:
    ans = False
    break
  s = _s
print('Yes' if ans else 'No')

Submission status: Accepted

Solution code:
import re
N, A, B, C, D = map(int, input().split())
S = input().replace('.', 'x')

if C < D:
    if len(re.findall('##', S[A:C])) != 0:
        print('No')
    elif len(re.findall('##', S[B:D])) != 0:
        print('No')
    else:
        print('Yes')
else:
    if len(re.findall('##', S[A:C])) != 0:
        print('No')
    elif len(re.findall('xxx', S[B - 2:D + 1])) == 0:
        print('No')
    else:
        print('Yes')

Submission status: Accepted

Solution code:
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N, A, B, C, D = [ int(x) for x in input().split() ]
A -= 1
B -= 1
C -= 1
D -= 1
S = input() + "#"

A_blocker = False
B_blocker = False
pass_point = False

A_load = S[A:C+1]
B_load = S[B:D+1]
pass_load = S[B-1:D+2]
if '##' in A_load:
    A_blocker = True
if '##' in B_load:
    B_blocker = True
if '...' in pass_load:
    pass_point = True

if D < C:
    if (not A_blocker) and (not B_blocker) and pass_point:
        print ("Yes")
    else:
        print ("No")
else:
    if (not A_blocker) and (not B_blocker):
        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 "##" in s[a:d]:
        print("No")
    else:
        print("Yes")
else:
    if "##" in s[a:c]:
        print("No")
    elif "..." 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 = list(input())
a = a-1
b = b-1
c = c-1
d = d-1
s[a] = "A"
s[b] = "B"
ans = True
flag = 0

while a<n and b<n:
  while a<b:
    if a==c:
      break
    elif a+1<n and a+1<b and s[a+1]==".":
      s[a] = "."
      s[a+1] = "A"
      a += 1
    elif a+2<n and a+2<b and s[a+2]==".":
      s[a] = "."
      s[a+2] = "A"
      a += 2
    else:
      break

  if a+2<n and d<c and s[a+1]=="B" and s[a+2]==".":
    s[a] = "."
    s[a+2] = "A"
    a += 2

  if b<a:
    while a<n:
      if a==c:
        break
      elif a+1<n and s[a+1]==".":
        s[a] = "."
        s[a+1] = "A"
        a += 1
      elif a+2<n and s[a+2]==".":
        s[a] = "."
        s[a+2] = "A"
        a += 2
      else:
        ans = False
        break

  if a==c and b==d:
    break
  elif b+1<n and s[b+1]==".":
    s[b] = "."
    s[b+1] = "B"
    b += 1
  elif b+2<n and s[b+2]==".":
    s[b] = "."
    s[b+2] = "B"
    b += 2
  else:
    ans = False
    break

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun  2 20:30:09 2019

@author: Yamazaki Kenichi
"""
import sys

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

if S[A] == '#' or S[B] == '#' or S[C] == '#' or S[D] == '#':
    print('No')
    sys.exit()

goal = True
previous = True
jump = False
for i in range(A + 1, max(C+1,D+1)):
    if S[i] == '.':
        True
    elif S[i-1] == '#' and S[i] == '#':
        goal = False
    if i >= B and i <= D and i != max(C,D):
        if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.':
            jump = True
#            print(i,previous, S[i] == '.', S[i+1])
#    print(i,previous)
if C > D:
    if not jump:
        print('No')
        sys.exit()
if goal:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:


from math import *

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

s=input()


flg=0


for i in range(b,d):
	if(s[i]=='#' and s[i-1]==s[i]):
		flg=1

for i in range(a,c):
	if(s[i]=='#' and s[i-1]==s[i]):
		flg=1

if(c>d):
	ff=1
	for i in range(b,d+1):
		if(s[i]=='.' and s[i-1]=='.' and s[i-2]=='.'):
			ff=0

	if(ff):
		flg=1

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

Submission status: Accepted

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

if S[A-1:max(C,D)].count('##') > 0:
    print('No')
else:
    if C < D:
        print('Yes')
    else:
        if S[B-2:D+1].count('...') > 0:
            print('Yes')
        else:
            print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

a-=1
b-=1
c-=1
d-=1
if d>c:
    dp = [False]*(n+3)
    dp[d] = True
    for i in range(d-1,-1,-1):
        if s[i] == '#':
            continue
        if dp[i+1] or dp[i+2]:
            dp[i] = True
    
    cp = [False]*(n+3)
    cp[c] = True
    for i in range(c-1,-1,-1):
        if s[i] == '#':
            continue
        if cp[i+1] or cp[i+2]:
            cp[i] = True
    if cp[a] and dp[b]:
        print('Yes')
    else:
        print('No')
else:
    dp = [False]*(n+3)
    dp[d] = True
    for i in range(d-1,-1,-1):
        if s[i] == '#':
            continue
        if dp[i+1] or dp[i+2]:
            dp[i] = True
    
    cp = [False]*(n+3)
    cp[c] = True
    for i in range(c-1,-1,-1):
        if s[i] == '#':
            continue
        if cp[i+1] or cp[i+2]:
            cp[i] = True
    

    res = 0
    cnt = 0
    for i in range(b-1,d+2):
        if s[i] == '.':
            cnt += 1
        else:
            res = max(cnt,res)
            cnt = 0
    res = max(res,cnt)
    if cp[a] and dp[b] and res >= 3:
        print('Yes')
    else:
        print('No')