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:
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に岩を置いて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]):
                if S[i:i+2]=="##":
                    ans="No"
                    break
    print(ans)

Submission status: Wrong Answer

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

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:
n, a, b, c, d = list(map (int, input().split()))
s = input ()
s = '#' + s
 
ans = True
 
if '##' in s[a:max(c,d)]:
    ans = False
else:
    if d < c:
        ans = False
        if '...' in s[b:d]:
            ans = True
        
 
if ans is True:
    print ('Yes')
else:
    print ('No')

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









#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:
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):
        print('Yes')
    else:
        print('No')

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("##"):
        flag = False
    else:
        if S[B-1:D+1].count("..."):
            flag = True
        else:
            flag = False
        
if flag:
    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-1:C]
    courseB = S[B-1: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-1-1: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:
n,a,b,c,d = map(int,input().split())
s = input()
if "##" in s[a:c]:
  print("No")
  exit()
elif "##" in s[b:d]:
  print("No")
  exit()
elif c > d:
  if "..." in s[b-2:d+1]:
    print("Yes")
    exit()
else:
  print("No")

Submission status: Wrong Answer

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

A -= 1
B -= 1
C -= 1
D -= 1

if S[C] == '#' or S[D] == '#':
    print("No")
    exit()

if C < B:
    stone = 0
    road = 0
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                print("No")
                exit()
        else:
            road += 1
            stone = 0
    stone = 0
    road = 0
    for i in range(B + 1, D):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                print("No")
                exit()
        else:
            road += 1
            stone = 0
    print("Yes")
    exit()

stone = 0
road = 0
c = False
l = [-1]
ans = False

for i in range(B - 1, D + 1):
    if S[i] == '#':
        stone += 1
        road = 0
        if c:
            l.append(i - 1)
            c = False
        if stone > 1:
            print("No")
            exit()
    else:
        road += 1
        stone = 0
        if road > 2:
            c = True
if C < D:
    S = S[:B] + ['.'] + S[B + 1:]
    stone = 0
    road = 0
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                print("No")
                exit()
        else:
            road += 1
            stone = 0
    ans = True
else:
    stone = 0
    road = 0
    check = True
    # B放置でゴールできるか
    S = S[:B] + ['#'] + S[B + 1:]
    stone = 0
    road = 0
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                check = False
        else:
            road += 1
            stone = 0
    S = S[:B] + ['.'] + S[B + 1:]
    if check:
        ans = True
    # Bがゴールしているとゴールできるか
    stone = 0
    road = 0
    check = True
    S = S[:D] + ['#'] + S[D + 1:]
    stone = 0
    road = 0
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                check = False
        else:
            road += 1
            stone = 0
    if check:
        ans = True
    S = S[:D] + ['.'] + S[D + 1:]

if not ans:
    stone = 0
    road = 0
    if l[-1] >= 0:
        for i in range(A + 1, C):
            if S[i] == '#':
                stone += 1
                road = 0
                if stone > 1:
                    print("No")
                    exit()
            else:
                road += 1
                stone = 0
        ans = True

if ans:
    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]
for i in range(b, d):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
if c > d:
    flag = False
    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
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] >= a - 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:
N, A, B, C, D = map(int, input().split())
S = input()

if '##' in S:
    print("No")
    quit()

if C > D:
    if '...' not in S[B-1:C-1]:
        print("No")
        quit()

print("Yes")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

A -= 1
B -= 1
C -= 1
D -= 1

if S[C] == '#' or S[D] == '#':
    print("No")
    exit()

if C < B:
    stone = 0
    road = 0
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                print("No")
                exit()
        else:
            road += 1
            stone = 0
    stone = 0
    road = 0
    for i in range(B + 1, D):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                print("No")
                exit()
        else:
            road += 1
            stone = 0
    print("Yes")
    exit()

stone = 0
road = 0
c = False
l = [-1]
ans = False

for i in range(B, D + 1):
    if S[i] == '#':
        stone += 1
        road = 0
        if c:
            l.append(i - 1)
            c = False
        if stone > 1:
            print("No")
            exit()
    else:
        road += 1
        stone = 0
        if road > 2:
            c = True
if C < D:
    S = S[:B] + ['.'] + S[B + 1:]
    stone = 0
    road = 0
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                print("No")
                exit()
        else:
            road += 1
            stone = 0
    ans = True
else:
    stone = 0
    road = 0
    check = True
    # B放置でゴールできるか
    S = S[:B] + ['#'] + S[B + 1:]
    stone = 0
    road = 0
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                check = False
        else:
            road += 1
            stone = 0
    S = S[:B] + ['.'] + S[B + 1:]
    if check:
        ans = True
    # Bがゴールしているとゴールできるか
    stone = 0
    road = 0
    check = True
    S = S[:D] + ['#'] + S[D + 1:]
    stone = 0
    road = 0
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                check = False
        else:
            road += 1
            stone = 0
    if check:
        ans = True
    S = S[:D] + ['.'] + S[D + 1:]

if not ans:
    stone = 0
    road = 0
    if l[-1] >= 0:
        for i in range(A + 1, C):
            if S[i] == '#':
                stone += 1
                road = 0
                if stone > 1:
                    print("No")
                    exit()
            else:
                road += 1
                stone = 0
        ans = True

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
s = list(input())
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 :
    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:
#!/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-1:C]:
            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()

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

Submission status: Wrong Answer

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

for i in range(len(S)):
    if S[i:i+2]=="##":
        print("No")
        break

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

if result == "":
    result = "No"

print(result)

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[B-1:D+1].count("..."):
        flag = True
    else:
        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()
s_flag = False
can_flag = True
count = 0
max_count = 0
m = max(c, d)
for i in range(m):
  if s[i] == '#':
    count = 0
    if s_flag == True:
      can_flag = False
      break
  else:
    count += 1
    max_count = max(max_count, count)

if c > d:
  if max_count <= 2:
    can_flag = False
if can_flag == True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

a_idx, b_idx, c_idx, d_idx = -1, -1, -1, -1
idx = 0
while idx < N:
    start, s = idx, S[idx]
    while idx < N and s == S[idx]:
        idx += 1
    if start <= A < idx:
        a_idx = len(road)
    if start <= B < idx:
        b_idx = len(road)
    if start <= C < idx:
        c_idx = len(road)
    if start <= D < idx:
        d_dix = len(road)
    road.append((idx-start, int(s == '#')))


def go_right(start):
    now = start
    threes = set()
    while now < len(road):
        length, s = road[now]
        if s == 0:
            if length >= 3:
                threes.add(now)
        else:
            if length >= 2:
                break
        now += 1
    return now-1, threes


a_right, a_three = go_right(a_idx)
b_right, b_three = go_right(b_idx)
if a_right < c_idx or b_right < d_idx:
    print("No")
    quit()
if C < D:
    print("Yes")
else:
    inter = a_three & b_three
    print("Yes" if len(inter) > 0 else "No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
if "##" in s[a:c]:
  print("No")
  exit()
elif "##" in s[b:d]:
  print("No")
  exit()
elif c > d:
  if "..." in s[b:d]:
    print("Yes")
  else:
    print("No")
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:
            flag = 1
    if flag == 0:
        ans = 0


if ans==1:
    print("Yes")
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'   

else:
    for i in range(N - 2):
        i
        if i <= A:
            continue

        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 input_from_console():
    n, a, b, c, d = map(int, input().split())
    s = input().rstrip()
    return n, a, b, c, d, s


def solve(n, a, b, c, d, s):
    def check(sub):
        if '##' in sub:
            return False
        return True

    # check for a
    s_a = s[a - 1:c]
    s_a_1 = s[a-1:c+1]
    state_a = check(s_a)
    if not state_a:
        return 'No'
    s_b = s[b - 1:d]
    state_b = check(s_b)
    if not state_b:
        return 'No'

    if c < d:
        return 'Yes'
    if c > d:  # can swap?
        s_b_d = s[b-1:d+2]
        if '...' in s_b_d:
            return 'Yes'
        else:
            return 'No'

    return 'Yes'


def main():
    n, a, b, c, d, s = input_from_console()
    print(solve(n, a, b, c, d, s))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = [int(i) - 1 for i in input().strip().split(' ')]
N += 1
S = [c for c in input().strip()]


def get(a, b):
  s = S[:]
  s[a] = 'A'
  s[b] = 'B'

  return s


def check(s, i, dest):
  while i < dest:
    i += 1
    if i <= dest and s[i] == '.':
      continue
    i += 1
    if i <= dest and s[i] == '.':
      continue

    return False

  return i == dest


def move(s, i, dest):
  if i == dest:
    return -1

  while i < dest:
    i = i + 1
    if i + 1 < N:
      if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
        return i

  return i if i == dest else -1


def main():
  a = A
  b = B

  for _ in range(1000):
    if a == C and b == D:
      return True

    s = get(a, b)
    # print(_, s)
    if a == C:
      return check(s, b, D)
    if b == D:
      return check(s, a, C)

    if C > D:
      if check(s, a, C):
        a = C
      else:
        b = move(s, b, D)
        if b < 0:
          return False
    else:
      if check(s, b, D):
        b = D
      else:
        a = move(s, a, C)
        if a < 0:
          return False


print('Yes' if main() else '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]:


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[A-1:C]:
            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:
# -*- coding: utf-8 -*-

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

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