Problem:


Score : 400 points

Problem Statement

There are N squares arranged in a row, numbered 1, 2, ..., N from left to right.
You are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.

In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.

You can repeat the following operation any number of times:

Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.

You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.

Determine whether this is possible.

Constraints

4 \leq N \leq 200\ 000

S is a string of length N consisting of . and #.

1 \leq A, B, C, D \leq N

Square A, B, C and D do not contain a rock.

A, B, C and D are all different.

A < B

A < C

B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

Print Yes if the objective is achievable, and No if it is not.

Sample Input 1

7 1 3 6 7
.#..#..

Sample Output 1

Yes

The objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)

A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB

Sample Input 2

7 1 3 7 6
.#..#..

Sample Output 2

No

Sample Input 3

15 1 3 15 13
...#.#...#.#...

Sample Output 3

Yes



Sample input:
7 1 3 6 7
.#..#..


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
if A < B:
    minS = A
    minG = C
    maxS = B
    maxG = D
else:
    maxS = A
    maxG = C
    minS = B
    minG = D

if "##" in S[minS : max(maxG, minG)]:
    print("No")
    exit()

# スタートが左側でゴールが右
if minS < maxS and minG == max(maxG, minG):
    # 途中で飛び越え必須
    if "..." not in S[minS: max(maxG, minG)]:
        print("No")
        exit()
    # OKでも、maxSが岩の前後の場合注意
    elif S[maxS - 1] == "#" or S[maxS + 1] == "#":
        # その場合maxS以降に3空きがあればOK
        if "..." not in S[maxS: max(maxG, minG)]:
            print("No")
            exit()

# スタート左、ゴールも左 -> 右側に先にゴールしてもらう
# スタート右、ゴールは左 -> スタートが左側でゴールが右

print("Yes")

Submission status: Wrong Answer

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

# 間に＃が連続していなければ通るはず

print(S[B-1:D-1])

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

Submission status: Wrong Answer

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

if '#' not in s:
    print('Yes')
# elif '#.#' in s and a < s.index('#.#') and s.index('#.#') < c:
#     print('No')
# elif '#.#' in s and b < s.index('#.#') and s.index('#.#') < d:
#     print('No')
# elif '#..#' in s and a < b and c > d:
#     print('No')
# elif '#..#' in s and a > b and c < d:
#     print('No')
elif '...' in s:
    print('Yes')
elif c < d:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
number_of_masu, firstsunuke, firstfunuke, lastsunuke, lastfunuke = map(int, input().split())
s = str(input())
tobenaiflag = 0
nukaseruflag = 0

for i in range(firstsunuke, lastsunuke-2):
    if s[i] == '#' and s[i+1] == '#':
        tobenaiflag += 1
        break
for k in range(firstfunuke, lastfunuke-2):
    if s[k] == '#' and s[k+1] == '#':
        tobenaiflag += 1
        break
if lastfunuke < lastsunuke:
    for j in range(max(firstsunuke, firstfunuke)-2, min(lastsunuke, lastfunuke)-1-1):
        if s[j] == '.' and s[j+1] == '.' and s[j+2] == '.':
            nukaseruflag += 1
            break
else:
    nukaseruflag += 1
if tobenaiflag == 0 and nukaseruflag == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

import sys

N, A, B, C, D = map(int, input().rstrip().split())
S = [x for x in input()]

if A < B and B < D and D < C:
    chain_rock = 0
    if S[B-2] == '.':
        chain_empty = 1
    else:
        chain_empty = 0
    max_chain_empty = 0
    for i in range(B-1, D):
        if S[i] == '.':
            chain_empty += 1
            chain_rock = 0
        else:
            chain_empty = 0
            chain_rock += 1
            
        max_chain_empty = max(max_chain_empty, chain_empty)
        if chain_rock >= 2:
            print('No')
            sys.exit()
            
    if max_chain_empty < 3:
        print('No')
        sys.exit()
            
    chain_rock = 0
    for i in range(A, C):
        if S[i] == '#':
            chain_rock += 1
        else:
            chain_rock = 0
            
        if chain_rock >= 2:
            print('No')
            sys.exit()
            
else:
    chain_rock = 0
    for i in range(A, C):
        if S[i] == '#':
            chain_rock += 1
        else:
            chain_rock = 0
            
        if chain_rock >= 2:
            print('No')
            sys.exit()
            
    chain_rock = 0
    for i in range(B, D):
        if S[i] == '#':
            chain_rock += 1
        else:
            chain_rock = 0
            
        if chain_rock >= 2:
            print('No')
            sys.exit()

print('Yes')

Submission status: Wrong Answer

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, 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: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
if "##" in S[A - 1: max(C, D)]:
	print("No")
	exit()
for i in range(B - 1, D):
	if S[i] == "." and S[i - 1] == ".":
		if D == N:
			print("Yes")
			exit()
		else:
			if S[i + 1] == ".":
				print("Yes")
				exit()
print("No")

Submission status: Wrong Answer

Solution code:
#Python標準入出力

import numpy as np

# 1行に複数の文字列（数字）を取得，整数に直す
# 今回は2つ受け取って，足し算する

# 0 len root 1 sunuke 2 funuke 3 point1 4 point2 funuke
Masu = list(map(int, input().split()))
Root = input()

#Answer 1 パターン入れ込み
# print(Masu[3])
# print(Root)

# print(Root[0])

Judge = True

Rock = []
for i in range(Masu[0]):
    if Root[i] == "#":
        Rock.append(i+1)

for j in range(Masu[0]):
    if Root[j] == "#" and Root[j-1] == "#":
        Judge = False
    if Masu[3] == j+1 and Masu[4] == j+1-1 and Root[j-2] == "#":
        Judge = False
    if Masu[3] == j+1 and Root[j-1] == "#" and Masu[4] == j+1-2:
        Judge = False


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




#Answer 2 動かし

Submission status: Wrong Answer

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

[N, A, B, C, D] = [int(i) for i in input().split()]

S = input()

# '#'が2連続あれば移動不可能
S_split = S.split('.')

max_length = 0
for s in S_split:
    if len(s) > max_length:
        max_length = len(s)

if max_length >= 2:
    print('No')
    sys.exit()

# ここまでくればBは必ず目的地に到着可能

# もしC<DだったらAも必ず到着可能
if C < D:
    print('Yes')
    sys.exit()

# もしC>Dだったら、Dの手前が'#'もしくはDの奥が'#'の場合はAはほぼ到達不可能
if S[D-2] == '#' or S[D] == '#':
    # もしS[A]からS[C-1]の間に'...'があればAは到達可能
    if '...' in S[A:C]:
        print('Yes')
        sys.exit()
    print('No')
    sys.exit()

print('Yes')

Submission status: Wrong Answer

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


ans = "Yes"
f = 0
if C>D:
    f = 1


if f == 0:
    now = S[A-1]
    count = 0
    for i in range(A-1,C):
        if S[i]=='#':
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break
  
    count = 0
    for i in range(B-1,D):
        if S[i]=='#':
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break
       


if f == 1:
    now = S[A-1]
    count = 0
    count_space = 0
    space_flag = False

    for i in range(A-1,D):
        if S[i]=='#':
            count_space = 0
        else:
            count_space += 1
        if count_space == 3:
            space_flag = True

    if not space_flag:
        ans = "No"
    
    for i in range(A-1,C):
        if S[i]=='#':
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break

    
    
    count = 0
    for i in range(B-1,D):
        if S[i]=='#':
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

l_s = []
for i in range(len(s)):
    l_s += [0 if s[i] == '.' else 1]

ans = 'Yes'
if i in range(len(s)-1):
    if sum(l_s[i:i+2])==2:
        ans = 'No'

if ans == 'Yes':
    if d>c:
        pass
    else:
        ans = 'No'
        for j in range(d-b-2):
            if sum(l_s[1+j:1+3+j]) == 0:
                ans = 'Yes'
            else:
                pass

print(ans)

Submission status: Wrong Answer

Solution code:
import heapq


def f(S, N, A, B, C, D):
    if B > C:
        if g(S, A, C) or g(S, C, D):
            return 'No'
        else:
            return 'Yes'
            
    elif C < D:
        if g(S, A, D):
            return 'No'
        else:
            return 'Yes'
        
    else:
        if g(S, A, B):
            return 'No'

        if g2(S, B-1, D):
            return 'Yes'
        
        return 'No'


def g(S, X, Y):
    for i in range(X-1, Y-1):
        if S[i] == '#' and S[i+1] == '#':
            return True

    return False



def g2(S, X, Y):
    for i in range(X-1, Y-1):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            return True

    return False



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

    print(f(S, N, A, B, C, D))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    A = A-1
    B = B-1

    def reachable(A, C, S):     # O(N)
        # AからCへ到達可能ですか
        if S[A:C+1].find("##") == -1:
            return True
        else:
            return False

    if C > D:
        # できるだけ早く追い越す
        # 追い越すためには、"..."という領域が必要。
        oikoshi = S[B-1:].find("...")
        if oikoshi == -1:
            no()
            return
        A = B-1+oikoshi + 2
        B = B-1+oikoshi + 1

    # ２連岩なければ通れる
    if reachable(A, C, S) and reachable(B, D, S):
        yes()
    else:
        no()
    return


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: Wrong Answer

Solution code:
n , a0 , b0 , c0 , d0 = map(int,input().split())
s = input()

# a < b に変換する
if a0 > b0 : # 入れ替える
    a = b0
    b = a0
    c = d0
    d = c0
else : # 入れ替えない
    a = a0
    b = b0
    c = c0
    d = d0

right = max(c,d)
left = min(a,b)
middle = max(a,b)

for i in range(n-1) :
    if s[i] == '#' and s[i+1] == '#' : # 岩が2個連続である場合
        if i <= right - 2 and i >= left - 1 :
            print('No')
            break
else :
    if c < d :
        print('Yes')
    else :
        for i in range(n-2) :
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' : # 入れ替え可能
                if i < d - 1 and i >= middle - 1 :
                    print('Yes')
                    break
        else :
            print('No')

Submission status: Wrong Answer

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

cnt3dot = 0
for i in range(A , N):
    # check "##"
    if S[i : i + 2] == "##":
        print("No")
        exit(0)
    # check "..."
    if i >= B - 1:
        if S[i - 1 : i + 2] == "...":
            cnt3dot += 1

if C < D:
    print("Yes")
else: # D < C
    if cnt3dot > 0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
flag2 = True
flag3 = False
if C < D:
    AS = S[A:C-1]
    BS = S[B:D-1]
    for i in range(len(S)-1):
        if BS[i:i+2] == '##':
            flag2 = False
    for i in range(len(S)-1):
        if AS[i:i+2] == '##':
            flag2 = False
    if flag2:
        print('Yes')
    else:
        print('No')
else:
    AS = S[A:C-1]
    BS = S[B:D-1]
    AD = S[A:D+1]
    for i in range(len(S)-2):
        if AD[i:i+3] == '...':
            flag3 = True
    if flag2 and flag3:
        print('Yes')
    else:
        print('No')
    for i in range(len(S)-1):
        if BS[i:i+2] == '##':
            flag2 = False
    for i in range(len(S)-1):
        if AS[i:i+2] == '##':
            flag2 = False

Submission status: Wrong Answer

Solution code:
import math
import numpy as np


def inputs(): return list(map(int, input().split()))


def main():
    N, A, B, C, D = inputs()
    S = input()
    course = S[A:max(C, D)]
    cnt = 0
    ans = 'Yes'
    for i in course:
        if i == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            ans = 'No'
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
temp = input()

temp2 = input()

N, A, B, C, D = [int(x) for x in temp.split()]
flag = True
before = -1
 
for x, xi in enumerate(temp2):
    if x<A:# 初めはいらない
        continue
    elif x>D+1:# 後半もいらない
        break
        
    if xi==".":
        continue
    # 以下ブロック箇所
    elif x-1 in [A, B, C, D]:
        flag = False
        break
    else:
        if x-before==1:
            flag = False
            break
        else:
            before = x
    
            
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = [int(x) for x in input().split(" ")]
S = str(input())

Sn = list()
for i in S:
    if(i == "."):
        Sn.append(0)
    else:
        Sn.append(1)


if(a>b):
    front = a-1
    back = b-1
    tof = c-1
    tob = d-1
else:
    front = b-1
    back = a-1
    tof = d-1
    tob = c-1

isCan = True
isHide = False
for i in range(front,tof-1):
    if(Sn[i] == 1 and Sn[i+1] == 1):
        isCan = False
        break
        
    if(Sn[i] == 0 and Sn[i-1] == 0 and Sn[i+1] == 0):
        isHide = True
        


if(isCan == True and isHide == False):
    Sn[tof] = 1

for j in range(back,tob-1):
    if(Sn[j] == 1 and Sn[i+1] == 1):
        isCan = False
        break
        
if(isCan == True):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(str(input()))
a, b, c, d = a-1, b-1, c-1, d-1
rng = []
chg = []
left = -1
for i in range(1, n-1):
  if s[i] == s[i+1] == "#":
    rng.append([left, i-1])
    left = i + 1
  elif i == n-2:
    rng.append([left, i+1])
  if s[i-1] == s[i] == s[i+1] == ".":
    chg.append(i)
#print(rng)
check = 0
if c < d:
  for r in rng:
    if r[0] <= a:
      if c <= r[1]:
        check = 1
      break
  if check:
    check = 0
    for r in rng:
      if r[0] <= b:
        if d <= r[1]:
          check = 1
        break

else:
  for r in rng:
    if r[0] <= a:
      if c <= r[1]:
        check = 1
        check_r = r
      break
  if check:
    check = 0
    for i in chg:
      if check_r[0] <= i:
        if i <= check_r[1]:
          check = 1
        break

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

Submission status: Wrong Answer

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) or (a>b and c > d):
        if  "##" in s[a:c]:
                print("No")
                exit()
        if   "##" in s[b:d]:
                print("No")
                exit()
        print("Yes")
else:
        if  "##" in s[a:c]:
                print("No")
                exit()
        if   "##" in s[b:d]:
                print("No")
                exit()
        sita = a
        ue = a         
        if  "..." in s[b:c+1]:
                print("Yes")
                exit()
        print("No")

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
def check(list,a,b,e,d):
    i,z,count,counter,c=a,True,0,0,0
    check1=0
    while i<b:
        if list[i]=='#':
            c+=1
        if list[i]=='.':
            c=0
        if c>=2:
            check1+=1
        i+=1
    if check1>0:
        return False
    c=0
    check1=0
    i=max(a,b)
    while i<max(e,d) and z:
        if list[i]=='#':
            counter=0
            c+=1
        if list[i]=='.':
            counter+=1
            c=0
        if counter>=3:
            count+=1
        if c>=2:
            check1+=1
        i+=1
    
    if check1>0:
        return False
    else:
        if d>e:
            return True
        elif d==c:
           
            return False
        else:
            if count>1:
                
                return True
m=list(map(int,input().strip().split()))
l=list(input())
if check(l,m[1],m[2],m[3],m[4]):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if '#' not in s:
    print('Yes')
elif '#.#' in s and a < s.index('#.#') and s.index('#.#') < c:
    print('No')
elif '#.#' in s and b < s.index('#.#') and s.index('#.#') < d:
    print('No')
elif '#..#' in s and a < b and c > d:
    print('No')
elif '#..#' in s and a > b and c < d:
    print('No')
elif '...' in s:
    print('Yes')
elif c < d:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if "##" in s[b:d+1]:
	# print('b-dで岩２つ')
	ans = 'No'
else:
	if "##" in s[a:c+1]:
		# print('a-cで岩２つ')
		ans = 'No'
	else:#邪魔な岩は無し
		if c>d: #ふぬけを飛び越える必要がある場合
			#ふぬけ君を飛び超えるために3マス以上連続で空いてる場所を探してあげる
			if "..." in s[b:]:
				# print('空きマス３つある')
				ans = 'Yes'
			else:#飛び越えるスペースが無かった
				# print(s[b:])
				# print('空きマス３つない・・・')
				ans = 'No'
		else:#ふぬけ、すぬけの順に動かせばいい場合、岩はもう見た
			# print('ふぬけ→すぬけ　OK')
			ans = 'Yes'

print(ans)

Submission status: Wrong Answer

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

if a > b:
    a,b,c,d = b,a,d,c

# print(s)
"""
  012345678
 "#####...#####".find("...")
5
>>> "#####...#####"[:5]
'#####'
>>> "#####...#####"[5+3:]
'#####'
>>> "0123456789"[1:7]
'123456'
"""

if c < d:
    # 追い越しが不要の場合
    if s[a:d+1].find("##") == -1: # 障害がないなら
        print("Yes")
    else:
        print("No")
else:
    # 追い越しが必要の場合
    #print(s)
    #print(s[b-1:c+1])
    if s[b-1:c+1].find("...") != -1:
        if s[a:c + 1].find("##") == -1: # 障害がないなら
            print("Yes")
        else:
            print("No")
    else:
        # 追い越し区間がないなら抜けない
        print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
if C==D:
  print("No")
elif 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:
  c,d=0,0
  if "##" in S[A-1:C]:
    d=1
  if "..." not in S[B-1:D]:
    d=1
  print("Yes" if d==0 else "No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
if C<D and B<C:
    for i in range(A-1,D-2):
        if S[i]=='#' and S[i+1]=='#':
            print('No')
            exit()
    print('Yes')
    exit()
elif C<D and B>C:
    for i in range(A-1,C-2):
        if S[i] == '#' and S[i + 1] == '#':
            print('No')
            exit()
    for p in range(B-1,D-2):
        if S[p] == '#' and S[p + 1] == '#':
            print('No')
            exit()
    print('Yes')
    exit()
elif C>D:
    for j in range(A-1,D-2):
        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-1)):
        print('Yes')
        exit()
print('No')

Submission status: Wrong Answer

Solution code:
from sys import stdin, exit

N, A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
for k in range(A - 1, D):
    if S[k] == '#' and S[k + 1] == '#':
        print('No')
        exit()

if C < D:
    print('Yes')
else:
    cnt = 0
    for k in range(B - 1, D):
        if S[k] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt > 2:
            print('Yes')
            exit()
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = [int(x) for x in input().split()]
S = input()
cross = False
minS = A
maxS = B
minG = C
maxG = D

if C < D:
    if A > B:
        maxS = A
        minS = B
        cross = True
else:
    minG = D
    maxG = C
    if A < B:
        cross = True

wall = S.find("##")
even = S.find("...")

if cross == False:
    if wall == -1:
        print("Yes")
    elif wall < minS or maxG < wall:
        print("Yes")
    else:
        print("No")
else:
    if even == -1:
        print("No")
    elif minS <= wall and wall <= maxG:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=list(map(int,input().split()))
S=input()
bS=S[B-1:D-1]
a=True
if C<D:
    if "##" in bS:
        a=False
    else:
        aS=S[A-1:C-1]
        if "##" in aS:
            a=False

else:
    if "##" in bS:
        a=False
    else:
        aS=S[A-1:C-1]
        if "##" in aS:
            a=False
        else:
            tmp=S[:B-1]+"#"+S[B-1:]
            aS=tmp[A-1:C-1]
            j1= ("##" in aS)
            tmp=S[:D-1]+"#"+S[D-1:]
            aS=tmp[A-1:C-1]
            j2= ("##" in aS)
            if  not("..." in bS or (j1 or j2)):
                a=False
            
        
        
if a:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        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 と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
    

"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""



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
def main(): 
    if C < D:
        past = True
        now = True
        for i in range(B, D):
            if S[i] == ".":
                now = True
            else:
                now = False
            
            if now == False and past ==False:
                return print("No")
            else:
                pass
            past = now
            
        past = True
        now = True
        for i in range(A, C):
            if S[i] == ".":
                now = True
            else:
                now = False
            
            if now == False and past ==False:
                return print("No")
            else:
                pass
            past = now
        return print("Yes")
    else:
        past = True
        now = True
        for i in range(A, C):
            if S[i] == ".":
                now = True
            else:
                now = False
            
            if now == False and past ==False:
                return print("No")
            else:
                pass
            past = now
                
        past2 = False
        past1 = False
        now   = True
        flg   = False
        for i in range(A, C):
            if S[i] == ".":
                now = True
            else:
                now = False
            if now == True and past1 ==True and past2 == True:
                flg = True
            else:
                pass
            past2 = past1
            past1 = now
        if S[D-1] == ".":
            flg = True
        if flg == True:
            return print("Yes")        
        else:
            return print("No")
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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