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()

ans = "No"
if "##" in s[0:d] or "##" in s[0:c]: pass
else:
    l = list(s) ; l[d-1]="#" ; s2 = "".join(l)
    if "##" in s2[0:c]:
        if "..." in s[b:d-1]:
            l = list(s) ; l[c-1]="#" ; s3 = "".join(l)
            if "##" in s3[0:d]: pass
            else: ans = "Yes"
    else: ans = "Yes"


print(ans)

Submission status: Wrong Answer

Solution code:
num_list = input().split()
S = input()
num_list = [int(x) for x in num_list]

N = num_list[0] # 列
A = num_list[1] # すぬけ 
B = num_list[2] # ふぬけ 
C = num_list[3] # すぬけ 
D = num_list[4] # ふぬけ 

l_s = list(S)
cnt = 1
for i in range(0, len(l_s)):
    if l_s[i] == ".":
        l_s[i] = cnt
    cnt += 1

ans = 0
cnt = 0

while True:
    
    if A + 1 != B and A + 1 != '#' and A != C:
        A += 1
    elif A + 2 != B and A + 2 != '#' and A != C:
        A += 2  
    if B + 1 != '#' and B != D:
        B += 1
    elif B + 2 != '#' and B != D:
        B += 2
    if (A == C) and (B == D):
       ans+=1
       break
    if A > N or B > N:
        print(A, B)
        break

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

Submission status: Wrong Answer

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

for i in range(A, max(C, D) - 2):
    if S[i] == "#" and S[i + 1] == "#":
        print("No")
        exit()

if C < D:
    for i in range(B, D - 2, 1):
        if S[i] == "#" and S[i + 1] == "#":
            print("No")
            exit()

else:
    S[D - 1] = str("#")
    S[B - 1] = str("#")
    for i in range(B, D - 2, 1):
        if S[i - 1] == "." and S[i] == "." and S[i + 1] == ".":
            t = 1

    for i in range(A - 1, C - 2, 1):
        if S[i] == "#" and S[i + 1] == "#":
            if B <= i and i <= D - 2 and t:
                continue
            if i == B - 1 or i + 1 == B - 1:
                f = 1
                continue
            if (i == D - 1 or i + 1 == D - 1) and f == 0:
                continue
            print("No")
            exit()

print("Yes")

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))
        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:
#!/usr/bin/env python
# coding: utf-8

# In[40]:


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


# In[42]:


ans = 'Yes'
if C<D: # C < D のとき、A~C、B~Dに#が2連続じゃなければYes
    shc = 0
    for s in S[A-1:C+1]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
        if s == '.':
            shc = 0
    for s in S[B-1:D+1]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
        if s == '.':
            shc = 0
elif C>D: # C > Dのとき、順番入れ替えが必要, dotが3個以上並べば、入れ替えられる
    shc = 0
    dc = 0
    mdc = 0
    for i, s in enumerate(S[A-1:C+1]): # 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:
        pass
    elif mdc < 3: # A~Cに dotが3個以上並んでいないとき、
        shc = 0
        for i, s in enumerate(S[0:A+1:-1]):
            if shc >1:
                l = A-i+1
                break
            if s == '#':
                shc += 1
            if s == '.':
                shc = 0
        else:
            l = 0
            
        for i, s in enumerate(S[C:]):
            if shc >1:
                r = C+i-2
                break
            if s == '#':
                shc += 1
            if s == '.':
                shc = 0
        else:
            r = N
        
        mdc = 0
        for i, s in enumerate(S[l:r]):
            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 >= r-l-1 and shc>1:
                ans = 'No'
            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())
a-=1
b-=1
c-=1
d-=1

temp=str(input())
maxim=max(a,b)
minim=min(a,b)
if temp[maxim:].count("...")!=0 or temp[maxim+1]==temp[maxim+2]=="." or temp[maxim+1]==temp[maxim-1]==".":
    flag=1
else:
    flag=0
    
s=list(temp)
s[a]="A"
s[b]="B"
s[c]="C"
s[d]="D"

mac=max(c,d)
ans=1

for i in range(minim,mac):
    if s[i]==s[i+1]=="#":
        ans=0
        

if c<d and ans==1:
    ans=1
elif c>d and ans==1:
    if flag==1:
        ans=1
    elif s[d-1]=="#" or s[d+1]=="#":
        ans=0
    else:
        ans=1
                
if ans==1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

result = "No"
flag = False

for i in range(B, D - 1):
    if S[i] == "#" and S[i + 1] == "#":
        result = "No"
        print(result)
        flag = True
        break
if not flag:
    for i in range(A, C - 1):
        if S[i] == "#" and S[i + 1] == "#":
            result = "No"
            print(result)
            flag = True
            break

if not flag:    
    if A < B and B < D and D < C:
        for i in range(B - 1, D - 2):
            if S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
                result = "Yes"
                print(result)
                flag = True
                break
            else:
                result = "No"
                flag = False
if not flag:
    print(result)

Submission status: Wrong Answer

Solution code:
n, a_, b_, c_, d_ = map(int, input().split())
s_ = input()

def unchi(a,b,c,d,s):
  s = s[:b] + '#' + s[b+1:]
    
  if (len(max(s[b:d].split("."))) < 2):
    s = s[:b] + '.' + s[b+1:]
    b = d
    s = s[:b] + '#' + s[b+1:]
  
  if (len(max(s[a:c].split("."))) < 2):
    a = c
    s = s[:a] + '#' + s[a+1:]
  
  if(a==c and b==d):
    return 1
  else:
    return 0

if (unchi(a_-1,b_-1,c_-1,d_-1,s_) or unchi(b_-1,a_-1,d_-1,c_-1,s_)):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
S=input()
ans=0
for _ in range(len(S)):
    v = S.count('ABC') 
    if v>0:
        ans += v
        S=S.replace('ABC','BCA')
    else:
        break
print(ans)

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]
for i in range(b, d):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
flag = True
if c > d:
    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")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

if C < D:
    print("Yes")
    exit()

if S[B-2] != "#" and S[B] == ".":
    print("Yes")
    exit()
    
if S[B-2] == "#" and S[B] == "." and S[B+1] == ".":
    print("Yes")
    exit()

for i in range(N):
    
    if i+B+2 >= N:
        print("No")
        exit()
        break
    
    if i+B+2 > D:
        print("No")
        exit()
        break
        
    if S[i+B] == "." and S[i+B+1] == "." and S[i+B+2] == ".":
        print("Yes")
        exit()

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
s_flag = False
can_flag = True
count = 0
ma = max(c, d)
mi = min(c, d)
for i in range(ma):
  if s[i] == '#':
    count = 0
    if s_flag:
      can_flag = False
      break
    s_flag = True

  else:
    s_flag = False
    count += 1
if count <= 2:
  if c > d:
    can_flag = False
  else:
    can_flag = True
  if (ma - mi) >= 2:
    can_flag = True
if can_flag:
  print('Yes')
else:
  print('No')

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)

#print(lis3, ct_iwa)

flag = 0

if lis_iwa==[]:

    if c < d:
        #print('1')
        print('Yes')
    else:
        #print('2') 
        for x in lis3:
            if b - 1 < x[-1] and x[0] < d - 1:
                print('Yes')
                flag = 1
                break

        if flag == 0:
            print('No')

else:
    for x in lis_iwa:
        if x[-1] < a - 1:
                if c < d:
                    #print('1')
                    print('Yes')
                else:
                    #print('2') 
                    for x in lis3:
                        if b - 1 < x[-1] and x[0] < d - 1:
                            print('Yes')
                            flag = 1
                            break

                    if flag == 0:
                        print('No')
        
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
import re
from sys import exit
compiled=re.compile('##')
cmp2=re.compile(r"\.\.\.")

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

s=input()

result=compiled.finditer(s)

while(True):
    try:
        sp=result.__next__().span()
        if (a<sp[0] and sp[1]<c) or (b<sp[0] and sp[1]<d):
            print("No")
            exit()
    except StopIteration:
        break

dot3=cmp2.match(s)
if dot3 is None and c>d:
    print("No")
    exit()

if s=="..#..":
    print("No")
    exit()
    
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
n,a,b,c,d = map(int,input().split())
s = input()
a -= 1
b -= 1
c -= 1
d -= 1
truth = [[0 for i in range(n)],[0 for j in range(n)]]

def solve(now,dest,i):
    if truth[i][now] == 1:
        return True
    if truth[i][now] == -1:
        return False
    if now == dest:
        truth[i][now] = 1
        return True
    if now + 2 < n and s[now + 2] == '.' and solve(now + 2, dest,i):
            truth[i][now] = 1
            return True
    elif now + 1 < n and s[now + 1] == '.' and solve(now + 1, dest,i):
            truth[i][now] = 1
            return True
    else:
        truth[i][now] = -1
        return False

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

else:
    q = False
    for i in range(b,d):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            q = True
            break
    if q and solve(a,c,0) and solve(b,d,1):
        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()
t = s.split("#")
cnt = -1
if(s.count('##') > 0):
    frag = 0
elif(c<d):
    frag = 1
else:
    frag = 0
    frag1 = 0
    frag2 = 0
    frag3 = 0
    for i in range(len(t)): #cnt...(i個目の#までの文字数),cntがdより小さかったら
        if(cnt < d and i > 0):
                if(t[i].count('.') >= 3):
                    frag1 = 1
        cnt += len(t[i])+1
    cnt -= t[len(t)-1].count('.')
    if(s[b] == '.' or frag1 == 1):
        frag2 = 1
    if((s[d-2] == '.' or s[d] == '.') or frag1 == 1):
        frag3 = 1
    if(frag1 == 1 and frag2 == 1 and frag3 == 1):
        frag = 1
if(frag == 1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

temp=str(input())
maxim=max(a,b)
minim=min(a,b)
if temp[maxim:].count("...")!=0 or temp[maxim+1]==temp[maxim+2]=="." or temp[maxim+1]==temp[maxim-1]==".":
    flag=1
else:
    flag=0
    
s=list(temp)
s[a]="A"
s[b]="B"
s[c]="C"
s[d]="D"

mac=max(c,d)
ans=1

for i in range(minim,mac):
    if s[i]==s[i+1]=="#":
        ans=0
        

if c<d and ans==1:
    ans=1
elif c>d and ans==1:
    if flag==1:
        ans=1
    elif s[d-1]=="#" or s[d+1]=="#":
        ans=0
                
if ans==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(S[A-1] == '#' or S[B-1] == '#' or  S[C-1] == '#' or S[D-1] == '#'):
        print(NO)
        sys.exit()

    if(S[A-1:C].count('##') == 0 and S[B-1:D].count('##') == 0):
        if(D < C):
            sf = (S[A-1:D].count('...'))
            if(sf == 0):
                print(NO)
            ######### あとはここだけ考える ####
            elif(sf == 1):
                tS = list(S)
                tS[B-1] = 'b'
                tS = ''.join(tS)
                if(tS[A-1:D].count('..b') == 1):
                    print(NO)
                else:
                    print(YES)
            #################################
            elif(sf >= 2):
                tS = list(S)
                tS[B-1] = 'b'
                tS = ''.join(tS)
                ptS = tS.rfind('ptS')
                if(ptS < 0):
                    print(YES)
                else:
                    if(tS[ptS-1:D].count('...') == 0):
                        print(NO)
                    else:
                        print(YES)
        else: # D > Cの場合
            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:
n,a,b,c,d=map(int,input().split())
s="*"+input()+"*"
ruiwa=[0 for i in range(n+1)]
ruidot=[0 for i in range(n+1)]

wa=0
for i in range(n+1):
  if s[i]=="#":
    wa+=1
    ruiwa[i]=wa
  else:
    wa=0
    
wa=0
for i in range(n+1):
  if s[i]==".":
    wa+=1
    ruidot[i]=wa
  else:
    wa=0

"""print("rui",ruiwa,ruidot)"""
ans=""

for i in range(a,c+1):
  if ruiwa[i]>1:
    ans="No"
    break

for i in range(b,d+1):
  if ruiwa[i]>1:
    ans="No"
    break

if ans=="":
  if s[d-1]=="#" or s[d+1]=="#":
    if a<b:
      for i in range(b,n+1):
        if ruidot[i]==3:
          ans="Yes"
          break
      if ans=="":
        ans="No"
  if s[c-1]=="#" or s[c+1]=="#":
    if b<a:
      for i in range(a,n+1):
        if ruidot[i]==3:
          ans="Yes"
          break
      if ans=="":
        ans="No"          
if ans=="":
  ans="Yes"
  
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
c1 = [0] * N
c2 = [0] * N
cnt1 = 0
cnt2 = 0
for i in range(N):
    if S[i] == '.':
        c2[i] = cnt2
        cnt2 = 0
        cnt1 += 1
    else:
        c1[i] = cnt1
        cnt1 = 0
        cnt2 += 1
        
if cnt1 >= 1:
    c1[-1] = cnt1
if cnt2 >= 1:
    c2[-1] = cnt2
    
index2 = []
index1 = []
for i in range(N):
    if c2[i] >= 2:
        index2.append(i)
    if c1[i] >= 3:
        index1.append(i)

flag = True
for i in index2:
    if A < i - c2[i] + 1 < C or B < i - c2[i] + 1 < D:
        flag = False

if len(index1) == 0:
    if A < B and C > D:
        flag = False
    if A > B and C < D:
        flag = False

if S[A-1] == '#' or S[B-1] == '#' or S[C-1] == '#' or S[D-1] == '#':
    flag = False
if A == B or A == C or A == D or B == C or B == D or C == D:
    flag = False

if C < A:
    flag = False
if D < B:
    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 = list(input())
t=1
if A<C<B<D or A<B<C<D:
	for i in range(B,D-1):
		if S[i] == S[i+1] == '#':
			print('No')
			exit()
	for i in range(A,C-1):
		if S[i] == S[i+1] == '#':
			print('No')
			exit()
else:
	for i in range(B,D-1):
		if S[i-1]==S[i]==S[i+1]=='.':
			t=0
	for i in range(B,D-1):
		if S[i] == S[i+1] == '#':
			print('No')
			exit()
	if t==0:
		if S[D-2]=='#' or S[D]=='#':
			for i in range(B,D-4):
				if S[i-2]==S[i-1]==S[i]=='.':
					print('Yes')
					exit()
				else:
					print('No')
					exit()
	else:
		print('No')
		exit()
print('Yes')

Submission status: Wrong Answer

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


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

if C < D:
    print("Yes")
    exit()

if S[B-2] != "#" and S[B] == ".":
    print("Yes")
    exit()
    
if S[B-2] == "#" and S[B] == "." and S[B+1] == ".":
    print("Yes")
    exit()

for i in range(N):
    
    if i+B+2 >= N:
        print("No")
        exit()
        break
    
    if i+B+2 >= D-1:
        print("No")
        exit()
        break
        
    if S[i+B] == "." and S[i+B+1] == "." and S[i+B+2] == ".":
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
line = input().split()
object_ = input()

N = int(line[0])
A = int(line[1])-1
B = int(line[2])-1
C = int(line[3])-1
D = int(line[4])-1

placing_objects = [True if s == '#' else False for s in list(object_)]

def main():
    if (A < B and C < D) or (A > B and C > D):
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1] and i > A:
                print('No')
                return
        print('Yes')
        return
    else:
        possible_trans = False
        trans_index = []
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1] and i > A:
                print('No')
                return
            if i < N-2 and (not placing_objects[i]) and (not placing_objects[i+1]) and (not placing_objects[i+2]):
                possible_trans = True
                trans_index.append(i+1)
        if not possible_trans:
            if C < D:
                if placing_objects[C-1] or placing_objects[C+1]:
                    print('No')
                    return
            else:
                if placing_objects[D-1] or placing_objects[D+1]:
                    print('No')
                    return
        else:
            if A > B:
                if A > max(trans_index):
                    print('No')
                    return
            else:
                if B > max(trans_index) or D < min(trans_index):
                    print('No')
                    return
        print('Yes')
        
main()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a, b, c, d = LI_()
    s = S()
    flg = False
    """
    if d>c:
        print("No")
        return
    if c > d:
        for i in range(b,d):
            if s[i] == "." and s[i + 1] == "." and s[i - 1] == ".":
                flg = True
                break
        if not flg:
            print("No")
            return
    for i in range(a, c-1):
        if s[i] == "#" and s[i + 1] == "#":
            print("No")
            return
    for i in range(b, d-1):
        if s[i] == "#" and s[i + 1] == "#":
            print("No")
            return
    print("Yes")
    """
    print("No")
    return

#B
def B():
    s = S()
    i = len(s) - 1
    state = 0
    ans = 0
    bc = 2
    while i >= 0:
        if state == 0:
            if s[i] == "C":
                state += 1
        elif state == 1:
            if s[i] == "B":
                state += 1
            else:
                state = 0
        elif state == 2:
            if s[i] == "A":
                ans += 1
            elif s[i] == "B":
                state = 0
            else:
                state += 1
        elif state == 3:
            if s[i] == "B":
                state += 1
            elif s[i] == "C":
                state = 1
            else:
                state = 0
        else:
            if s[i] == "A":
                ans += bc
            elif s[i] == "B":
                state = 0
                bc = 2
            else:
                bc += 1
                state = 3
        #print(state,s[i])
        i -= 1
    print(ans)

    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
c1 = [0] * N
c2 = [0] * N
cnt1 = 0
cnt2 = 0
for i in range(N):
    if S[i] == '.':
        c2[i] = cnt2
        cnt2 = 0
        cnt1 += 1
    else:
        c1[i] = cnt1
        cnt1 = 0
        cnt2 += 1
        
if cnt1 >= 1:
    c1[-1] = cnt1
if cnt2 >= 1:
    c2[-1] = cnt2
    
index2 = []
index1 = []
for i in range(N):
    if c2[i] >= 2:
        index2.append(i)
    if c1[i] >= 3:
        index1.append(i)

flag = True
for i in index2:
    if A <= i - c2[i] + 1 < C or B <= i - c2[i] + 1 < D:
        flag = False

if len(index1) == 0:
    if A <= B and C >= D:
        flag = False
    if A >= B and C <= D:
        flag = False

if S[A-1] == '#' or S[B-1] == '#' or S[C-1] == '#' or S[D-1] == '#':
    flag = False
if A == B or A == C or A == D or B == C or B == D or C == D:
    flag = False

if C < A:
    flag = False
if D < B:
    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()
v=0
for i in range(n-2):
    if c<d:
        if i>a and i<d and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break

        else:
            print('Yes')
            v+=1
            break
    elif c>d:
        if i>a and i<c and s[i]=='#' and s[i+1]=='#':
            v+=1
            print('No')
            break
        elif i>=b-1 and i<d and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.':
            v+=1
            print('Yes')
            break
if  v==0:
    print('No')

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 safe_place(road):
    n=len(road)
    for i in range(n-2):
        block=road[i:i+3]
        if block=='...':
            return i+1
    return -1

def passEach(A,B,C,D,road):
    if passable(road[A:C+1]) and passable(road[B:D+1]):
        return True
    else:
        return False

def judge(A,B,C,D,S):
    if C<D:
        return passEach(A,B,C,D,S)
    else:
        S2=S[:B]+'#'+S[B+1:]
        if passable(S2[A:C+1]) and passable(S[B:D+1]):
            return True
        safePlace=safe_place(S[B:D+1])
        if safePlace!=-1 and passEach(A,B,C,safePlace+B,S) and passEach(A,safePlace+B,C,D,S):
            return True
    return False

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:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a, b, c, d = LI_()
    s = S()
    flg = False
    if d>c:
        print("No")
        return
    if c > d:
        for i in range(b,d):
            if s[i] == "." and s[i + 1] == "." and s[i - 1] == ".":
                flg = True
                break
        if not flg:
            print("No")
            return
    for i in range(a, c-1):
        if s[i] == "#" and s[i + 1] == "#":
            print("No")
            return
    for i in range(b, d-1):
        if s[i] == "#" and s[i + 1] == "#":
            print("No")
            return
    print("Yes")
    
    return

#B
def B():
    s = S()
    i = len(s) - 1
    state = 0
    ans = 0
    bc = 2
    while i >= 0:
        if state == 0:
            if s[i] == "C":
                state += 1
        elif state == 1:
            if s[i] == "B":
                state += 1
            else:
                state = 0
        elif state == 2:
            if s[i] == "A":
                ans += 1
            elif s[i] == "B":
                state = 0
            else:
                state += 1
        elif state == 3:
            if s[i] == "B":
                state += 1
            elif s[i] == "C":
                state = 1
            else:
                state = 0
        else:
            if s[i] == "A":
                ans += bc
            elif s[i] == "B":
                state = 0
                bc = 2
            else:
                bc += 1
                state = 3
        #print(state,s[i])
        i -= 1
    print(ans)

    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()