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:
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    [n, a, b, c, d] = li()
    s = input()
    if c < d:
        route = s[a:d - 1]
        # print(route)
        possible = True
        before = "."
        for si in s:
            if before == si == "#":
                possible = False
                break
            before = si
    elif d < c:
        route = s[a:d - 1]
        # print(route)
        possible = True
        before = "."
        for si in s:
            if before == si == "#":
                possible = False
                break
            before = si

        cross_possible = False
        route = s[b:max(n, d + 1)]
        # print(route)
        before = [s[b - 2], s[b - 1]]
        for si in s:
            before.append(si)
            before = before[-3:]
            if before[0] == before[1] == before[2] == ".":
                cross_possible = True
        possible = possible and cross_possible

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

# C<Dの場合
# 目的地までの間に岩が２連続で存在しなければ可能
# D<Cの場合
# BとCの間に岩がないマスが３連続で存在すれば可能

Submission status: Wrong Answer

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


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def SI(): return input()


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

    M = [0 for _ in range(A-1)]
    a = 0
    for s in S[A-1:max(C, D)]:
        if s == ".":
            a = 0
            M.append(0)
        else:
            if a == 1:
                print("No")
                return
            a = 1
            M.append(1)
    if D > C:
        print("Yes")
        return
    a = 0
    for m in M[B:D]:
        if m == 0:
            a += 1
        else:
            a = 0
        if a == 3:
            print("Yes")
            return
    if M[B-2] == 0 and M[B] == 0:
        print("Yes")
        return
    if M[D-2] == 0 and M[D] == 0:
        print("Yes")
        return
    print("No")


main()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int, input().split())
S = input()[:max(c,d)]
if "##" in S:
  print('No')
elif c > d and "..." not in S:
  print('No')
else:
  print("Yes")

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 "##" in S[A-1:C] or "##" in S[B-1:D]:
        print("No")
    else:
        print("Yes")
else:
    s = S.split("##")
    l=-2
    i=-2
    for ss in s:
        i += 2
        l += 2+len(ss)
        if l >= A:break
        i = l
    if ("..." in ss) and len(ss)+i >= C:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import math
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column

# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']




def main():
    N, A, B, C, D = list(map(int,input().split()))
    S= str(input())
    # print(S[2:5])-> [2]~[4]
    if C>D:
        if '##' in S[A:C]:
            print("No")
        elif "..." in S[B-2:D]:
            print("Yes")
        else:
            print("No")
    else:
        if '##' in S[A:D]:
            print("No")
        else:
            print("Yes")
    # elif C>D and  ("..." in S[B-2:])
    # print(S[B-2:])
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

needOver = False
if C > D:
    needOver = True

ans = 'Yes'
overPos = 0
if needOver:
    canOver = False
    for i in range(B+1-1, C):
        if S[i-2] == '.' and S[i-1] == '.' and S[i] == '.':
            canOver = True
            if i == C-1 and C < D and S[i+1] == '#':
                ans = 'No'
            break
    if not canOver:
        ans = 'No'

for i in range(A+1-1, C):
    if S[i-1] == '#' and S[i] == '#':
        ans = 'No'
        break

for i in range(B+1-1, D):
    if S[i-1] == '#' and S[i] == '#':
        ans = 'No'
        break

print(ans)

Submission status: Wrong Answer

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

ans = True
d = False
for i in range(B,D):
    if(S[i] == "#" and d):
        ans = False
    elif(S[i] == "#"):
        d = True
    else:
        d = False
d = False
for j in range(A,C):
    if(S[i] == "#" and d):
        ans = False
    elif(S[i] == "#"):
        d = True
    else:
        d = False
if(C>D):
    ans = S[B-1:D].count("...")!=0

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

Submission status: Wrong Answer

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

if B < C and C < D :
    if "##" in S[A-1:D-1] :
        print("No")
    else:
        print("Yes")
if B < D and D < C:
    if "##" in S[A-1:C-1] :
        print("No")
    else:
        # Bの一つ手前からDの次までに...があればよい
        if "..." in S[B-2:D]:
            print("Yes")
        else:
            print("No")

if C < B and B < D:
    # A..Cに2つ連続#がなければよい
    # B..Dに2つ連続#がなければよい
    if "##" in S[A-1:C-1] or "##" in S[B-1:D-1] :
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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 C < D:
    if "##" in s[A-1:D]:
        print("No")
    else:
        print("Yes")
else:
    if "..." in s[B-2:C] and "##" not in s[A-1:D]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

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

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
    if xi==".":
        continue
    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 = map(int, input().split())
s = input()

if '##' in s[a:c-1]:
  print('No')
  exit()
if '##' in s[b:d-1]:
  print('No')
  exit()
if c > d:
  if '...' not in s[b-1:d+1]:
    print('No')
    exit()

print('Yes')

Submission status: Wrong Answer

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

ans = "Yes"
tmpSpace = 0
tmpRock = 0
space = 0
for i in range(min(C, D)):
    if s[i] == ".":
        tmpSpace += 1
        tmpRock = 0
    else:
        tmpRock += 1
        if tmpRock >= 2:
            ans = "No"
            break
        space = max(space, tmpSpace)
        tmpSpace = 0

space = max(space, tmpSpace)
if (A - B) * (C - D) < 0:
    if space <= 2:
        ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
rock = []
for i in range(N):
	if S[i] == '#':
		rock.append(i+1)

nRock = len(rock)

# renzoku
for i in range(nRock-1):
	if rock[i+1] - rock[i] == 1:
		if A < rock[i] or B < rock[i]:
			print("No")
			exit()

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

# A ... B ...#.....#... D ... C
for i in range(nRock):
	if i == 0:
		if rock[i] >= 4:
			if B < rock[i]-1:
				print("Yes")
				exit()
		continue
	if rock[i] - rock[i-1] > 3:
		if B < rock[i]-1:
			if D == rock[i-1]+1:
				print("No")
				exit()
			else:
				print("Yes")
				exit()
print("No")

Submission status: Wrong Answer

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

ans = "Yes"
#岩が２個続いてたらダメ
for i in range(A - 1, max(C, D)):
  if i >= A and S[i] == "#" and S[i - 1] == "#":
    ans = "No"
    break

#途中で追い越しが必要な場合
if D < C:
  #岩無しが何個続いてるかカウント
  cnt = 0
  tmp = 0
  for i in range(B - 1, D):#BがDに到着するまでに追い越す
    if S[i] == ".":
      tmp += 1
    else:
      cnt = max(cnt, tmp)
      tmp = 0
  cnt = max(cnt, tmp)
  #岩無しのスペースが3個続かなきゃダメ
  if cnt < 3:
    ans = "No"
print(ans)

Submission status: Wrong Answer

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

ans = True

dp = [False]*n
dp[b-1] = True
# b→d
for i in range(b-1, d):
    if s[i] != ".":
        continue
    for j in range(1,3):
        if i+j < n:
            if s[i+j] != ".":
                continue
            if not dp[i+j]:
                dp[i+j] = dp[i]
if not dp[d-1]:
    ans = False


dp = [False]*n
dp[a-1] = True
# a→c
for i in range(a-1, c):
    if s[i] != ".":
        continue
    for j in range(1,3):
        if i+j < n:
            if s[i+j] != ".":
                continue
            if not dp[i+j]:
                dp[i+j] = dp[i]
if not dp[c-1]:
    ans = False

if d < c:
    l = max(b-2, 0)
    r = min(d-2, n-1)
    if "..." not in s[l:r+1]:
        ans = False

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

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)

for i in range(n-1) :
    if s[i] == '#' and s[i+1] == '#' : # 岩が2個連続である場合
        if i <= right - 2 :
            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 :
                    print('Yes')
                    break
        else :
            print('No')

Submission status: Wrong Answer

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


def f():
    can_over = False

    prev_2 = ""
    prev_1 = ""
    for i in range(A, max(D, C) + 1):
        now = S[i]
        if prev_1 == "#" and now == "#":
            return False

        if i >= B + 2 and prev_1 == prev_2 == now == ".":
            can_over = True

        prev_2, prev_1 = prev_1, now

    return can_over if D < C else True

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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(A,B,C,D)
    # 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[B-1:D]
    # print(S_cut1,S_cut2)
    # 抜く場所
    flg2 = (S_cut2.count("...")>=1)
    if flg1 and flg2:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,a,b,c,d = na()
s = ns()

a-=1
b-=1
c-=1
d-=1
fla = 0
flb = 0
dou = True
tri = False if d < c else True

for i in range(a+1,max(c,d)+1):
    if c < i and i < b:
        continue
    if s[i] == '.':
        fla = 0
        flb += 1
    else:
        fla += 1
        flb = 0
    if fla == 2:
        dou = False
    if flb == 3 and i <= d+1:
        tri = True

if dou and tri:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, a, b, c, d = map(lambda x: int(x) - 1, input().split())
s = list(input())

if c < d:
    while b < d:
        if s[b + 1] == '.':
            b += 1
        elif b + 2 < n and s[b + 2] == '.':
            b += 2
        else:
            print('No')
            exit()
    while a < c:
        if s[a + 1] == '.':
            a += 1
        elif a + 2 < n and s[a + 2] == '.':
            a += 2
        else:
            print('No')
            exit()
    print('Yes')
else:
    s[b] = 'b'
    while a < min(b, c):
        if s[a + 1] == '.':
            a += 1
        elif a + 2 < n and s[a + 2] == '.':
            a += 2
        else:
            if b >= d:
                print('No')
                exit()
            if 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:
                print('No')
                exit()
    while a < c:
        if s[a + 1] == '.':
            a += 1
        elif a + 2 < n and s[a + 2] == '.':
            a += 2
        else:
            print('No')
            exit()
    while b < d:
        if s[b + 1] == '.':
            b += 1
        elif b + 2 < n and s[b + 2] == '.':
            b += 2
        else:
            print('No')
            exit()
    print('Yes')

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]
if c < d :
    if pathA.count("##") == 0 and pathB.count("##") == 0:
        print("Yes")
    else:
        print("No")
else:
    if pathB.count("##") == 0 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())

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+1):
        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')

Submission status: Wrong Answer

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

flag = True
# B -> D
s_bd = s[b:d-1]
for i in range(len(s_bd)-1):
    if s_bd[i:i+2] == "##":
        flag = False
        break
# A -> C
s_ac = s[a:c-1]
if flag:
    for i in range(len(s_ac)-1):
        if s_ac[i:i+2] == "##":
            flag = False
            break

# Bのせいで通れ無い
has_ddd = False
if flag and s_bd[-1] == "#":
    for i in range(len(s_bd)-2):
        if s_bd[i:i+3] == "...":
            has_ddd = True
    if not has_ddd:
        flag = False

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import numpy as np
from functools import lru_cache
import time

def main(): 
    if True:
        N,A,B,C,D = list(map(int, input().split()))
        S = np.asarray(list(str(input())))
    else:
        pass

    scount = 0
    dcount = 0
    swapok = False
    #print(S[A:D])
    for i in range(A,max(C,D)):
        s = S[i]
        if s == "#":
            dcount = 0
            scount += 1
            if scount == 2:
                print("No")
                exit()
        else:
            scount = 0
            if i > B-3:
                dcount += 1
                if dcount == 3:
                    swapok = True
    
    if (C>D) & (not swapok):
        print("No")
    else:
        print("Yes")

if __name__ =='__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=(int(i) for i in input().split())
s=input()
r="Yes"
for i in(a,c-1):
  if s[i]=="#":
    if s[i+1]=="#":
      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: Wrong Answer

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

    if c < d:
        count = 0
        for i in range(d - 1):
            if s[i] == '#':
                count += 1
                if count == 2:
                    print('No')
                    exit(0)
            else:
                count = 0
        print('Yes')
    else:
        flag = 0
        countr = 0
        countv = 0
        for i in range(d + 1):
            if s[i] == '#':
                countr += 1
                countv = 0
                if countr == 2:
                    print('No')
            else:
                countv += 1
                countr = 0
                if countv == 3:
                    flag = 1
        print('Yes') if flag else print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy as np

N,A,B,C,D = map(int,input().split())
S = np.array((False,)+tuple(map(lambda x: x == '#',input()))+(False,))

def check1(i,j):
    return not np.any(S[i:j-1] & S[i+1:j])

def check2(i,j):
    return np.any((~S[i-1:j-1])&(~S[i:j])&(~S[i+1:j+1]))

if C < D:
    print('Yes' if check1(A,C) and check1(B,D) else 'No')
else:
    print('Yes' if check2(B,D) and check1(A,C) else 'No')

Submission status: Wrong Answer

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 > a:
            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] == '#') or threeChk == False):
        print "No"
    elif chk == False:
        print "No"
    else:
        print "Yes"

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

seq=0
tri=0
if c<d:
    seq=s[a:d].count("##")
    if seq==0:
        print("Yes")
    else:
        print("No")
else:
    seq=s[a:c].count("##")
    tri=s[b-1:d+1].count("...")
    if seq==0:
        if tri!=0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Submission status: Wrong Answer

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

S = list(input().split()[0])

result = "Yes"

if C < D:
    for i in range(B, D - 1):
        #2つ連続
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
else:
    for i in range(B, C - 1):
        #２つ連続
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
    for i in range(B, C - 2):
        if S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
            result = "Yes"


print(result)

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(min(firstsunuke, firstfunuke), max(lastsunuke, lastfunuke)-1-1):
    if s[i] == '#' and s[i+1] == '#':
        tobenaiflag += 1
        break
if lastfunuke < lastsunuke:
    for j in range(max(firstsunuke, firstfunuke)-1, min(lastsunuke, lastfunuke)-1-2):
        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:
import sys
sys.setrecursionlimit(10 ** 5)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def SI(): return input()


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

    M = [0 for _ in range(A-1)]
    a = 0
    for s in S[A-1:max(C, D)]:
        if s == ".":
            a = 0
            M.append(0)
        else:
            if a == 1:
                print("No")
                return
            a = 1
            M.append(1)
    if D > C:
        print("Yes")
        return
    a = 0
    for m in M[B:D]:
        if m == 0:
            a += 1
        else:
            a = 0
        if a == 3:
            print("Yes")
            return
    if M[B-2] == 0 and M[B] == 0:
        print("Yes")
        return
    if M[D-2] == 0 and M[D] == 0:
        print("Yes")
        return
    print("No")


main()

Submission status: Wrong Answer

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

gyaku = 0
if C > D:
    gyaku = 1

flag = 0
renzoku = 0
irekae = 0
for i in range(N):
    if S[i] == '#':
        renzoku = 0
        if flag == 1:
            if A < i < C-1 or B < i < D-1:
                print('No')
                exit()
        flag = 1

    else:
        flag = 0
        renzoku += 1
        if renzoku == 3:
            irekae = 1
            irekaeiti = i

    if gyaku:
        if i == D-1:
            if S[i-1] == '#':
                if irekae == 0 :
                    print('No')
                    exit()
                elif B < irekaeiti < D-1:
                    pass
                else:
                    print('No')
                    exit()
print('Yes')

Submission status: Wrong Answer

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 A > B:
        A,B = B,A
        C,D = D,C

    if A > C or B > D:
        print(NO)
        return

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

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

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

        if not bOK:
            print(NO)
            return

    print(YES)







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

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


if __name__ == "__main__":
    [n, a, b, c, d] = li()
    s = input()
    if c < d:
        route = s[a:d - 1]
        print(route)
        possible = True
        before = "."
        for si in s:
            if before == si == "#":
                possible = False
                break
            before = si
    elif d < c:
        route = s[a:d - 1]
        print(route)
        possible = True
        before = "."
        for si in s:
            if before == si == "#":
                possible = False
                break
            before = si

        cross_possible = False
        route = s[b:max(n, d + 1)]
        print(route)
        before = [s[b - 2], s[b - 1]]
        for si in s:
            before.append(si)
            before = before[-3:]
            if before[0] == before[1] == before[2] == ".":
                cross_possible = True
        possible = possible and cross_possible

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

# C<Dの場合
# 目的地までの間に岩が２連続で存在しなければ可能
# D<Cの場合
# BとCの間に岩がないマスが３連続で存在すれば可能

Submission status: Wrong Answer

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):
    for i in range(start-1,goal-2):
        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: Wrong Answer

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

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

koerunka = (not ((A<B and C<D) or (B<A and D<C)))# or (C<B or A<D)

muripo=False
for i in range(3, N):
	if S[i-1] == S[i] == '#':
		muripo = True
		break
	if S[i-3] == S[i] == '#':
		if koerunka:
			muripo=True
			break

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

Submission status: Wrong Answer

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

A_list = S[A:C-1]
count = 0
for i in range (len(A_list)-1):
    if ''.join(A_list[i:i+2])=='##':
        count+=1

S_after_a = S.copy()
S_after_a[C-1]='#'

B_list = S_after_a[B:D-1]
for i in range (len(B_list)-1):
    if ''.join(B_list[i:i+2])=='##':
        count+=1
    
#count逆
B_list = S[B:D-1]
count2 = 0
for i in range (len(B_list)-1):
    if ''.join(B_list[i:i+2])=='##':
        count2+=1

S_after_b = S.copy()
S_after_b[D-1]='#'

A_list = S_after_b[A:C-1]
for i in range (len(A_list)-1):
    if ''.join(A_list[i:i+2])=='##':
        count2+=1
        
if count == 0 and count2 ==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()+"#"*2
e,f=True,False
for i in range(1,n+1):
    if s[i-1]+s[i]=="#"*2:
        if a<i<c or b<i<d:
            print("No")
            break
    else:
        if s[i-1]+s[i]+s[i+1]=="."*3:
            if b<=i<=d:
                f=True
else:
    if c<d:
        print("Yes")
    else:
        if f:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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

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

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


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