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:
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, A, B, C, D = read_ints()
S = input()

A -= 1
B -= 1
C -= 1
D -= 1
# 大小関係の実装
plan = 1  # ひっくり返らない処理が1,ヒックリ変えるのが2、領域が二分割されるのが3

if D < C:
    plan = 2

if C < B:
    plan = 3

from sys import exit

# 入れ替わるかの条件ごとに実装する
if plan == 1:
    for s_left, s_right in zip(S[A:], S[A + 1:D]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()
    print('Yes')
elif plan == 2:
    # 入れ替わる場
    for s_left, s_right in zip(S[A:], S[A + 1:C]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()

    for s_left, s_center, s_right in zip(S[B-1:D], S[B:D+1], S[B+1:D+2]):
        if s_left == '.' and s_center == '.' and s_right == '.':
            print('Yes')
            exit()
    print('No')
elif plan == 3:
    # print(plan)
    # AC,BD間に##の存在を確かめれば良い
    for s_left, s_right in zip(S[A:], S[A+1:C]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()
    for s_left, s_right in zip(S[B:], S[B+1:D]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()
    print('Yes')

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10000)
mod = 1000000007


def mul(a, b):
    return ((a % mod) * (b % mod)) % mod


def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % mod
    elif y % 2 == 0:
        return power(x, y / 2) ** 2 % mod
    else:
        return power(x, y / 2) ** 2 * x % mod


def div(a, b):
    return mul(a, power(b, mod - 2))


# def gcd(a_gcd, b_gcd):
#     while b_gcd != 0:
#         a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
#     return a_gcd
#
#
# def lcm(a_lcm, b_lcm):
#     return a_lcm * b // gcd(a_lcm, b_lcm)
#
#
# def max_sum(N_max_sum, a_max_sum):
#     dp = [0] * (N_max_sum + 1)
#     for i in range(N_max_sum):
#         dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
#     return dp[N]
#
#
# def knapsack(N_knapsack, W, weight, value):
#     inf = float("inf")
#     dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
#     for i in range(W+1):
#         dp[0][i] = 0
#
#     for i in range(N_knapsack):
#         for w in range(W+1):
#             if weight[i] <= w:
#                 dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
#             else:
#                 dp[i+1][w] = dp[i][w]
#     return dp[N_knapsack][W]
#
#
# class UnionFind:
#     def __init__(self, n):
#         self.par = [i for i in range(n+1)]
#         self.rank = [0] * (n+1)
#
#     # 検索
#     def find(self, x):
#         if self.par[x] == x:
#             return x
#         else:
#             self.par[x] = self.find(self.par[x])
#             return self.par[x]
#
#     # 併合
#     def union(self, x, y):
#         x = self.find(x)
#         y = self.find(y)
#         if self.rank[x] < self.rank[y]:
#             self.par[x] = y
#         else:
#             self.par[y] = x
#             if self.rank[x] == self.rank[y]:
#                 self.rank[x] += 1
#
#     # 同じ集合に属するか判定
#     def same_check(self, x, y):
#         return self.find(x) == self.find(y)


# S = input()
# N = int(input())
# A = list(map(int, input().split()))
# X = [int(input()) for _ in range(N)]

N, A, B, C, D = map(int, input().split())
S = input()
block = "#"
ans = "Yes"
if C < D:
    for i in range(A, C):
        if S[i] == block:
            if S[i + 1] == block:
                ans = "No"
                break
    for i in range(B, D):
        if S[i] == block:
            if S[i + 1] == block:
                ans = "No"
                break
else:
    change_frag = False

    for i in range(A, C):
        # print(S[i])
        if S[i] == block:
            if S[i + 1] == block:
                ans = "No"
                break
    for i in range(B-1, D):
        #print(i+1, S[i])
        if S[i] == block:
            if S[i + 1] == block:
                ans = "No"
                break
        elif S[i-1] != block and S[i+1] != block:
                #print(i+1, S[i], "(●・▽・●)")
                change_frag = True

    if not change_frag:
        ans = "No"


print(ans)

Submission status: Accepted

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

if C < B:
    if S[A-1:C].find('##') < 0 and S[B-1:D].find('##') < 0: print 'Yes'
    else: print 'No'
elif C < D:
    if S[B-1:D].find('##') >= 0: print 'No'
    elif S[A-1:C].find('##') >= 0: print 'No'
    else:
        print 'Yes'
else:
    if S[B-1:D].find('##') >= 0: print 'No'
    else:
        if S[A-1:C].find('##') >= 0: print 'No'
        else:
            list_s = list(S)
            list_s[B-1] = '#'
            list_s_1 = list(S)
            list_s_1[D-1] = '#'
            S_1 = ''.join(list_s)
            S_2 = ''.join(list_s_1)
            if S_1[A-1:C].find('##') >= 0 and S_2[A-1:C].find('##') >= 0:
                if S[B-1:D].find('...') >= 0: print 'Yes'
                else: print 'No'
            else: print 'Yes'

Submission status: Accepted

Solution code:
I=lambda:map(int,input().split())
N,A,B,C,D=I()
S=input()
if C<D: #not cross
    f=True
    for i in range(A-1,C-1):
        if S[i]==S[i+1]=='#':f=False
    for i in range(B-1,D-1):
        if S[i]==S[i+1]=='#':f=False
    print('Yes' if f else 'No')
else:
    f=True
    akichi=False
    for i in range(B-1,D):
        if S[i-1]==S[i]==S[i+1]=='.':akichi=True
    f=True
    for i in range(A-1,C-1):
        if S[i]==S[i+1]=='#':f=False
    for i in range(B-1,D-1):
        if S[i]==S[i+1]=='#':f=False
    print('Yes' if f and akichi else 'No')

Submission status: Accepted

Solution code:
import numpy as np

N,A,B,C,D = list(map(int, input().split()))
S = input()
s = S
ans = "No"
if "##" in S[B : min([C, D])]:
    ans = "No"
else:
    if C < D:
        ans = "No"
        if not "##" in S[B:D]:
            if not "##" in S[A:C]:
                ans = "Yes"
    else:
        S = S[:C]
        s = S
        
        if not "##" in S[B:D]:
            S = S[:D-1] + "#" + S[D:]
            if not "##" in S[A:]:
                ans = "Yes"
            else:
                ans = "No"
        else:
            ans = "No"

        S = s
        if ans is "No":
            if "..." in S[B-2:D]:
                if not "##" in S[A:]:
                    S = S[:D]
                    if not "##" in S[B:]:
                        ans = "Yes"
                    else:
                        ans = "No"
                else:
                    ans = "No"        

print(ans)

Submission status: Accepted

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



N,A,B,C,D = map(int, input().split())
As = [A-1,C-1]
Bs = [B-1,D-1]
S = "#"+str(input())+"#"

ans = True
if "##" in S[Bs[0]+1:Bs[1]+2] or "##" in S[As[0]+1:As[1]+2]:
  ans = False
elif As[1] > Bs[1]:
  if "..." not in S[Bs[0]:Bs[1]+3]:
    ans = False

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

Submission status: Accepted

Solution code:
def check(b,d,path):
    seq = False
    for s in path[b:d]:
        if s == '#':
            if seq:
                return False
            else:
                seq = True
        else:
            seq = False  

    return True  


n,a,b,c,d = map( int, input().split() ) 
npath = input()
path = []
for s in npath:
    path.append(s)

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


ans = True
if c < d:
    ans = check(b,d,path) and check(a,c,path)
else:
    triple = 0
    for s in path[b-1:d+2]:
        if triple == 3:
            break
        if s == '#':
            triple = 0
        else:
            triple += 1

    if triple == 3:
        ans = check(a,d,path) and check(b,c,path)
    else:
        ans = False



if ans:
    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:max([C, D])]:
	print("No")
	exit()

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

print("Yes")

Submission status: Accepted

Solution code:
N,A,B,C,D=(int(x) for x in input().split())
S=input()
def Solve():
    if '##' in S[B-1:D] or '##' in S[A-1:C]:#道中に石が2つ並んでたらその時点でアウト
        return 'No'
    if C<D:
        return 'Yes'
    if '...' in S[B-1:D]:
        return 'Yes'
    if (D!=N and S[D]=='.' and S[D-2]=="." and S[D-1]==".") or (S[B-2]=='.' and S[B-1]=="." and S[B]=="."):
        return 'Yes'
    else:
        return 'No'
    

print(Solve())

Submission status: Accepted

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
if C<B and B<D:#パターンその1
    for i in range(A-1,C-1):
        if S[i] == '#' and S[i + 1] == '#':
            print('No')
            exit()
    for p in range(B-1,D-1):
        if S[p] == '#' and S[p + 1] == '#':
            print('No')
            exit()
    print('Yes')
    exit()
elif B<C and C<D:#パターンその2
    for i in range(A-1,D-1):
        if S[i]=='#' and S[i+1]=='#':
            print('No')
            exit()
    print('Yes')
    exit()
elif D<C:#パターンその3
    for j in range(A-1,C-1):
        if S[j]=='#' and S[j+1]=='#':
            print('No')
            exit()
    if any(S[k-1]=='.' and S[k]=='.' and S[k+1]=='.' for k in range(B-1,D)):
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np
# import math
# import random
# import fractions
# import sys
# sys.setrecursionlimit(100000)
# N = int(stdin.readline().rstrip().split()[0])
# A = [int(x) for x in stdin.readline().rstrip().split()]
# N, X = [int(x) for x in stdin.readline().rstrip().split()]
# S = stdin.readline().rstrip().split()[0]
N, A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip().split()[0]

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

stone = []
count=0
for i in range(N-1):
  if S[i]=="#" and S[i+1]=="#":
    count +=1
  stone.append(count)

def f(i, j):
  s = stone[j-1] - stone[i]
  if s==0:
    return True
  else:
    return False

if C < B:
  if f(A,C) and f(B,D):
    print("Yes")
  else:
    print("No")
elif C < D:
  if f(A,C) and f(B,D):
    print("Yes")
  else:
    print("No")
else:
  space = []
  count=0
  for i in range(N-2):
    if S[i]=="." and S[i+1]=="." and S[i+2]==".":
      count +=1
    space.append(count)
  
  s = space[D-1]-space[B-2]
  if s != 0:
    if f(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=input()
s=list(s)
s.append('#')
s.append('#')
out=0
ct=0
if c<d:
    for i in range(a-1,c):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    if out>0:print('No')
    else:print('Yes')
elif c>d:
    for i in range(a-1,c):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-2,d-1):
        if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
            #print('Yes')
            ct+=1
        
    if(out>0 or ct==0):print('No')
    else:print('Yes')

Submission status: Accepted

Solution code:
import numpy as np

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

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

Submission status: Accepted

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

if C < D:
	if D < N:
		if '##' in S[A-1:D]:
			print('No')
		else:
			print('Yes')
	else:
		if '##' in S[A-1:]:
			print('No')
		else:
			print('Yes')
else:
	if C < N:
		if '##' in S[A-1:C]:
			print('No')
			sys.exit()
	else:
		if '##' in S[A-1:]:
			print('No')
			sys.exit()
	if (S[D-2] == '.') & (S[D] == '.'):
		print('Yes')
	else:
		if '...' in S[B-2:D]:
			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()
s += '##'

def check(x,y):
    while x<y:
        if s[x+1]=='.':
            x += 1
        elif s[x+1]=='#':
            if s[x+2]=='#':
                return False
            x += 2
    if x==y:
        return True
    else:
        return False


def overtake(x,y):
    while x<n and y<n and x<y:
        if s[x+1] == '.' and y-x!=1:
            x += 1
        elif s[x+2] == '.' and y-x!=2:
            x += 2
        elif s[y+1] == '.':
            y += 1
        elif s[y+2] == '.':
            y += 2
        else:
            return None, None
    if y<x:
        return x,y
    else:
        return None,None
            
            
            

if c<d:
    if check(b,d) and check(a,c):
        print('Yes')
    else:
        print('No')
else:
    a, b = overtake(a,b)
    if a is None:
        print('No')
    elif check(b,d) and check(a,c):
        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:max(c,d)]:
  print('No')
elif c > d and "..." not in S[b-2:min(c,d)+1]:
  print('No')
else:
  print("Yes")

Submission status: Accepted

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

if '##' in S[A:C-1] or '##' in S[B:D-1]:
  ng=True
if (not ng) and (B<C and D<C):
  if '...' in S[B-1:D+1]: pass
  elif S[B-2:B+1]=='...' and A<=B-1: pass
  else: ng = True

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

Submission status: Accepted

Solution code:
N, A, B, C, D = map(int,input().split())
S = input()
# ふぬけ が すぬけ より前にいる
if C < D:
    S_cut = S[A-1:D]
    num = S_cut.count("##")
    # print(S_cut)
    if num > 0:
        print("No")
    else:
        print("Yes")
# すぬけ が ふぬけ より前にいる
else:
    S_cut1 = S[A-1:C]
    # 飛び越えられる
    flg1 = (S_cut1.count("##") == 0)
    S_cut2 = S[max(0,B-2):D+1]
    # S_cut2 = S[A-1:D+1]    
    # 抜く場所
    flg2 = (S_cut2.count("...")>=1)
    if flg1 and flg2:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
def q1():
    _, A, B, C, D = [int(x) - 1 for x in input().split(' ')]
    S = input()
    if "##" in S[A:D + 1]:
        return False
    if C < D:
        return True
    for b in range(B, D + 1):
        if S[b] == '#':
            continue
        if (S[b - 1] != "#" and S[b + 1] != "#"):
            return True
    return False

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

Submission status: Accepted

Solution code:
N, A, B, C, D = map(int, input().split())
 
S = input()
 
S = S + '#'
 
def continuous_rock_search(S, A, B, C, D):
    begin = min(A, B)
    target = max(C, D)
    for i in range(begin, target - 1):
        if S[i] == '#' and S[i+1] == '#':
            return True
    return False
  
def validation_funuke_move(S, B, D):
    '''
    ふぬけ君が両隣に岩がなくなるまで移動したとき、Dより向こうにはイカないことを確認する。
    True/False and ふぬけの移動後の位置
    '''
    funuke_position = B
    while (B <= D):
        if (S[B-2] == '#' or S[B] == '#'):
            if S[B] == '.' :
                B = B + 1
            else:
                B = B + 2
        elif (S[B-2] == '.' and S[B] == '.'):
            return True, B
    
    return False, -1
  
def KenKenRace(S, A, B, C, D):
    if continuous_rock_search(S, A, B, C, D):
        return False
    
    if C < D:
        return True
    
    if D < C:
        valid , _ = validation_funuke_move(S, B, D)
        if valid:
            return True
        else:
            return False
          
if KenKenRace(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()
State = "Yes"
for i in range(B-1,D-1):
    if s[i] == "#" and s[i+1] == "#":
        State = "No"
        break
if C < D:
    for i in range(A-1,C-1):
        if s[i] == "#" and s[i+1] == "#":
            State = "No"
            break
elif State == "Yes":
    State = "No"
    for i in range(B-2,D-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            State = "Yes"
            break
    for i in range(D-1,C-1):
        if s[i] == "#" and s[i+1] == "#":
            State = "No"
            break
    for i in range(A-1,B-1):
        if s[i] == "#" and s[i+1] == "#":
            State = "No"
            break
print(State)

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')
else:
    if C > D:
        if '...' in s[B-2:D+1]:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Accepted

Solution code:
import sys

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

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


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

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

Submission status: Accepted

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

# dのほうがとおい
if c < d:
  # acbd
  if c < b:
    for i in range(a, c-1):
      if s[i+1] == '#' and s[i+2] == '#':
        print("No")
        exit()
    for i in range(b, d-1):
      if s[i+1] == '#' and s[i+2] == '#':
        print("No")
        exit()
  # abcd      
  else:
    for i in range(b, d-1):
        if s[i+1] == '#' and s[i+2] == '#':
            print("No")
            exit()
    for i in range(a, c-1):
        if s[i+1] == '#' and s[i+2] == '#':
            print("No")
            exit()
  print("Yes")
  
# abdc
else:
  #まず全部確認
  for i in range(a, c-1):
    if s[i+1] == '#' and s[i+2] == '#':
      print("No")
      exit()
  #bd間を確認
  for i in range(b, d+1):
    if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
      print("Yes")
      exit()
  print("No")
  exit()

Submission status: Accepted

Solution code:
n, a, b, c, d = [int(item) for item in input().strip().split(" ")]
s = input().strip()

def h(a,b,c,d,s):
    if "##" in s[a-1:c]:
        return False
    if "##" in s[b-1:d]:
        return False
    if c < d:
        return True
    if "..." in s[b-2:d+1]:
        return True
    return False

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

Submission status: Accepted

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

a -= 1
b -= 1
c -= 1
d -= 1
is_arrive = True
for i in range(len(s)-1):
  if s[i]+s[i+1] == '##':
    if a < i < c-1:
      is_arrive = False
      break
    elif b < i < d-1:
      is_arrive = False
      break

if is_arrive:
  if (a < b and c < d) or (a > b and c > d):
    print('Yes')
  else:
    if c < d:
      while b < d:
        if s[b + 1] == '#':
          if b + 2 == a:
            if s[a + 1] == '#':
              a += 2
              b += 2
            else:
              a += 1
              b += 2
          else:
            b += 2
        elif s[b + 2] == '#':
          if b + 1 == a:
            a += 2
            b += 1
          else:
            b += 1
        elif b + 1 == a:
          if s[a + 1] == '#':
            a += 2
            b += 1
          else:
            b += 2
        else:
          b += 1
      if a > c:
        print('No')
      else:
        print('Yes')
    elif d < c:
      while a < c:
        if s[a + 1] == '#':
          if a + 2 == b:
            if s[b + 1] == '#':
              b += 2
              a += 2
            else:
              b += 1
              a += 2
          else:
            a += 2
        elif s[a + 2] == '#':
          if a + 1 == b:
            b += 2
            a += 1
          else:
            a += 1
        elif a + 1 == b:
          if s[b + 1] == '#':
            b += 2
            a += 1
          else:
            a += 2
        else:
          a += 1
      if b > d:
        print('No')
      else:
        print('Yes')
else:
  print('No')

Submission status: Accepted

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

Sstr=input()


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

print(ans)

Submission status: Accepted

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

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

#飛び越える
if(D<C):
    changable = 0
    for i in range(B-2, D-1):
        if S[i]=="." and S[i+1]=="." and S[i+2]==".":
            changable=1
            break
    if(changable==0):
        jumpable=0

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

Submission status: Accepted

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

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    if C < D:
        flag_d = False
        for i in range(A+1, D-1):
            if S[i:i+2] == '##':
                flag_d = True
                break

        if flag_d:
            print(NO)
        else:
            print(YES)


    elif D < C:
        flag_d = False
        for i in range(A+1, C-1):
            if S[i:i+2] == '##':
                flag_d = True
                break

        flag_c = False
        for i in range(B-2, D-2):
            if S[i:i+3] == '...':
                flag_c = True
                break

        if flag_d:
            print(NO)
        else:
            if flag_c:
                print(YES)
            elif S[D-2] != '#' and S[D] != '#':
                print(YES)
            else:
                print(NO)


    else:
        raise NotImplementedError





    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

flag = True
isSharp = False
for i in range(A, max(C, D)):
    if S[i] == '#':
        if isSharp is False:
            isSharp = True
        else:
            flag = False
            break
    else:
        isSharp = False

if D < C:
    cnt = 0
    isCons = False
    for i in range(B-2, D+1):
        if S[i] == '.':
            cnt += 1
            if cnt == 3:
                isCons = True
                break
        else:
            cnt = 0
    if isCons is False:
        flag = False

if flag is True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

ref = 1

if C < D:
    for i in range(B+1, D-1):
        if S[i]=='#' and S[i+1]=='#':
            ref = 0
            break
        else:
            continue

    for j in range(A+1, C-1):
        if S[j]=='#' and S[j+1]=='#':
            ref = 0
            break
        else:
            continue

    if ref == 1:
        print('Yes')
    else:
        print('No')
        
else:
    ref = 0
    for i in range(B, D+1):
        if S[i-1]=='.' and S[i]=='.' and S[i+1]=='.' : 
            ref = 1
            break
        else:
            ref = 0
    for j in range(A+1, C-1):
        if S[j]=='#' and S[j+1]=='#':
            ref = 0
            break
        else:
            continue
    if ref == 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 B<C:
    d=0
    if "##" in S[A-1:D]:
      d=1
    print("Yes" if d==0 else "No")
  else:
    d=0
    if "##" in S[A-1:C]:
      d=1
    if "##" in S[B-1:D]:
      d=1
    print("Yes" if d==0 else "No") 
else:
  d=0
  if "##" in S[A-1:C]:
    d=1
  if "..." not in S[B-2:D+1]:
    d=1
  print("Yes" if d==0 else "No")

Submission status: Accepted

Solution code:
import sys

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

lst = [0] * (n+1)
for i in range(1, n+1):
    if s[i-1] == '#':
        lst[i] = 1

if c < d:
    stone = 0
    for i in range(b+1, d+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    stone = 0
    for i in range(a+1, c+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    print('Yes')
else:
    brank = 0
    three = 0
    for i in range(b-1, c+1):
        if lst[i] == 0:
            brank += 1
            if brank == 3:
                if i-1 <= d:
                    three = 1
                    break
                else:
                    print('No')
                    sys.exit()
        else:
            brank = 0
    if three == 0:
        print('No')
        sys.exit()
    stone = 0
    for i in range(b+1, d+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    stone = 0
    for i in range(a+1, c+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    print('Yes')

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<b:
  if s[a:c].find("##")==-1 and s[b:d].find("##")==-1:
    print("Yes")
  else:
    print("No")
elif s[a:d].find("##")==-1:
  if c<d:
    print("Yes")
  else:
    if s[b-1:d+2].find("...")==-1:
      print("No")
    else:
      print("Yes")
else:
  print("No")