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 check(list,a,b,e,d):
    if a==b:
        return False
    if e==d:
        return False
    if list[d-1]=='#' or list[e-1]=='#':
        return False
    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
    i=max(a,b)
    while i<min(e,d):
        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
    c=0
    
    while i<max(e,d):
        if list[i]=='#':
            c+=1
        if list[i]=='.':
            c=0
        if c>=2:
            check1+=1
        i+=1
   
    if check1>0:
        return False
    else:
        if d>e:
            return True
        elif d==e:
           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:
#coding:utf-8
N,A,B,C,D = map(int,input().split())
S = input()
def isContinuous(S):
    for i in range(len(S)-1):
        if S[i:i+2] == "##":
            return True
    return False
def paint(S):
    P = [0] * len(S)
    for i in range(len(S)):
        if S[i] == "#":
            P[i] = 1
            if i != 0:
                P[i-1] = 1
            if i != (len(S)-1):
                P[i+1] = 1
    return P
if C < D:
    if not isContinuous(S[B:C]):
        print ("Yes")
    else:
        print ("No")
else:
    P = paint(S)
    for i in P[B:D]:
        if i == 0:
            print ("Yes")
            exit()
    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 = str(input())
if C < D:
    if "##" in s[A:C] or "##" in s[B:D]:
        print("No")
    else:
        print("Yes")
else:
    if "##" in s[A:C] or "##" in s[B:D]:
        print("No")
    else:
        if D-B >= 2:
            if "..." in s[B:D+1]:
                print("Yes")
            elif s[D-1] == ".":
                print("Yes")
            else:
                print("No")
        else:
            if s[B+2] == ".":
                print("Yes")
            else:
                print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
# import statistics
import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


n, a, b, c, d = MI()
s = [s for s in input()]
aki = []
for i in range(1, len(s)):
    if s[i] == '#' and s[i-1] == '#':
        if a-1 < i < c-1 or b-1 < i < d-1:
            print('No')
            exit()

if c < d:
    print('Yes')
else:
    for i in range(2, len(s)):
        if s[i] == '.' and s[i-1] == '.' and s[i-2] == '.':
            aki.append(i)
    if s[d-2] == '#':
        for num in aki:
            if b-1 <= num < d-2:
                print('Yes')
                exit()
    elif s[d] == '#':
        for num in aki:
            if b-1 <= num < d:
                print('Yes')
                exit()
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def syori1(sunuke,hunuke):
    while hunuke<D:
        if hunuke+1 == N:
            return "Yes"
        if S[hunuke+1] == ".":
            hunuke += 2
        elif S[hunuke] == ".":
            hunuke += 1
        else:
            return "No"
    
    while sunuke<C:
        if sunuke + 1 == N:
            return "Yes"
        if S[sunuke+1] == ".":
            sunuke += 2
        elif S[sunuke] == ".":
            sunuke += 1
        else:
            return "No"
    
    return "Yes"

def canover():
    for i in range(B-1,D-2):
        if S[i] == "." and S[i+1] == "." and S[i+2]==".":
            return True
        else:
            pass
    return False

if C > D:
    if canover():
        print(syori1(sunuke,hunuke))
    else:
        print("No")
else:
    print(syori1(sunuke,hunuke))

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
obs = [S[i] is "#" and S[i+1] is "#" for i in range(min(A,B),max(C,D)-1)]
space = [S[i] is "." and S[i+1] is "." and S[i+2] is "." for i in range(min(A,B),max(C,D)-2)]
if C < D:
  if True in obs[B:D-1] or True in obs[A:C-1]:
    print("No")
  else:
    print("Yes")
else:
  if not True in space[B-1:D-2]:
    print("No")
  elif True in obs[B:D-1] or True in obs[A:C-1]:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

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

flag3 = 0
flagno = 0

if c > d:

    for i in range(a,c):

        if s[i:i+2] == "##":
            flagno += 1
            break

    if flagno == 0:

        for i in range(b,d-2):
        
            if s[i-2:i+1] == "...":
                flag3 += 1
                break
    
    if flagno == 0 and flag3 > 0:
        print("Yes")

    else:
        print("No")

else:

    for i in range(a,d):

        if s[i:i+2] == "##":
            flagno += 1
            break
    
    if flagno == 0:
        print("Yes")

    else:
        print("No")

Submission status: Wrong Answer

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

    s.insert(0, '.')
    s[a] = 'A'
    s[b] = 'B'

    # C D までに岩が2個あるか
    t = s[min(a,b):max(c,d)]
    st = "".join(t)
    if '##' in st:
        print("No")
        return

    # A B が入れ替わるかどうか
    if (c > d):
        # 入れ替わるスペースがあるか
        u = s[max(a,b):min(c,d)]
        su = "".join(t)
        if not '...' in su:
            print("No")
            return

    print("Yes")

test()

Submission status: Wrong Answer

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

if s[a:c].count("##") > 0 or s[b:d].count("##") > 0:
    print("No")
elif c < d:
    print("Yes")
else:
    if s[b:].count("...") > 0 or s[b:b+2] == ".." or s[b-2] == "." and s[b] == ".":
        print("Yes")
    else:
        print("No")

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(C < D):
        if(S[A-1:C].count('##') == 0 and S[B-1:D].count('##') == 0):
            print(YES)
    elif(C > D):
            if(S[B-1:D].count('...') == 0):
                print(NO)
            else:
                st = ''.join(list(S[:D]))
                # st = list(S)
                # st[B-1] = '#'
                # print(''.join(st[B-1:D]))
                if(st.rfind('...')+2 == B and st[D-2] == '#'):
                    print(NO)
                else:
                    print(YES)
    else:
        print(NO)
    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: Wrong Answer

Solution code:
import numpy as np
NABCD = list(map(int,input().split()))
N = NABCD[0]
A = NABCD[1]
B = NABCD[2]
C = NABCD[3]
D = NABCD[4]
S = input()

output = "No"

cous = 0
maxs = 0
cour = 0
maxr = 0
maxi = np.array([])
maxir = np.array([])

for i in range(N):
    p = S[i]
    if p == "#":
        cour += 1
        cous = 0
    elif p == ".":
        cous += 1
        cour = 0
    if cour > maxr:
        maxr = cour
    if cous > maxs:
        maxs = cous
    if cous > 2:
        maxi = np.append(maxi,i+1)
    if cour >= 2:
        maxir = np.append(maxir,i+1)

keysum = sum(maxi-1>=B)
outsumA = sum((A<maxir)*(maxir<C))
outsumB = sum((B<maxir)*(maxir<D))
outsum = outsumA + outsumB
if C > D:
    if (maxr < 2)and(maxs >2)and(keysum>0):
        output = "Yes"
    elif (maxr >= 2)and(outsum==0)and(maxs >2)and(keysum>0):
        output = "Yes"
elif D > C:
    if maxr < 2:
        output = "Yes"
    elif (maxr >= 2)and(outsum==0):
        output = "Yes"

print(output)

Submission status: Wrong Answer

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

if(s.count('##') > 0):
    frag = 0
if(c<d):
    frag = 1
else:
    frag = 0
    cnt = 0
    for i in range(len(t)-1):
        cnt += t[i].count(".")
        if(t[i].count(".") >= 3):
            frag = 1
    if(frag == 0 and (t[len(t)-1].count('.') >= 3 and cnt + len(t)-1 + 1 < d)):
        frag = 1
    else:
        frag = 0
if(frag == 1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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-1,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: 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(C < D):
        if(S[A-1:C].count('##') == 0 and S[B-1:D].count('##') == 0):
            print(YES)
    elif(C > D):
            if(S[B-1:D].count('...') == 0):
                print(NO)
            else:
                st = ''.join(list(S[:D]))
                # st = list(S)
                # st[B-1] = '#'
                # print(''.join(st[B-1:D]))
                if(st.rfind('...')+2 == B and st[B-2] == '#'):
                    print(NO)
                else:
                    print(YES)
    else:
        print(NO)
    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: Wrong Answer

Solution code:
S = input()
n = 0
while True:
    I = S.find('ABC')
    if I >= 0:
        S = S[:I] + 'BCA' + S[I+3:]
        n = n + 1
    else:
        break
print(n)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

def PNO():
    print("No")
    sys.exit(0)

def PYES():
    print("Yes")
    sys.exit(0)



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

ac = str(s[a:c])
if (ac.find("##") != -1):
    PNO()

bd = str(s[b:d])
if (bd.find("##") != -1):
    PNO()

if (c > d):
    bdd = str(s[b:d+2])
    if (bdd.find("...") == -1):
        PNO()

PYES()

Submission status: Wrong Answer

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:
    ans = check(a,d,path) and check(b,c,path)
    # triple = 0
    # for s in path[b-1:c+1]:
    #     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: Wrong Answer

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:
    s = min(A, B, C, D)
    g = max(A, B, C, D)
    for s_left, s_right in zip(S[s:g-1], S[s + 1:g]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()
    print('Yes')
elif plan == 2:
    # planAでない。つまり入れ替わる場合
    s = min(A, B, C, D)
    g = max(A, B, C, D)
    for s_left, s_right in zip(S[s:g-1], S[s + 1:g]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()
    if B + 1 == D:
        print('Yes')
        exit()
    for s_left, s_center, s_right in zip(S[B:D - 1], S[B + 1:D], S[B + 2:D + 1]):
        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: Wrong Answer

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

if c<d:
    s = list(s)
    h = s[b:d]
    for i in range(1,len(h)):
        if h[i]==h[i-1] and h[i]=="#":
            print("No")
            break
    else:
        hh = s[a:c]
        for i in range(1,len(hh)):
            if hh[i]==hh[i-1] and hh[i]=="#":
                print("No")
                break
        else:
            print("Yes")
else:
    if "..." in s[a:d]:
        h = s[a:c]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            hh = s[b:d]
            for i in range(1,len(hh)):
                if hh[i]==hh[i-1] and hh[i]=="#":
                    print("No")
                    break
            else:
                print("Yes")
    else:
        s = list(s)
        h = s[b:d]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            s[d-1]="#"
            hh = s[a:c]
            for i in range(1,len(hh)):
                if hh[i]==hh[i-1] and hh[i]=="#":
                    print("No")
                    break
            else:
                print("Yes")

Submission status: Wrong Answer

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

if S.find('##')>=0 and A<S.find('ABC')<C or B<S.find('ABC')<D:
    ans = "No"

if A<B<D<C and not '...' in S:
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
for i in range(a, c - 2):
    if s[i] == "#" and s[i + 1] == "#":
        print("No")
        exit()
for i in range(b, d - 2):
    if s[i] == "#" and s[i + 1] == "#":
        print("No")
        exit()
if c > d:
    f = s[b - 2:].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 = input()
if ('##' in s[A:C]) or ('##' in s[B:D]):
    print('No')
else:
    if C > D:
        if '...' in s[B-1:D]:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

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

ans = "Yes"
space = 0
tmpSpace = 0
# 岩判定
for i in range(min(A, B) - 1, max(C, D)):
    if i != 0 and s[i-1:i+1] == "##":
        ans = "No"
        break

# スペース >= 2 判定
spaceFlg = False
for i in range(max(A, B) - 1, min(C, D) + 1):
    if i != 0 and s[i-1:i+2] == "...":
        spaceFlg = True
        break

if (A - B) * (C - D) < 0 and not spaceFlg:
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

Solution code:
def check(list,a,b,e,d):
    if a==b:
        return False
    if e==d:
        return False
    if list[d-1]=='#' or list[e-1]=='#':
        return False
    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
    print(check1)
    if check1>0:
        return False
    c=0
    i=max(a,b)
    while i<min(e,d):
        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
    c=0
    print(check1)
    while i<max(e,d):
        if list[i]=='#':
            c+=1
        if list[i]=='.':
            c=0
        if c>=2:
            check1+=1
        i+=1
    print(check1)
    print(count,'c')
    if check1>0:
        return False
    else:
        if d>e:
            return True
        elif d==e:
           return False
        else:
            if count>=1:
                print('a')
                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 = list(input())

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

if s[c-1] == "#" or s[d-1] == "#":
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

rock = 0
max_rock = []
non = 0
max_non = []
k = 0
for i in s:
    if i == '#':
        rock += 1
        if non >= 3:
            max_non.append([non, k])
        non = 0
    else:
        non += 1
        if rock >= 2:
            max_rock.append([rock, k])
        rock = 0
    if k == n-1:
        k += 1
        if non >= 3:
            max_non.append([non, k])
        if rock >= 2:
            max_rock.append([rock, k])
    k += 1

max_non1 = [i for i in max_non if i[1]-3 < d and i[1]-3 < c and i[1] > a and i[1] > b]
max_rock1 = [i for i in max_rock if i[1]-3 < d and i[1]-3 < c and i[1] > a and i[1] > b]
# print(max_non1)
# print(max_rock1)
if len(max_rock1) > 0:
    print('No')
elif d > c:
    print('Yes')
else:
    if len(max_non) > 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
obs = [S[i] is "#" and S[i+1] is "#" for i in range(min(A,B),max(C,D)-1)]
space = [S[i] is "." and S[i+1] is "." and S[i+2] is "." for i in range(min(A,B),max(C,D)-2)]
if C < D:
  if True in obs[B:D-1] or True in obs[A:C-1]:
    print("No")
  else:
    print("Yes")
else:
  if not True in space[B-1:max(C,D)-2]:
    print("No")
  elif True in obs[B:D-1] or True in obs[A:C-1]:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

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

flag = True

# c < dならbを先にゴールさせれば良い
s_bd = s[b:d-1]
for i in range(len(s_bd)-1):
    if s_bd[i:i+2] == "##":
        flag = False
        break
s_ac = s[a:c-1]
for i in range(len(s_ac)-1):
    if s_ac[i:i+2] == "##":
        flag = False
        break

if c > d:
    # ゴールの左が#
    if s[d-2] == "#" and s[b] == "#":
        s_bd = s[b-1:d]
        has_ddd = False
        for i in range(len(s_bd)-2):
            if s_bd[i:i+3] == "...":
                has_ddd = True
        if has_ddd == False:
            flag = False

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:]:
  ans = "No"
elif C < D:
  ans = "Yes"
else:
  if "..." in S[B-2:D+1]:
    ans = "Yes"
  else:
    ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
def check(start,end,road):
    s = road[start-1:end-1]
    if '##' in s:
        return False
    else:
        return True

def check2(start,end,road):
    s = road[start-1:end-1]
    if '...' in s:
        return True
    else:
        return False

if __name__ == '__main__':
    n,a,b, c,d = map(int, input().split())
    s = input()
    if c < d:
        if check(a,d,s):
            print('Yes')
        else:
            print('No')
    else:
        if check2(a,c,s):
            if check(a,d,s):
                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<B and B<D:#パターンその1
    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 B<C and C<D:#パターンその2
    for i in range(A-1,D-2):
        if S[i]=='#' and S[i+1]=='#':
            print('No')
            exit()
    print('Yes')
    exit()
elif D<C:#パターンその3
    for j in range(A-1,C-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:
n, a, b, c, d = [int(i) for i in input().split()]
s = input()

#先にBを移動させる
i = b - 1
while(1):
    
    if i == (d-1):
        break
    
    if i >= (n-1):
        print('No')
        exit()
    
    move = 2
    
    if (i + 2) >= n:
        move = 1
        
    if (i + 1) >= n:
        move = 0
    
    if (s[i + move] == '#'):
        move -= 1
    
    if(move <= 0):
        break
    
    i += move
    

#次にAを移動させる
j = a - 1
while(1):
    
    if j == (c-1):
        break
    
    if j >= (n-1):
        print('No')
        exit()
    
    move = 2
    
    if (j + 2) >= n:
        move = 1
        
    if (j + 1) >= n:
        move = 0
    
    if (s[j + move] == '#'):
        move -= 1
    elif (j + move) == i:
        move -= 1

    if(move <= 0):
        break
    
    j += move

print('Yes')

Submission status: Wrong Answer

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]:Bs[1]+1] or "##" in S[As[0]:As[1]+1]:
  ans = False
elif As[1] > Bs[1]:
  if "..." not in S[Bs[0]:Bs[1]+1]:
    ans = False

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

Submission status: Wrong Answer

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:c+1]:
#         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: Wrong Answer

Solution code:
N,A,B,C,D = [int(x) for x in input().split()]
S = input()
S_ = list(S)
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.rfind("...")

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 even + 1 < maxS:
        print("No")
    elif minG < even + 1:
        print("No")
    elif minS <= wall and wall <= maxG:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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
        if not "##" in S[B:D]:
            S = S[:D-1] + "#" + S[D:]
            if not "##" in S[A:C]:
                ans = "Yes"
            else:
                ans = "No"
        else:
            ans = "No"

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

            if ans is "No":
                S = s
                if "..." in S[B:min([C, D])]:
                    if not "##" in S[A:C]:
                        S = S[:C-1] + "#" + S[C:]
                        if not "##" in S[B:D]:
                            ans = "Yes"
                        else:
                            ans = "No"
                    else:
                        ans = "No"        

print(ans)