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 = list(map(int, input().split()))
s = list(str(input()))

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

print(ans)

Submission status: Wrong Answer

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

result = "Yes"
onon = True

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


print(result)

Submission status: Wrong Answer

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

stoneflag = 0
clearflag = 0
for i in range(n - 1):
    if s[i] == '#' and s[i + 1] == '#':
        stoneflag = 1
    elif i > b and i < d and i <= n - 3:
        if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
            clearflag = 1

if stoneflag == 1:
    print('No')
elif c < d:
    print('Yes')
elif c > d and clearflag == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
import re
from collections import deque
import sys
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_invs(n, mod=DIV):
    inv = [0]*(n+1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, n+1):
        inv[i] = (-(mod//i)*inv[mod % i]) % mod
    return inv


N,A,B,C,D = ints_raw()
S = input()
#N = int_raw()


def main():
    ans = 0
    if D==C:
        return "No"
    if S[D-1]=="#" or S[C-1]=="#":
        return "No"
    if "##" in S[A:max(B, D)]:
        return "No"
    if D>C:
        return "Yes"
    else:
        if "..." in S[B-2:max(D+1,N)]:
            return "Yes"
        if (B-A ==1) and S[B]==".":
            return "Yes"
        if S[B-2:B+1]==".#.":
            return "Yes"
        return "No" 
    return ans


print(main())

Submission status: Wrong Answer

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

# 間に＃が連続していなければ通るはず

if not "##" in S[B-1:D-1]:
    S = list(S)
    S[D-1] = "#"
    S = ''.join(S)
    if not "##" in S[A-1:C-1] or "..." in S[B-1:C-1]:
        print("Yes")
    else:
        print("No")
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 a + 1 == b == d -1 == c-2:
        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+1, c-1):
        if s[i] == "#" and s[i + 1] == "#":
            print("No")
            return
    for i in range(b+1, d-1):
        if s[i] == "#" and s[i + 1] == "#":
            print("No")
            return
    print("Yes")
    
    return

#B
def B():
    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:
# -*- coding: utf-8 -*-
N, A, B, C, D = map(int, input().split())
S = input()

cnt3dot = 0
for i in range(A , N):
    # check "##"
    if S[i : i + 2] == "##":
        print("No")
        exit(0)
    # check "..."
    if S[i - 1 : i + 2] == "...":
        cnt3dot += 1

if C < D:
    print("Yes")
else: # D < C
    if cnt3dot > 0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

DS = False
TD = False
nd = 0
ns = 0
if A + 1 == B:
    nd = 1
for x in range(A+1, max(C, D)+1):
    s = S[x-1]
    if s == '.':
        nd = nd + 1
        ns = 0
    else:
        nd = 0
        ns = ns + 1
    if ns >= 2:
        DS = True
    if B <= x <= D + 1:
        if nd >= 3:
            TD = True

if DS == True or (D < C and TD == False):
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

gyaku = 0
if C > D:
    gyaku = 1

flag = 0
renzoku = 0
irekae = 0
for i in range(N):
    if S[i] == '#':
        renzoku = 0
        if flag == 1:
            if A < i < C-1 or B < i < D-1:
                print('No')
                exit()
        flag = 1

    else:
        flag = 0
        renzoku += 1
        if renzoku == 3:
            irekae = 1
            irekaeiti = i

    if gyaku:
        if i == D-1:
            if S[i-1] == '#' or S[i+1] == '#':
                if irekae == 0 :
                    print('No')
                    exit()
                elif B < irekaeiti < D:
                    pass
                else:
                    print('No')
                    exit()
print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)

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

def x(s):
    try:
        s.index("##")
    except:
        return True
    else:
        return False

n,a,b,c,d=intinput()
s=input()
if c<d:
    if x(s[a-1:c-1]):
        print("Yes")
    else:
        print("No")
else:
    try:
        s[a-1:d-1].index("...")
    except:
        print("No")
    else:
        if x(s[a - 1:d - 1]):
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
c, d , cc, dd = 0, 0, 0, 0
if "##" in S[B-1:D] or "##" in S[A-1:C]:
  print("No")
elif C < D:
  print("Yes")
else:
  for i in S[D:]:
    cc += 1
    if c == 2:
      break
    if i == "#":
      c += 1
    else:
      c = 0
  for i in S[:A][::-1]:
    dd += 1
    if d == 2:
      break
    if i == "#":
      d += 1
    else:
      d = 0
  if "..." in S[A-d+2:C+cc-2]:
    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()

if ('##' in s[b:d]) and ('##' in s[a:c]):
    print('No')
elif c > d:
    if '...' in s[b:d]:
        print('Yes')
    else:
        print('No') 
else:
    print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

i=0
j=0
gg=0
nnt=0
if c<d:
    i=a-1
    while i!=n:
        if s[i]=="#":
            j=j+1
        else:
            j=0
        if j==2:
            nnt=1
            break
        i=i+1

else:
    i=a-1
    nnt=1
    while i!=n:

        if s[i]==".":
            gg=gg+1
        else:
            gg=0
        if gg==3:
            if i>b:
                nnt=0



        if s[i]=="#":
            j=j+1
        else:
            j=0
        if j==2:
            nnt=1
            break

        i=i+1
if nnt==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
flag2 = True
flag3 = False
if C < D:
    AS = S[A:C-1]
    BS = S[B:D-1]
    for i in range(len(S)-1):
        if BS[i:i+2] == '##':
            flag2 = False
    for i in range(len(S)-1):
        if AS[i:i+2] == '##':
            flag2 = False
    if flag2:
        print('Yes')
    else:
        print('No')
else:
    AS = S[A:C-1]
    BS = S[B:D-1]
    for i in range(len(S)-1):
        if BS[i:i+2] == '##':
            flag2 = False
    for i in range(len(S)-1):
        if AS[i:i+2] == '##':
            flag2 = False
    AD = S[A:D+1]
    for i in range(len(S)-2):
        if BS[i:i+3] == '...':
            flag3 = True
    if flag2 and flag3:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
n, a, b, c, d  = map(int, input().split())
a = a-1
b = b-1
c = c-1
d = d-1
s2 = input()
s = list(s2)

if '...' in s2[(b-1):d] and not ('##' in s2[a:d]):
    print('Yes')
    exit()


if all(s[i] == '.' or s[i+1] == '.' for i in range(b,d)):
    s[d] = '#'
    if all(s[i] == '.' or s[i+1] == '.' for i in range(a,c)):
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

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

needOver = False
if C > D:
    needOver = True

ans = 'Yes'
overPos = 0
if needOver:
    canOver = False
    for i in range(B+1-1, D):
        if S[i-2] == '.' and S[i-1] == '.' and S[i] == '.':
            canOver = True
            break
    if not canOver:
        ans = 'No'

for i in range(A+1-1, C):
    if S[i-1] == '#' and S[i] == '#':
        ans = 'No'
        break

for i in range(B+1-1, D):
    if S[i-1] == '#' and S[i] == '#':
        ans = 'No'
        break

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import copy

def solve(n, a, b, c, d, s):
    if c < d:
        for i in range(a-1, d-1):
            if s[i] == "#" and s[i+1] == "#":
                return "No"
            else:
                return "Yes"
    else:
        for i in range(a-1, d-1):
            if s[i] == "#" and s[i+1] == "#":
                return "No"
            elif i < d - 2 and s[i] == "." and s[i+1] == "." and  s[i+2] == "." :
                return "Yes"
        return "No"


if __name__ == '__main__':

    n, a, b, c, d = map(int, sys.stdin.readline().strip().split(" "))
    s = sys.stdin.readline().strip()
    print solve(n, a, b, c, d, s)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=list(input())
if c<d:
  f=0
  for i in range(b,d-1):
    if s[i]=='#' and s[i+1]=='#':
      f==1
      break
  if f==0:
    for i in range(a,c-1):
      if s[i]=='#' and s[i+1]=='#':
        f=1
  if f==1:print('No')
  else:print('Yes')
else:
  f=0
  for i in range(b,d-1):
    if s[i]=='#' and s[i+1]=='#':
      f=1
      break
  if f==0:
    for i in range(a,c-1):
      if s[i]=='#' and s[i+1]=='#':
        f=1
        break
  if f==0:
    if s[d-2]=='#' or (s[d]=='#' and s[d-3]=='#'):
      ct=0
      for i in range(b,d-2):
        if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
          ct=1
          break
      if ct==0:f=1
  if f==1:print('No')
  else:print('Yes')

Submission status: Wrong Answer

Solution code:
#
#　　　　　　　　　　　　　　,. -─────────‐- .、
#　　　　　　　　　　　　 ／／￣￣＼　　　　　　／￣￣＼＼
#　　　　　　　　　　　／　　　　　　　　　　　　　　　　　　　　 ＼
#　　　　　　　　　 ／　　　　　　　　::::::::::::::::::::::::::::::::　　　　　　　＼
#　　　　　　　　／ 　　／ ／￣＼＼::::;;;;;;;;;;;;;;;;;:::::／／￣＼＼　　＼
#　　　　　　 ／　　　　|　 |.　┃　.|　| ::::;;;;;;;;;;;;;::::｜ |.　┃　.|　|　　　 ＼　　　　　　　　　　　　　　　　　　　　　
#　　　　　／ 　　　　　＼ ＼＿／／　::::::::::::::::::　＼＼＿／／　　　　　 ＼　　　　
#　　　 ／　　　　　..／￣￣＼　／　　　::｜::　　　＼　／￣￣＼..　　　　　＼
#　　 / 　 　 　 　 :::::　　　　　　|　　　　　 |　　　　　 |　　　　　　 :::::　　　　　 ヽ.　　　
#　　| 　　　　　　　　　　　　　　|　　　　　 |　　　　　 |　　　　　　　　　　　　　　|.
#　　| 　　　　　　　　　　　　　　＼＿＿／＼＿＿／ 　　　　　　　　　　　　　　|　　　　　　　　　　　　　　　　　
#　　| 　　　　　　　　　　　　　　　｜　　　　　　　｜　　　　　　　　　　　　　　　|
#　　| 　　　　　　　　　　　　　　　｜r─‐┬──､|　　　　　　　　　　　　　　　 |
#　　ヽ　　　　　　　　　　　　　　　 |/　　　|　　 　｜　　　　　　　　　　　　　　/
#　　　 ＼　　　　　　　　　　　　　 ＼　　　　　　／　　　　　　　　　　　　　／
#　　　　　＼ 　　　　　　　　　　　　　￣￣￣￣　　　　　　　　　　　　　／
#
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N, A, B, C, D = MI()
    S = "."+ST()

    if A > C or B > D:
        print("No")
        exit()

    for i in range(min(A, B), max(C, D) ):
        if S[i] == "#" and S[i - 1] == "#":
            print("No")
            exit()
    
    if (A - B) * (C - D) >= 0:
        print("Yes")
    else:
        #3連続あるか判定
        for i in range(max(A, B)+1, min(C, D)+1):
            if S[i] == "." and S[i - 1] == "." and S[i - 2] == ".":
                print("Yes")
                exit()
        print("No")

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if C < D:
    lst = []
    for i in range(N-1):
        if S[i] == '#' and S[i+1] =='#': #岩が連続である場所
            if (A <= i and i <= C) or (B <= i and i <= D):
                print ('No')
                sys.exit()
    print ('Yes')
    sys.exit()
        
if C > D:
    flag1 = False
    flag2 = True
    lst = []
    for i in range(1,N-1): 
        if S[i] == '#' and S[i+1] =='#': #岩が連続である場所が一つでもあればダメ
            if (A <= i and i <= C) or (B <= i and i <= D):
                print ('No')
                sys.exit()
        if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.' and B < i-1 and i+1 < D: #3個以上連続になっているBの避難スペースがあるかどうか
            flag1 = True
    if C-D != 1:
        flag2 = True


if flag1 and flag2:
    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:d].find("##")==-1:
  if c<d:
    print("Yes")
  else:
    if s[b:d+1].find("...")==-1:
      print("No")
    else:
      print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
temp = input()
temp2 = input()

N, A, B, C, D = [int(x) for x in temp.split()]
flag = True
before = -1
 
for x, xi in enumerate(temp2):
    if x<A:# 初めはいらない
        continue
    elif x>D:# 後半もいらない
        break
        
    if xi==".":
        continue
    elif xi==C or xi==D:
        flag = False
        break
    else:
        if x-before==1:
            flag = False
            break
        else:
            before = x
    
            
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if "##" in s:
    print("No")
    exit()

if ((a < b and c > d) or (a > b and c < d) and ("..." not in s)):
    print("No")
    exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)

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

def x(s):
    try:
        s.index("##")
    except:
        return True
    else:
        return False

n,a,b,c,d=intinput()
s=input()
print(s[a-1:c-1])
if c<d:
    if x(s[a-1:c-1]):
        print("Yes")
    else:
        print("No")
else:
    try:
        s[a-1:d-1].index("...")
    except:
        print("No")
    else:
        if x(s[a - 1:d - 1]):
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
import numpy as np

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

changable = False
if "..." in S[B:min([C-1, D-1])]:
    changable = True

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

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

Submission status: Wrong Answer

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

if "##" in S:
    print("No")
else:
    S = S[:max(C, D)-1]
    if "..." in S:
        print("Yes")
    else:
        if C < D:
            print("Yes")
        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[A:D:].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 = str(input())
ans = "Yes"

if '##' in S:
    ans = "No"

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

print(ans)

Submission status: Wrong Answer

Solution code:
#A問題
N,A,B,C,D = map(int,input().split())
Slist = list(str(input()))
if C < D:
    now = B-1
    Rock = 0
    flag = 0
    for i in range(D-B):
        I = i+now
        if i == 0:
            pass
        else:
            if Slist[I] == "#":
                Rock+=1
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0
    now = A-1
    Rock = 0
    for i in range(C-A):
        I = i+now
        if i == 0:
            pass
        else:
            if Slist[I] == "#":
                Rock+=1
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0

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

    if Maxmass <= 2:
        flag = 1
    
    if flag == 1:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def has_double(S, x, y):
    for i in range(x, y):
        if S[i] == '#' and S[i + 1] == '#':
            return True
    return False


def solve(N, A, B, C, D, S):
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    if has_double(S, A, C):
        return False
    if has_double(S, B, D):
        return False

    # ABCD
    # ACBD
    # ABDC
    if D < C:
        lb = A
        rb = C
        while True:
            if lb >= 2 and S[lb - 2] == '.':
                lb -= 2
                continue
            if lb >= 1 and S[lb - 1] == '.':
                lb -= 1
                continue
            break

        while True:
            if rb < N - 2 and S[rb + 2] == '.':
                rb += 2
                continue
            if rb < N - 1 and S[rb + 1] == '.':
                rb += 1
                continue
            break

        for i in range(lb, rb - 1):
            if S[i] == '.' and S[i + 1] == '.' and S[i + 2] == '.':
                return True

        return False

    return True


def main():
    N, A, B, C, D = [int(e) for e in inp().split()]
    S = inp()
    print('Yes' if solve(N, A, B, C, D, S) else 'No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

result = "Yes"
onon = True

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


print(result)

Submission status: Wrong Answer

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

rock=0
blank=0
for i in range(a,c):
    if path[i-1]=='#' and path[i]=='#':
        rock=1
for i in range(b,d):
    if path[i-1]=='#' and path[i]=='#':
        rock=1

for i in range(max(a,b),min(c,d)):
    if path[i-1]=='.' and path[i]=='.' and path[i+1]=='.':
        blank=1

if rock==0 and ((a-b)*(c-d)>0 or (blank==1 and (a-b)*(c-d)<0)):
    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 = "Yes"

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

Submission status: Wrong Answer

Solution code:
import sys
N, A, B, C, D = map(int, input().split())
S = input()
skip = 0
num = 1
for i,k in zip(S[1:],S[:-1]):
	if i == k == "#" and num < min(C, D):
		print('No')
		sys.exit()
	elif i == k == "." and B < num < D:
		skip += 1
	num += 1
if C<D:
	print('Yes')

elif skip > 0:
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

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

def yn(a):
    print('Yes' if a else 'No')

if C < D:
    # `##` is NG btw A and D
    yn('##' not in S[A:D])
else:
    # `#` is NG prev D except oikoseru
    oikoseru = S[B] == '.' or '...' in S[B:D]
    yn('##' not in S[A:C] and ('#' != S[D-2] or oikoseru))

Submission status: Wrong Answer

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

pres = 'x'          # S[i-1]
cntx, cnty = 0, 0   # x:'.'の連続数, y:'#'の連続数
mxx, mxy = 1, 1     # mxx:'.'の連続数max, mxy:'#'の連続数max

for i in range(A-1, max(C, D)): # base=0
    if S[i] == pres:
        if S[i] == '.':
            cntx += 1
            if i >= B-1 and i < D:  # .のチェックは B-Dだけ
                mxx = max(cntx, mxx)
        elif S[i] == '#':
            cnty += 1
            mxy = max(cnty, mxy)
    else:
        pres = S[i]
        if S[i] == '.':
            cntx = 1
        elif S[i] == '#':
            cnty = 1

if C < D:
    if mxy < 2:
        print("Yes")
    else:
        print("No")
else:
    if mxy < 2 and mxx >= 3:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n , a0 , b0 , c0 , d0 = map(int,input().split())
s = input()

# a < b に変換する
if a0 > b0 : # 入れ替える
    a = b0
    b = a0
    c = d0
    d = c0
else : # 入れ替えない
    a = a0
    b = b0
    c = c0
    d = d0

right = max(c,d)
left = min(a,b)

for i in range(n-1) :
    if s[i] == '#' and s[i+1] == '#' : # 岩が2個連続である場合
        if i <= right - 2 and i >= left - 1 :
            print('No')
            break
else :
    if c < d :
        print('Yes')
    else :
        for i in range(n-2) :
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' : # 入れ替え可能
                if i < d - 1 and i >= left - 1 :
                    print('Yes')
                    break
        else :
            print('No')

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import math

def main():
    n,a,b,c,d = map(int, raw_input().split())
    s = list(raw_input())
    chk = True
    cnt = 1
    hurdleA = 0
    hurdleB = 0
    three = 0
    threeChk = False
    for i in s:
        if cnt > a and cnt < b:
            if i == '.':
                three += 1
            else:
                three = 0
            if three >= 3:
                threeChk = True
        if cnt > a and cnt < c:
            if i == '#':
                hurdleA += 1
            else:
                hurdleA = 0
            if hurdleA >= 2:
                chk = False
                break
        if cnt > b and cnt < d:
            if i == '#':
                hurdleB += 1
            else:
                hurdleB = 0
            if hurdleB >= 2:
                chk = False
                break
        cnt += 1
    if c > d and (s[d-2] == '#' or s[d] == '#') and threeChk == False:
        print "No"
    elif chk == False:
        print "No"
    else:
        print "Yes"

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def inverse(a):
    return pow(a, mod - 2, mod)

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

    s = input()

    a_r = a
    cnt = 0
    for i in range(a, n):
        if s[i] == '#':
            cnt += 1
        else:
            cnt = 0
        a_r = i
        if cnt == 2:
            a_r = i - 2
            break

    b_r = a
    cnt = 0
    for i in range(b, n):
        if s[i] == '#':
            cnt += 1
        else:
            cnt = 0
        b_r = i
        if cnt == 2:
            b_r = i - 2
            break
    if a_r < c or b_r < d:
        print('No')
        return
    if c < d:
        print('Yes')
        return
    cnt = 0
    for i in range(b, c+1):
        if s[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt > 2:
            print('Yes')
            return

    if s[b-1] == '.' and s[b+1]:
        print('Yes')
        return 
    if d < n-1 and s[d-1] == '.' and s[d+1]:
        print('Yes')
        return 

    print('No')


main()

Submission status: Wrong Answer

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

if "##" in S:
    print("NO")
else:
    S = S[:max(C, D)-1]
    if "..." in S:
        print("YES")
    else:
        if C < D:
            print("YES")
        else:
            print("NO")

Submission status: Wrong Answer

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

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