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:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from copy import copy
from fractions import gcd


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


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


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

n, a, b, c, d = MAP()
s = list(input())

lis3  =[]
lis_iwa=[]

tmp3 = []
tmp_iwa=[]
for i in range(n):
    #print(s[i])
    if s[i] =='.':
        tmp3.append(i)
        if len(tmp_iwa) > 1:
            tmp1 = tmp_iwa.copy()
            lis_iwa.append(tmp1)
            
        tmp_iwa.clear()
    else:
        tmp_iwa.append(i)
        if len(tmp3) > 2:
            tmp=tmp3.copy()
            lis3.append(tmp)
               
        tmp3.clear()
    
    #print(tmp3)


if len(tmp3) > 2:
    lis3.append(tmp3)
if len(tmp_iwa) > 1:
    lis_iwa.append(tmp_iwa)

lis3 = [x for x in lis3 if x[-1] >= b - 1 and x[0] < d - 1]

lis_iwa = [x for x in lis_iwa if x[0] > a - 1 and x[-1] < max(c,d) - 1]

#print(lis3, lis_iwa)

if lis_iwa == []:
    if c < d:
        print('Yes')
    else:
        if lis3 != []:
            print('Yes')
        else:
            print('No')

else:
    print('No')

Submission status: Wrong Answer

Solution code:
import re

n,a,b,c,d = input().split()
li = input()

pat1 = '##'
pat2 = r'\.\.\.'

sm = int(c) if int(c) < int(d) else int(d)
lg = int(c) if int(c) > int(d) else int(d)

sh = li[:sm + 1]
sh = li[int(b) - 2:]
lo = li[:lg]
lo = li[int(a):]
ret = ''
# print(sh)
if re.search(pat1, lo):
    ret = 'No'
else:
    if c > d:
        if re.search(pat2, sh):
            ret = 'Yes'
        else:
            ret = 'No'
    else:
        ret = 'Yes'
    

print(ret)

Submission status: Wrong Answer

Solution code:
import sys

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

S = input()

# ゴールまでに#の連続があるか
for i in range(A,max(C,D)):
    if S[i:i+2]  == '##':
        print('No')
        sys.exit()

# 追い越す必要がある場合
if C > D:
    for i in range(B,C):
        if S[i:i+3] == '...':
            print('Yes')
            sys.exit()
    else:
        print('No')
        sys.exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
import re

n,a,b,c,d = (int(x) for x in input().split())
s = input()
# ss = s.replace('.', '0').replace('#', '1')

if c < d:
    bs1 = s[b:d-1]
    if bs1.find('##') > 0:
        print('No')
    else:
        as1 = s[a:c-1]
        if as1.find('##') > 0:
            print('No')
        else:
            print('Yes')
else:
    bs1 = s[b:d-1]
    if bs1.find('##') > 0:
        print('No')
    elif bs1.find('...') > 0:
        as1 = s[a:c-1]
        if as1.find('##') > 0:
            print('No')
        else:
            print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
lis=list(map(int,input().split()))
S=input()
ans="Yes"
memo=0
if lis[3]<lis[4]:
    #Bを先に行かせてみる
    for i in range(lis[2],lis[4]):
        if S[i:i+2]=="##":
            ans="No"
            break
    #更にAも行かせてみる
    for i in range(lis[1],lis[4]):
        if S[i:i+2]=="##":
            ans="No"
            break
    print(ans)

else:
    #Bの位置に岩を置く
    a=S[:lis[2]-1]
    b=S[lis[2]:]
    S=a+"#"+b
    #Aを先に行かせる。可能なら終了。ダメならBを先に行かせてみる
    for i in range(lis[1],lis[3]):
        if S[i:i+2]=="##":
            ans="No"
            break
    #先にBを行かせる。まず可能か判定
    if ans=="No":
        ans="Yes"
        for i in range(lis[2],lis[4]):
            if S[i:i+2]=="##":
                ans="No"
                break
        for i in range(lis[2],lis[4]-1):
            if S[i:i+3]=="...":
                memo=i+1
                break
        #だめなら終了。可能ならmemoもしくはDに岩を置いてAについて検討
        if ans=="Yes":
            #print(S)
            if memo>0:
                a=S[:memo]
                b=S[memo+1:]
                S=a+"#"+b
            else:
                a=S[:lis[4]-1]
                b=S[lis[4]:]
                S=a+"#"+b
            #print(S)
            a=S[:lis[2]-1]
            b=S[lis[2]:]
            S=a+"."+b
            #print(S,memo)
            for i in range(lis[1],lis[3]-1):
                if S[i:i+2]=="##":
                    ans="No"
                    break
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n, a, b, c, d = map(int, input().split())
s = input()
if '##' not in s:
    ans = 'Yes'
    if c > d:
        if '...' in s:
            ans = 'Yes'
        elif '.' in s[d-2] and '.' in s[d]:
            ans = 'Yes'
        else:
            ans = 'No'
else:
    ans = 'No' 
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
count1 = 0
count2 = 0
if C>D:
    for i in range(B-1,D):
        if S[B-2] == '.' and S[B] =='.':
            count1 = 3
            break
        if S[i] == ".":
            count1 += 1
            if count1 ==3:
                break
        else:
            count1 = 0
    for i in range(A-1,C):
        if S[i] == '#':
            count2 +=1
            if count2 == 2:
                break
        else:
            count2 =0
    if count1 == 3 and count2 !=2:
        print("Yes")
    else:
        print("No")
else:
    for i in range(A-1,D):
        if S[i] == "#":
            count2 += 1
            if count2 == 2:
                break
        else:
            count2 = 0
    if count2 != 2:
        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[c] == '#' or s[d] == '#':
    ans = 'No'
elif s.find('##', b, d + 1) != -1 or s.find('##', a, c + 1) != -1:
    ans = 'No'
elif c < d:
    ans = 'Yes'
elif s[d - 1] == '.' and s[d + 1] != '#':
    ans = 'Yes'
elif s.find('...', b - 1, c) != -1:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun  2 22:01:55 2019

@author: hisaki
"""

import sys
N, A, B, C, D = map(int, input().split())
S = input()
A_start = A -1
B_start = B -1
A_goal = C -1
B_goal = D -1

A_pos = A_start
B_pos = B_start

flag = True
for i in range(A_goal):
    if i< A_goal and S[i] == '#':
        if S[i+1] == '#':
            flag = False

for i in range(B_goal):
    if i< B_goal and S[i] == '#':
        if S[i+1] == '#':
            flag = False
            
if flag == False:
    print ("No")
    sys.exit()
  


if A_pos < B_pos and A_goal < B_goal:
    print ("Yes")
    sys.exit()


if A_pos < B_pos and B_goal < A_goal :
    for i in range(B_pos , B_goal):
        if (S[i-1] == '.' or i-1 == A_pos) and (S[i]== '.') and (S[i+1] == '.'):
            print ("Yes")
            sys.exit()

            
print ("No")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[43]:


N, A, B, C, D = map(int, input().split())
S = input()
"""
7 1 3 7 6
.#..#..
"""


# In[55]:


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

"""
if C<D: # C < D のとき、A~C、B~Dに#が2連続じゃなければYes
    shc = 0
    for s in S[A-1:C]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
        if s == '.':
            shc = 0
    shc = 0
    for s in S[B-1:D]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
        if s == '.':
            shc = 0
elif C>D: # C > Dのとき、順番入れ替えが必要, dotが3個以上並べば、入れ替えられる
    #print(1)
    shc = 0
    dc = 0
    mdc = 0
    for i, s in enumerate(S[A-1:C]): # A~Cで　#が二個以上あればアウト
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
            if dc>0:
                mdc = max(dc, mdc)
                dc = 0
        if s == '.':
            dc += 1
            shc = 0
        if i >= C-A:
            mdc = max(dc, mdc)
    if mdc >= 3:
        #print(2)
        pass
    elif mdc < 3: # A~Cに dotが3個以上並んでいないとき、
        #print(2)
        shc = 0
        for i, s in enumerate(S[0:A:-1]):
            if shc >1:
                l = A-i+1
                break
            if s == '#':
                shc += 1
            if s == '.':
                shc = 0
            if i >= A-1 and shc > 1:
                l = A-i+2
        else:
            l = 0
            
        shc = 0
        for i, s in enumerate(S[C:]):
            if shc >1:
                r = C+i-2
                break
            if s == '#':
                shc += 1
            if s == '.':
                shc = 0
            if i >= N-C-1 and shc > 1:
                r = C+i-2
        else:
            r = N
        
        #print(l, r)
        mdc = 0
        dc = 0
        for i, s in enumerate(S[l:r]):
            #print('{}: {}'.format(i, dc))
            if s == '#':
                if dc>0:
                    mdc = max(dc, mdc)
                    dc = 0
            if s == '.':
                dc += 1
            if i >= r-l-1:
                mdc = max(dc, mdc)
        if mdc < 3:
            ans = 'No'
print(ans)
"""


# In[ ]:

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
s = list(input())
s_a =s[A-1:C]
s_b = s[B-1:D]

count = 0
if C < D :

    for i in range(C-A-1):
        if s_a[i] == "#" and s_a[i+1] == "#" :
            count += 1
    for i in range(D-B-1) :
        if s_b[i] == "#" and s_b[i+1] == "#" : 
            count += 1

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


else :
    s_b[0]="B"
    p = 0
    for i in range(C-A-1):
        if s_a[i] == "#" and s_a[i+1] == "#" :
            count += 1
    for i in range(D-B-1) :
        if s_b[i] == "#" and s_b[i+1] == "#" : 
            count += 1
    
    for i in range(D-B-2):
        if s_b[i] == "." :
            if  s_b[i+1] == "." and s_b[i+2]=="." :
                p += 1
    
    if p >= 1 and count == 0:
        print("Yes")
    else: print("No")

Submission status: Wrong Answer

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

def solveSimple(s, a, b, c, d):     
    if '##' in s[b-1:d]:
        return False 
    if '##' in s[a-1:c]:
        return False
    return True

import re
def solveDifficult(s, a, b, c, d):
    spot = [m.start() for m in re.finditer('\.\.\.', s)]
    
    if len(spot) == 0:
        return False

    for i, it in enumerate(spot):
        if it > a and it > b:
            break

    if solveSimple(s, a, b, it, it+1) and solveSimple(s, it, it+1, d, c):
        return True
    return False

# simple 
if c < d:
    ans = solveSimple(s, a, b, c, d)
    
# solveDifficult
else:
    ans = solveDifficult(s, a, b, c, d)
    
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

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

S = input()

# ゴールまでに#の連続があるか
for i in range(A,max(C,D)):
    if S[i:i+2]  == '##':
        print('No')
        sys.exit()

# 追い越す必要がある場合
if C > D:
    for i in range(B,C):
        if S[i:i+3] == '...':
            print('Yes')
            sys.exit()
    else:
        print('No')
        
        
print('Yes')

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[c] == '#' or s[d] == '#':
    ans = 'No'
elif s.find('##', b, d + 1) != -1 or s.find('##', a, c + 1) != -1:
    ans = 'No'
elif c < d:
    ans = 'Yes'
elif s[d - 1] == '.' and 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:
# 2019/06/02
# AtCoder Grand Contest 034 - A

# For the answer:
# 1-1. Search min(ac) and max(abcd)
# 1-2. Search ## between min and max
# 2. Case:B<C, Left of B is . and (. or C), or exist .. -> Yes

# Def 1 : True is "Case No"
def searchRock(in_l, in_r, in_str, in_tg):
    rcflg = False
    for i in range(in_l - 1, in_r - 1): # Change -2 -> -1
        if in_str[i] == in_tg and in_str[i+1] == in_tg:
            rcflg = True
            break
    return rcflg

def searchPlain(in_l, in_r, in_str, in_tg):
    rcflg = False
    for i in range(in_l - 1, in_r - 2): # Change -2 -> -1
        if in_str[i] == in_tg and in_str[i+1] == in_tg and in_str[i+2] == in_tg:
            rcflg = True
            break
    return rcflg

# Input
n, a, b, c, d = map(int, input().split())
s = input()
ans = ""

# 1. Search ##
if c < b:
    # Search between a and c, b and d
    rflg = searchRock(a, c+1, s, "#")
    if rflg == True:
        ans = "No"
    else:
        rflg = searchRock(b, d+1, s, "#")
        if rflg == True:
            ans = "No"

else:
    # Search between a and max(c, d)
    rflg = searchRock(a, max(c, d)+1, s, "#")
    if rflg == True:
        ans = "No"
    
# 2. Check around b
if ans != "No":
    if (b < c and d < c):
        # Case: B < D < C 
        pflg = searchPlain(b-1, d-1, s, ".")
        if pflg == False:
            if s[b-2] == "." and s[b] == ".":
                ans = "Yes"
            else:
                ans = "No"
        else:
            ans = "Yes"
    else:
        ans = "Yes"

# Output
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from copy import copy
import numpy as np
from numpy.fft import fft, ifft
from fractions import gcd


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


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


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

n, a, b, c, d = MAP()
s = list(input())

lis3  =[]
lis_iwa=[]

tmp3 = []
tmp_iwa=[]
for i in range(n):
    #print(s[i])
    if s[i] =='.':
        tmp3.append(i)
        if len(tmp_iwa) > 1:
            tmp1 = tmp_iwa.copy()
            lis_iwa.append(tmp1)
            
        tmp_iwa.clear()
    else:
        tmp_iwa.append(i)
        if len(tmp3) > 2:
            tmp=tmp3.copy()
            lis3.append(tmp)
               
        tmp3.clear()
    
    #print(tmp3)


if len(tmp3) > 2:
    lis3.append(tmp3)
if len(tmp_iwa) > 1:
    lis_iwa.append(tmp_iwa)



flag = 0

lis3 = [x for x in lis3 if x[0] >= b - 1 and x[0] < d - 1]

lis_iwa = [x for x in lis_iwa if x[0] > a - 1 and x[-1] < max(c,d) - 1]

#print(lis3, lis_iwa)

if lis_iwa == []:
    if c < d:
        print('Yes')
    else:
        if lis3 != []:
            print('Yes')
        else:
            print('No')

else:
    print('No')

Submission status: Wrong Answer

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

    # print(S[A:D:])
    # print(S[A:D:].count("##"))
    # print(S[A:D:].count("#.#"))
    # print(S[A:D:].count("#..#"))

    answer = "-1"

    if C < D:
       if S[A:D:].count("##") >= 1:
           answer = "No"
       else:
           answer = "Yes"
    else:
       if S[B-1:D+2:].count("...") >= 1:
           answer = "Yes"
       else:
           answer = "No"

    print(answer)

Submission status: Wrong Answer

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


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


def search(start, goal):
    for i in range(start, goal - 2):
        if s[i] + s[i + 1] == '##':
            return False
    return True


def search3(start, goal):
    for i in range(start, goal - 3):
        if s[i] + s[i + 1]+s[i+2] == '...':
            return True
    return False


if c < d:
    if search(a, c) and search(b, d):
        print('Yes')
    else:
        print('No')

else:
    if search3(b-1, d+1)and search(a,c):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
## AからＣ　ＢからＤに移動させたい
## C<D なら簡単

N,A,B,C,D = map(int,input().split())
S = input()
flag = 0
obs = []
esc = []
ans = 1

#ＡとＢで小さいほうを low
if A<B:
    low = A
    mid1 = B
else:
    low = B
    mid1 = A
#ＣとＤで大きいほうをhigh
if C<D:
    high = D
    mid2 = C
else:
    high = C
    mid2 = D



for i in range(low,high):
     if S[i]=="#" and flag == 1:
         obs.append(i)
         flag = 0
     elif S[i] == "#":
         flag = 1
     else: flag = 0

 # obsに通れない位置を入力
flag = 0
for i in range(low,high):
      if S[i]=="." and flag == 2:
          esc.append(i)
          flag = 0
      elif S[i] == ".":
          flag += 1
      else:
          flag = 0
if len(obs)!=0:
    ans = 0

if D<C :
    flag = 0
    for i in range(len(esc)):
        if mid1< esc[i] <= mid2+1:
            flag = 1
    if flag == 0:
        ans = 0


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

Submission status: Wrong Answer

Solution code:
import math
import numpy as np


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


def main():
    _, A, B, C, D = inputs()
    S = input()
    maxDst = max(C, D)
    courseA = S[A:C]
    courseB = S[B:D]
    cnt = 0
    ans = []
    for i in courseB:
        if i == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            ans.append(False)
            break
    else:
        ans.append(True)
    cnt = 0
    for i in courseA:
        if i == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            ans.append(False)
            break
    else:
        ans.append(True)
    if maxDst == C:
        cnt = 0
        for i in S[B-2:D+2]:
            if i == '.':
                cnt += 1
            if cnt == 3:
                ans.append(True)
                break
        else:
            ans.append(False)

    if all(ans):
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#Python標準入出力

import numpy as np

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

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

N = Masu[0]
A = Masu[1]
B = Masu[2]
C = Masu[3]
D = Masu[4]

S = Root

At = A-1
Bt = B-1
Ct = C-1
Dt = D-1

Judge = True

#Answer 1 パターン入れ込み

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


threePoints = False

for k in range(N):
    if k < 1:
        gg = 0
    elif S[k] == "." and S[k-1] == "." and S[k-2] == ".":
        # print("roop{}".format(k))
        if Dt+1 > k:
            threePoints = True

# print(threePoints)

for j in range(Masu[0]):
    if S[j] == "#" and S[j-1] == "#":
        Judge = False

    if Ct == j+1 and Dt == j+1-1 and Root[j-2] == "#" and (not threePoints):
        Judge = False
    if Ct == j+1 and Root[j-1] == "#" and Dt == j+1-2 and (not threePoints):
        Judge = False

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

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









#Answer 2 動かし

# Sunuke = At
# Funuke = Bt
# throuth = 0
#
#
# if C < D:
#     for i in range(N-Funuke):
#
#         ii = i+Bt
#
#         # print("current {0}: funuke: {1}".format(ii,Funuke))
#         if Funuke == Dt:
#             break
#
#         elif S[ii] == "#" and S[ii+1] == "#":
#             Judge = False
#             break
#
#         elif S[ii] == "#":
#             throuth = 0
#
#         elif S[ii+1] == ".":
#             Funuke = Funuke+1
#
#         elif S[ii+1] == "#":
#             Funuke = Funuke+2
#
#     #
#     # print("Funuke: {}".format(Funuke))
#     # print("Sunuke: {}".format(Sunuke))
#     # print(At)
#     if Judge:
#         for j in range(N-Sunuke):
#
#             jj = j+At
#             # print("current {0}: Sunuke: {1}".format(jj, Sunuke))
#
#             if Sunuke == Ct:
#                 break
#
#             elif S[jj] == "#" and jj + 1 == Funuke:
#                 Judge = False
#                 break
#
#             elif S[jj] == "#":
#                 throuth = 0
#
#             elif S[jj + 1] == ".":
#                 Sunuke = Sunuke + 1
#
#             elif S[jj + 1] == "#" or jj+1 == Funuke:
#                 Sunuke = Sunuke + 2
#
#     #
#     # print(Sunuke)
#     # print(Funuke)
#     #
#
# else:
#     Rock = []
#     for i in range(Masu[0]):
#         if Root[i] == "#":
#             Rock.append(i + 1)
#
#     threePoints = False
#
#     for k in range(N):
#         if k < 1:
#             gg = 0
#         elif S[k] == "." and S[k - 1] == "." and S[k - 2] == ".":
#             # print("roop{}".format(k))
#             if D+1 > k:
#                 threePoints = True
#
#     # print(threePoints)
#
#     for j in range(Masu[0]):
#         if S[j] == "#" and S[j - 1] == "#":
#             Judge = False
#
#         if C == j + 1 and D == j + 1 - 1 and Root[j - 2] == "#" and (not threePoints):
#             Judge = False
#         if C == j + 1 and Root[j - 1] == "#" and D == j + 1 - 2 and (not threePoints):
#             Judge = False
#
#             # if Masu[3] == j+1:
#             #     for p in range(j):
#             #         if Masu[4] == p+1 and Root[p-1] == "#":
#             #             Judge = False
#
# if Judge:
#     print("Yes")
# else:
#     print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

S = input()

# ゴールまでに#の連続があるか
for i in range(A,max(C,D)):
    if S[i:i+2]  == '##':
        print('No')
        sys.exit()

# 追い越す必要がある場合
if C > D:
    for i in range(B,C):
        if S[i:i+3] == '...':
            print('Yes')
            sys.exit()
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

N, A, B , C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = input().strip().translate(str.maketrans({'#': '1', '.': '0'}))
ss = [int(c) for c in S ]

ans = 'No'

# 3つ以上の空間があれば順序を入れ替えられる
if D > C:
    ans = 'YES'   

elif D < C:
    for i in range(D - 2):
        
        if i < B - 1:
            continue
        
        if ss[i] == 0 and ss[i+1] == 0 and ss[i+2] == 0 :
            ans = 'YES'

# 連続して岩があるとき（＝解けない）
for i in range(N - 1):
        
    if ss[i] == 1  and ss[i+1] == 1 :
        ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
def passable(road):
    n=len(road)
    for i in range(n-1):
        block=road[i:i+2]
        if block=='##':
            return False
    return True

def blank(road):
    n=len(road)
    road='.'+road+'.'
    for i in range(1,n+1):
        block=road[i-1:i+2]
        if block=='...':
            return True
    return False

def judge(A,B,C,D,S):
    if C<D:
        return passable(S[A:C+1]) and passable(S[B:D+1])
    else:
        return passable(S[A:C+1]) and passable(S[B:D+1]) and blank(S[B:D+1])

N,A,B,C,D=map(int,input().split())
S=input()
if judge(A-1,B-1,C-1,D-1,S):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(input())
last = ""
for i in range(a, c):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
last = ""
for i in range(b, d):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
last = ""
if c > d:
    flag = True
    s[b - 1] = "#"
    for i in range(a, c):
        if last == "#" and s[i] == "#":
            flag = False
        last = s[i]
    s[b - 1] = "."
    count = 0
    for i in range(b - 1, d):
        if s[i] == ".":
            count += 1
            if count == 3:
                flag = True
        else:
            count = 0
    if flag:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

n, a, b, c, d = map(int, input().split())
s = input()
if '##' not in s:
    ans = 'Yes'
    if c > d:
        if '...' in s:
            ans = 'Yes'
        else:
            ans = 'No'
else:
    ans = 'No' 
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[43]:


N, A, B, C, D = map(int, input().split())
S = input()
"""
7 1 3 7 6
.#..#..
"""


# In[55]:


ans = 'Yes'
if '##' in S[A-1:C] or '##' in S[B-1:D]:
    ans = 'No'
else:
    if C<D:
        pass
    else:
        if '...' in S[B-2:C+1]:
            pass
        else:
            ans = 'No'
print(ans)

"""
if C<D: # C < D のとき、A~C、B~Dに#が2連続じゃなければYes
    shc = 0
    for s in S[A-1:C]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
        if s == '.':
            shc = 0
    shc = 0
    for s in S[B-1:D]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
        if s == '.':
            shc = 0
elif C>D: # C > Dのとき、順番入れ替えが必要, dotが3個以上並べば、入れ替えられる
    #print(1)
    shc = 0
    dc = 0
    mdc = 0
    for i, s in enumerate(S[A-1:C]): # A~Cで　#が二個以上あればアウト
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
            if dc>0:
                mdc = max(dc, mdc)
                dc = 0
        if s == '.':
            dc += 1
            shc = 0
        if i >= C-A:
            mdc = max(dc, mdc)
    if mdc >= 3:
        #print(2)
        pass
    elif mdc < 3: # A~Cに dotが3個以上並んでいないとき、
        #print(2)
        shc = 0
        for i, s in enumerate(S[0:A:-1]):
            if shc >1:
                l = A-i+1
                break
            if s == '#':
                shc += 1
            if s == '.':
                shc = 0
            if i >= A-1 and shc > 1:
                l = A-i+2
        else:
            l = 0
            
        shc = 0
        for i, s in enumerate(S[C:]):
            if shc >1:
                r = C+i-2
                break
            if s == '#':
                shc += 1
            if s == '.':
                shc = 0
            if i >= N-C-1 and shc > 1:
                r = C+i-2
        else:
            r = N
        
        #print(l, r)
        mdc = 0
        dc = 0
        for i, s in enumerate(S[l:r]):
            #print('{}: {}'.format(i, dc))
            if s == '#':
                if dc>0:
                    mdc = max(dc, mdc)
                    dc = 0
            if s == '.':
                dc += 1
            if i >= r-l-1:
                mdc = max(dc, mdc)
        if mdc < 3:
            ans = 'No'
print(ans)
"""


# In[ ]:

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
if C < D:
    if S[C-1:].count('##') > 0:
        print('No')
    else:
        print('Yes')
else:
    if S[C-1:].count('##') == 0 and S[B-1:D].count('...') > 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def snum(S):
    # bcの数
    origS = S[:]
    bccnt = 0
    i = 0
    bcIndex = []
    base = 0
    while "BC" in S[i:]:
        S = S[i:]
        bcIndex.append( S.find("BC")  + base)
        i = S.find("BC") + 2
        base += i
 
 
    aIndex = []
    i = 0
    base = 0
    S = origS[:]
    while "A" in S[i:]:    
        S = S[i:]
        aIndex.append(S.find("A") + base)
        i = S.find("A") + 1
        base += i
 
 
    ans = 0
    ai = 0
    bc = 0
    nokoriBC = len(bcIndex)
    nowA = 0
 
    subS = [0] * len(origS)
    for a in aIndex:
        subS[a] = 1
    for b in bcIndex:
        subS[b] = 2
 
    for i in range(len(origS)):
        if subS[i]  == 1:
            nowA += 1
        elif subS[i] == 2:
            ans += nowA * nokoriBC
            nowA = 0
            nokoriBC -= 1
            if (nokoriBC == 0): break
    return ans
    return (aIndex, bcIndex)
 
S = input()
pos = []
i = 0
while "CC"  in S[i:] or "BB" in S[i:] or "CB" in S[i:]:
    S = S[i:]
    # a = min( S.find("CC"), S.find("BB"))
    c = (S.find("CC"))
    b = S.find("BB")
    a = 0
    if ( c != -1 and b != -1) :
        a = min(b,c)
    elif b == -1:
        a = c
    else :
        a = b
 
    pos.append( S[i:a+1]  )
    i = a+2
pos.append(S[i:])
# print(kpos)
ans = 0
for p in pos:
    tmp = snum(p)
    ans += tmp
print(ans)

Submission status: Wrong Answer

Solution code:
# A問題
N, A, B, C, D = map(int, input().split())
S = input()
flag = False
S = S[A-1:]

if C < D:   # AがBを飛び越えない時
    if S.count("##") > 0:
        if S[A-1:C-1].count("##") > 0 or S[B-1:D-1].count("##") > 0:
            flag = False
        else:
            flag = True
    else:
        flag = True
else:   # AがBを飛び越えるとき
    if S.count("##") > 0:
        flag = False
    else:
        if S[B-1:D+1].count("..."):
            flag = True
        else:
            flag = False
        
if flag:
    print("Yes")
else:
    print("No")