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 s[c-1] =='#':
    print('No')
    exit(0)
if s[c-1] =='#':
    print('No')
    exit(0)
for i in range(b,d-1):
    if s[i]=='#' and s[i+1]=='#':
        print('No')
        exit(0)
for i in range(a,c-1):
    if s[i]=='#' and s[i+1]=='#':
        print('No')
        exit(0)
if c>d:
    flag = False
    for i in range(b-2,d-2):
        if s[i:i+3]=='...':
            flag = True
            break
    if not flag:
        print("No")
        exit(0)
    else:
        print("Yes")
else:
    print("Yes")

Submission status: Wrong Answer

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

if "##" in S[:max([D, C])]:
	print("No")
	exit()

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

print("Yes")

Submission status: Wrong Answer

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

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

    if A == B:
        print("No")
        break
            
    if A == C and B ==D:
        print("Yes")
        break
        
    if A > N or B > N:
        print("No")
        break

    if C == D:
        print("No")
        break
    print(A)
    print(B)
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b,c,d=map(int,input().split(' '))
    s=input()
    result = 'Yes'
    if a<b<d<c:
        tmp =0
        cnt=0
        for i in range(b-1,d):
            if s[i]=='#'and s[i+1]=='#':
                result='No'
                break
            if s[i]=='#':
                if tmp > cnt:
                    cnt = tmp
                    tmp=0
            else:
                tmp +=1
        if cnt < 3:
                result = 'No'
        if result =='Yes':
            for i in range(a,c):
                if s[i]=='#'and s[i+1]=='#':
                    result='No'
    else:
        for i in range(b,d):
            if s[i] =='#' and s[i+1]=='#':
                result ='No'
                break
        if result=='Yes':
            for i in range(a,c):
                if s[i] =='#' and s[i+1]=='#':
                    result = 'No'
    print(result)

main()

Submission status: Wrong Answer

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

if c < d:
  if "##" in s:
    print("No")
  else:
    print("Yes")
else:
  if "##" in s:
    print("No")
  else:
    if "..."in s[b-2:d+1]:
      print("Yes")
    else:
      print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
#aとbが反転してるかどうが
if (a > b and c > d) or (a < b and c < d):rev = False
else:rev = True
#石が二つ連続していないかどうが
ren = True
for i in range(min(a,b)-1,max(c,d)):
    if max(c,d) - 1 <= i:pass
    elif s[i] == '#' and s[i+1] == '#':
        ren = False
#石と石の間が３以上空いているかどうが
enp = False
for i in range(max(a,b)-2,min(c,d)):
    if i >= min(c,d) - 2:continue
    if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
        enp = True

if rev:
    if enp and ren:
        print('Yes')
    else:
        print('No')
else:
    if ren:
        print('Yes')
    else:
        print('No')

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()
    # 左ゴールの前後も岩だとダメ
    elif S[maxG - 1] == "#" or S[maxG + 1] == "#":
        if "..." not in S[maxS: min(maxG, minG)]:
            print("No")
            exit()

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

print("Yes")

Submission status: Wrong Answer

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

if ('##' in S) and ( (S.find('##') + 1) < max(C,D)):
    print('No')
elif (D < C) 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()
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 s[a-1:d-1].count("...") > 0:
        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 "#" not in S[i - 1: min(i + 2, N)]:
		print("Yes")
		exit()
print("No")

Submission status: Wrong Answer

Solution code:
INPUT = input().split()
S = input()     # Nと同じ長さの文字列'.'と'#からなる。'

N = int(INPUT[0])    #マス目（文字列）の長さ
A = int(INPUT[1])    #すぬけ君の最初の位置
B = int(INPUT[2])    #ふぬけ君の最初の位置
C = int(INPUT[3])    #すぬけ君に最終的にいてほしい位置
D = int(INPUT[4])    #ふぬけ君に最終的にいてほしい位置

if "##" in S:
    print("No")
else:
    if C > D:
        if S[D - 1] == '#':
            print("No")
        else:
            if "..." in S:
                print("Yes")
            else:
                print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

Sstr=input()


if "##" in Sstr[A:C-1]:
    print("No")
elif "##" in Sstr[B:D-1]:
    print("No")
else:
    
    if C<D:
        print("Yes")
    else:
        if "..." in Sstr[B-2:D]:
            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 = a
for i in range(max(a, 1), min(n-1, max(c, d))):
  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:
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,c):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b,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,c):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b,d):
        if s[i]=='#' and s[i+1]=='#':
            out+=1
    for i in range(b-1,d):
        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:
#A問題
N,A,B,C,D = map(int,input().split())
Slist = list(str(input()))
if C < D:
    now = B-1
    Rock = 0
    flag = 0
    for i in range(D-B):
        I = i+now
        if i == 0:
            pass
        else:
            if Slist[I] == "#":
                Rock+=1
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0
    now = A-1
    Rock = 0
    for i in range(C-A):
        I = i+now
        if i == 0:
            pass
        else:
            if Slist[I] == "#":
                Rock+=1
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0

    if flag == 1:
        print("No")
    else:
        print("Yes")
    
else:
    now = B-1
    Rock = 0
    flag = 0
    for i in range(D-B):
        I = i+now
        if i == 0:
            pass
        else:
            if Slist[I] == "#":
                Rock+=1
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0
    now = A-1
    Rock = 0
    mass = 0
    Maxmass = 0
    aflag = 0
    for i in range(C-A):
        I = i+now
        if i == 0:
            pass
        else:
            if Slist[I] == "#":
                Rock+=1
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0
                
    now = A-1
    for i in range(D-A):
        I = now + i
        if i == 0:
            mass+=1
        else:
            if Slist[I] == "#":
                Maxmass = max(Maxmass,mass)
                mass = 0
            else:
                mass+=1

    if Maxmass <= 2:
        if mass == 2 and Slist[D] == ".":
            pass
        else:
            flag = 1
    
    if flag == 1:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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


def can_pass(s):
    for i in range(len(s) - 1):
        if s[i] == '#' and s[i+1] == '#':
            return False
    return True


def can_pass2(s):
    for i in range(len(s) - 2):
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
            return True
    return False


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

if C < D:
    if can_pass(S[A-1:C]) and can_pass(S[B-1:D]):
        print('Yes')
    else:
        print('No')
else:
    if can_pass2(S[B-2:C+1]):
        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:
        flag_d = False
        for i in range(A+1, D-1):
            if S[i:i+2] == '##':
                flag_d = True
                break

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

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


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

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

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


    else:
        raise NotImplementedError





    return


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

if __name__ == '__main__':
    main()

Submission status: 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, lastfunuke-1):
        if i == lastfunuke-1 and s[i-1] == '#':
            break
        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:
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]:
        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=map(int,input().split())
s=input()
flag=0
span=0
buf=-5
if(c<d):
    for i in range(a-1,d):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
else:
    for i in range(a-1,c):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
        elif s[i]=='#':
            buf=max([span,buf])
            span=0
        elif b<i<d+1:
            span+=1
    if buf<=2:
        flag=1
        #print(buf)
print('No' if flag==1 else 'Yes')

Submission status: Wrong Answer

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

print(type(S.find('##')))

if ('##' in S) and ( (S.find('##') + 1) < max(C,D)):
    print('No')
elif (D < C) 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()

def max_stone(seq):
  m = 0
  for j in range(len(seq)-1):
    if S[j:j+1] == '##':
      return False
  
  return True
  
def reachable(n):
  for j in range(n, len(S)):
    s = S[j]
    n_sharp = 0
    n_dot = 0
    if s=='.':
      n_dot += 1
      n_sharp = 0
    else:
      n_sharp += 1
      n_dot = 0
    if n_sharp == 2:
      return False
    elif n_dot == 3:
      return True
  return False
  
if C < B:
  if max_stone(S[A-1:C-1]) and max_stone(S[B-1:D-1]):
    print('Yes')
  else:
    print('No')
elif B < C and C < D:
  if max_stone(S[A-1:C-1]) and max_stone(S[B-1:D-1]):
    print('Yes')
  else:
    print('No')
elif B < C and C > D:
  if reachable(A-1) and max_stone(S[A-1:C-1]) and max_stone(S[B-1:D-1]):
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
import re
N, A, B, C, D = input().strip().split(" ")
S = input().strip()

m1 = re.finditer('##', S)
for match in m1:
    if match.start() > int(A) or match.start() < int(D):
        print('no')
        sys.exit()
if int(C) < int(D):
    print('yes')
    sys.exit()
else:
    m2 = re.finditer('...', S)
    for match in m2:
        if match.start() > int(B) and match.start() < int(C):
            print('yes')
            sys.exit()
    print('no')
    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def SI(): return input()

N,A,B,C,D=LI()
st=input()

if C < D:
    if st[A:C].find('##') >= 0 or st[B:D].find('##') >= 0:
        print('No')
    else:
        print('Yes')
else:
    # Cの方がおおきいケース 入れ替わる
    if st[A:C].find('##') >= 0:
        print('No')
    else:
        lft = st.find('##', 0, A)
        if lft == -1:
            lft = 0
        else:
            lft += 2

        rgt = st.find('##', C)
        aru = st[lft:rgt].find('...')
        # print("lft{} rgt{} aru{}".format(lft, rgt, aru))
        if aru == -1:
            print('No')
        else:
            print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
 
n, a, b, c, d = map(int, input().split(' '))
s = input()
 
# 2連続石が無いか調べる
# & 連続空白を調べる
isStone = False
spaceChainCount = 0
threeSpaceCenterIndex = -1
for i in range(len(s)):
    if s[i] == '#':
        if isStone:
            print("No")
            sys.exit()
        isStone = True
        spaceChainCount = 0
    else:
        isStone = False
        spaceChainCount += 1
        if spaceChainCount >= 3:
            threeSpaceCenterIndex = i - 1

# A,Bが入れ替わる & 3連続空白が無い場合はNo
if ((a < b and c > d) or (a > b and c < d)) and threeSpaceCenterIndex < 0:
    print("No")
    sys.exit()

# 3空白がA,B両方より左の場合
if threeSpaceCenterIndex > 0 and threeSpaceCenterIndex < max(a, b):
    print("No")
    sys.exit()

# 通ってきたならOK
print("Yes")

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')
elif c > d and "..." not in S[b-2:max(c,d)]:
  print('No')
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, a, b, c, d = map(int, input().split())
s = input()

for idx, masu in enumerate(s):
    if masu == '.':
        start = idx
        break

# construct rle
rle = list()
last_masu = s[start]
cnt = 0
for masu in s[start:]:
    if masu == last_masu:
        cnt += 1
    else:
        rle.append(cnt)
        last_masu = masu
        cnt = 1
rle.append(cnt)

for idx in range(1, len(rle), 2):
    if rle[idx] > 1:
        print('No')
        exit()

if c > d:
    is_reverse = True
else:
    is_reverse = False

if is_reverse:
    flag = False
    for idx in range(0, len(rle), 2):
        print(idx)
        if rle[idx] > 2:
            flag = True
            break
    if flag:
        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()
rocks = []
flag = True
for i, s in enumerate(S):
    if s == '#':
        rocks.append(i+1)
if 1 in [rocks[i+1] - rocks[i] for i in range(len(rocks) - 1)]:
    flag = False
if flag:
    if C > D:
        r_in_fpath = [r for r in rocks if r in range(B, D)]
        dif_r_in_fpath = [r_in_fpath[i+1] - r_in_fpath[i] for i in range(len(r_in_fpath) - 1)]
        if (B + 1 in rocks or B - 1 in rocks) and len(set(dif_r_in_fpath) - {2, 3}) == 0:
            if D + 1 in rocks or D - 1 in rocks:
                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().rstrip()

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

if s.find('##', b, d + 1) != -1 or s.find('##', a, c + 1) != -1:
    ans = 'No'
elif c < d:
    ans = 'Yes'
elif s[d - 1] == '.':
    ans = 'Yes'
elif s.find('..', b + 1, d) != -1:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

for k in range(N-1):
    if S[k] == S[k+1] == "#":
        print("No")
        exit(0)

if C < D:
    print("Yes")
    exit(0)
for k in range(N-2):
    if S[k] == S[k+1] == S[k+2] == ".":
        if k+2 <= D and k+3 <= C:
            print("Yes")
            exit(0)
print("No")
exit(0)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
a = input()
k = A-1
found = True
ffond = False
b = 0
c = 0
if C <D :
    while  found == True and k < D:
        if a[k] == "#":
            b += 1
        else:
            b = 0
        if b == 2:
            found = False
        k += 1
    if found == False:
        print("No")
    else:
        print("Yes")
else:
    while  found == True and k < C:
        if a[k] == "#":
            b += 1
            if k > B-2 and k <= D:
                c = 0
        else:
            b = 0
            if k > B-2 and k <=D:
                c +=1
        if b == 2:
            found = False
        if c == 3:
            ffond = True
        k += 1
    if found == False or ffond == False:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=list(map(int,input().split()))
s=input().rstrip()
vis=[False]*(n)
vis2=[False]*(n)
flag=1
vis[b-1]=True
for i in range(b-1,n):
    if vis[i]==True:
        if i+1<n:
            if s[i+1]=='.':
                vis[i+1]=True
        if i+2<n:
            if s[i+2]=='.':
                vis[i+2]=True
vis2[a-1]=True
for i in range(a-1,n):
    if vis2[i]==True:
        if i+1<n:
            if s[i+1]=='.':
                vis2[i+1]=True
        if i+2<n:
            if s[i+2]=='.':
                vis2[i+2]=True

if vis[d-1]==True and vis2[c-1]==True and c!=d:
    if d<c:
        if (vis2[d-1]==True and vis2[d-2]==False):
            print('No')
        else:
            print('Yes')
    else:
        print('Yes')
        
else:
    print('No')

Submission status: Wrong Answer

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

if len(s)>n:
    n = len(s)
    s = s[:n]
    
if '##' in s:
    print('No')
else:
    if c-1==d and s[d-2] == '#':
        if '...' in s:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

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

def cd():
    two_block_flg = False
    for s in S[A:C+1]:
        if two_block_flg:
            if s=='#':
                return 'No'
            else:
                two_block_flg = False
        else:
            if s=='#':
                two_block_flg = True
    two_block_flg = False
    for s in S[B:D+1]:
        if two_block_flg:
            if s=='#':
                return 'No'
            else:
                two_block_flg = False
        else:
            if s=='#':
                two_block_flg = True
    return 'Yes'

def dc():
    block_cnt = 0
    space_cnt = 0
    space_flg = False
    for i,s in enumerate(S[A:C+1]):
        if s=='#':
            block_cnt += 1
            if B<=i+A and i+A<D and (not space_flg):
                space_cnt = 0
        else:
            block_cnt = 0
            if B<=i+A and i+A<D and (not space_flg):
                space_cnt += 1
        if block_cnt>=2:
            return 'No'
        if space_cnt>=3:
            space_flg = True
    if space_flg:
        return 'Yes'
    else:
        return 'No'
                


if C<D:
    print(cd())
else:
    print(dc())

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+1])
    if (bdd.find("...") == -1):
        PNO()

PYES()

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(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[A-1:D+1]
    # 抜く場所
    flg2 = (S_cut2.count("...")>=1)
    if flg1 and flg2:
        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)


front = b-1
back = a-1
tof = d-1
tob = c-1

isCan = True
isHide = False

for i in range(front,tof):
    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):
    if(Sn[j] == 1 and Sn[i+1] == 1):
        isCan = False
        break


if(isCan == False):
    isCan = True
    front = a-1
    back = b-1
    tof = d-1
    tob = c-1
    
    for i in range(front,tof):
        if(Sn[i] == 1 and Sn[i+1] == 1):
            isCan = False
            break

        if(i != 0 and 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):
        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:
from sys import stdin

n, a, b, c, d = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()

# A..C 二つの岩 あったらだめ
# B..D二つの岩 あったらだめ
# D < Cのとき、 AがBを追い越せななかったらだめ

ans = "Yes"

rock = 0
for i in range(a, c):
    if '#' == s[i-1]:
        rock += 1
        if rock >= 2:
            ans = "No"
            break
    else:
        rock = 0

rock = 0
for i in range(b, d):
    if '#' == s[i-1]:
        rock += 1
        if rock >= 2:
            ans = "No"
            break
    else:
        rock = 0


space = 0
if d < c:
    ok = 0
    for i in range(b, d):
        if '.' == s[i-1]:
            space += 1
            if space >= 3:
                ok = 1
        else:
            space = 0
    if '.' == s[d-1-1] and '.' == s[d+1-1]:
        ok = 1
    if '.' == s[b-1-1] and '.' == s[b+1-1]:
        ok = 1
    if 0 == ok:
        ans = "No"

print(ans)

Submission status: Wrong Answer

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

if "##" in s[A-1:C]+" "+s[B-1:D]:
  print("No")
  quit()
st,e=0,0
for spl in s.split("##"):
  e += len(spl)
  if st <A<max(C,D)<e:
    break
  st+= len(spl)

if "..." in s[st:e]:
  print("Yes")
elif D<C:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

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

if ('##' in S[a:c-1]) or ('##' in S[b:d-1]): print('No')
else:
    if d < c:
        if ('...' in S[b:d+1]) or ((S[b-2] == '.' or a == b-1) and S[b] == '.'): print('Yes')
        else: print('No')
    else: print('Yes')

Submission status: Wrong Answer

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

S = input()
nS = S[B-1:max(C,D)+1]
AB = S[A-1:B]

if C<D:
    if nS.find("##") != -1 or AB.find("##") != -1:
        print("No")
    else:
        print("Yes")

elif AB.find("##") != -1:
    print("No")
elif nS.find("...") == -1:
    print("No")
else:
    print("Yes")

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]
    BD = S[B-2:D+1]
    print(BD)
    for i in range(len(S)-2):
        if BD[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:
N, A, B, C, D = map(int, input().split())
A -= 1
B -= 1
C -= 1
D -= 1
S = input()

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
#ぬかさないケース
if c<b:
  if s[a:c].find("##")==-1 and s[b:d].find("##")==-1:
    print("Yes")
  else:
    print("No")
elif s[a:d].find("##")==-1:
  if c<d:
    print("Yes")
  else:
    if s[b-1:d+1].find("...")==-1:
      print("No")
    else:
      print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

def solve():
    ac, bd = S[A - 1:C], S[B - 1:D]
    if A < B < D < C:
        return ("..." in bd and "##" not in ac)
    else:
        return ("##" not in ac and "##" not in bd)

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