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 = True
d = False
for i in range(B,D):
    if(S[i] == "#" and d):
        ans = False
    elif(S[i] == "#"):
        d = True
    else:
        d = False
d = False
for j in range(A,C):
    if(S[i] == "#" and d):
        ans = False
    elif(S[i] == "#"):
        d = True
    else:
        d = False
if(C>D):
    ans = S.count("...")!=0

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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map( int, input().split())
S = input()
check = "Yes"
for i in range(A-1, max(C,D)):
    if S[i] == "#" and S[i+1] == "#":
        check = "No"
        break
if check == "Yes":
    if C < D:
        pass
    else:
        check = "No"
        A -= 1
        B -= 1
        C -= 1
        D -= 1
        t = 0
        for i in range(B-1, D+1):
            if S[i] == "#":
                if t <= 2:
                    t += 1
                elif t >= 3:
                    check = "Yes"
                    break
print(check)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=list(map(int,input().split()))
s=input().rstrip()
vis=[False]*(n+1)
i=a-1
flag=1
s=[i for i in s]
#check for b
i=b-1
while(i<d):
    if i==d-1:
        break
    elif s[i+1]=='.':
        i+=1
    elif s[i+2]=='.':
        i+=2
    else:
        break
if i==d-1:
    pass
else:
    print('No')
    exit()
i=a-1
while(i<c):
    if i==c-1:
        break
    elif  s[i+1]=='.':
        i+=1
    elif  s[i+2]=='.':
        i+=2
    else:
        break
if i==c-1:
    pass
else:
    print('No')
    exit()
if d==c:
    print('No')
    exit()
print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
number_of_masu, firstsunuke, firstfunuke, lastsunuke, lastfunuke = map(int, input().split())
s = str(input())
tobenaiflag = 0
nukaseruflag = 0

for i in range(min(firstsunuke, firstfunuke), max(lastsunuke, lastfunuke)-1-1):
    if s[i] == '#' and s[i+1] == '#':
        tobenaiflag += 1
        break
if lastfunuke < lastsunuke:
    for j in range(max(firstsunuke, firstfunuke), min(lastsunuke, lastfunuke)-1-2):
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
            nukaseruflag += 1
            break
else:
    nukaseruflag += 1
if tobenaiflag == 0 and nukaseruflag == 1:
    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):
        print("No")
    else:
        print("Yes")
else:
    try:
        s.index("...")
    except:
        print("No")
        sys.exit()
    else:
        if x(s):
            print("No")
        else:
            print("Yes")

Submission status: Wrong Answer

Solution code:
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N, A, B, C, D = [ int(x) for x in input().split() ]
A -= 1
B -= 1
C -= 1
D -= 1
S = input() + "#"

A_blocker = False
B_blocker = False
pass_point = False

A_load = S[A:C]
B_load = S[A:D]
pass_load = S[B-1:D+1]
if '##' in A_load:
    A_blocker = True
if '##' in B_load:
    B_blocker = True
if '...' in pass_load:
    pass_point = True

if D < C:
    if not A_blocker and not B_blocker and pass_point:
        print ("Yes")
    else:
        print ("No")
else:
    if not A_blocker and not B_blocker:
        print ("Yes")
    else:
        print ("No")

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, max(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:
n,a,b,c,d=map(int,input().split())
s=list(input())
def check(a,c,s):
  if s[a-1]=="#"or"#"==s[c-1]:return False
  for i in range(c-a):
    if s[a-1+i]==s[a+i]=="#":return False
  return True
def ls(s):
  a=""
  for i in s:a+=i
  return a
if c<d:
  if check(a,c,s)and check(b,d,s):print("Yes")
  else:print("No")
else:
  if not(check(b,d,s)):print("No");exit()
  f=False
  for i in range(d-b):
    if s[b-2+i:b+1+i]==[".",".","."]:f=True
  if f and check(a,c,s):print("Yes")
  else:print("No")

Submission status: Wrong Answer

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

tmp_s = s[:b - 1] + "#" + s[b:]
a_s = tmp_s[a:]
tmp_s = s[:d - 1] + "#" + s[d:]
aa_s = tmp_s[:c]

tmp_s = s[:a - 1] + "#" + s[a:]
b_s = tmp_s[b:]
tmp_s = s[:c - 1] + "#" + s[c:]
bb_s = tmp_s[:d]

a_flag = False
b_flag = False
if "##" not in a_s or "##" not in aa_s or "..." in a_s or "..." in aa_s:
    a_flag = True

if "##" not in b_s or "##" not in bb_s or "..." in b_s or "..." in bb_s:
    b_flag = True
print("Yes" if b_flag and  a_flag else "No")

Submission status: Wrong Answer

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

if C < D:
    answer = 'Yes'
    prev = ''
    for s in S:
        if prev == s and s == '#':
            answer = 'No'
        prev = s
    print(answer)
else:
    answer = 'No'
    for i in range(B-1, D):
        if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.':
            answer = 'Yes'
    prev = ''
    for s in S:
        if prev == s and s == '#':
            answer = 'No'
        prev = s
    print(answer)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
st = input()
if C == D :
  print("No")
elif C < D:#連続で岩が置かれていなければおっけー
  flag = 0
  st1 = st[A:C+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B:D+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
  if flag :
    print("No")
  else:
    print("Yes")
    
else:#入れ替わりを行う必要がある
  flag = 0
  irekaeble = 0
  st1 = st[A:C+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B:D+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B-1:D+2]
  for i in range(len(st)-2):
    if st1[i:i+3] == "...":
      irekaeble = 1
  
  if flag or irekaeble == 0:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
if "##" in S:
  print("No")
elif "#..#"in S:
  print("No")
else:
  print("Yes")

Submission status: Wrong Answer

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

r = [[False]*(N+2) for _ in range(N+2)]

def move(x1, x2):
    if r[x1][x2]: return
    r[x1][x2] = True
    if S[x1]=='#' or S[x2]=='#' or x1==x2: return
    move(x1+1, x2)
    move(x1+2, x2)
    move(x1, x2+1)
    move(x1, x2+2)

move(A-1, B-1)
out = 'YES' if r[C-1][D-1] else 'NO'
print(out)

Submission status: Wrong Answer

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

def readInt():
    return int(input())

def readList():
    return list(input().split())

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

def check(s, x_from, x_to):
    for x in range(x_from, x_to-1):
        can_jump = False
        for dx in range(0, 2):
            if s[x+dx] == '.':
                can_jump = True
                break
        if not can_jump:
            return False
    return True


def main():
    n, a, b, c, d = readListI()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = input()

    if c > d:
        # 抜く必要があり、...がb-1<=x<=cにないといけないのでその判定をする
        can_swap = False
        for x in range(b-1, c-1):
            can_swap_here = True
            for dx in range(0, 3):
                if x+dx >= len(s):
                    can_swap_here = False
                    break
                if s[x+dx] == '#':
                    can_swap_here = False
                    break
            if can_swap_here:
                can_swap = True
                break
        if not can_swap:
            print("No")
            return

    # それぞれがたどりつけるか (##がないか) を調べれば良い
    if not check(s, a, c):
        print("No")
        return
    if not check(s, b, d):
        print("No")
        return
    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,a,b,c,d = na()
s = ns()

a-=1
b-=1
c-=1
d-=1
fla = 0
flb = 0
dou = True
tri = False if d < c else True

for i in range(a,max(c,d)+1):
    if s[i] == '.':
        fla = 0
        flb += 1
    else:
        fla += 1
        flb = 0
    if fla == 2:
        dou = False
    if flb == 3 and i <= d+1:
        tri = True

if dou and tri:
    print('Yes')
else:
    print('No')

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):
        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):
        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):
        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
    for i in range(C-A):
        if i == 0:
            mass+=1
        else:
            if Slist[i] == "#":
                Rock+=1
                Maxmass = max(Maxmass,mass)
                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:
N, A, B, C, D = map(int, input().split())
road = input()

def check_cont_rock(s, e):
  use_road = road[s:e]
  return "##" in use_road

def check_cont_road(s, e):
  use_road = road[s:e]
  return "..." in use_road

if D > C:
  if check_cont_rock(A-1, D-1):
    print("No")
  else:
    print("Yes")
else:
  if check_cont_rock(A-1, C-1):
    print("No")
  else:
    if check_cont_road(B-2, D-1):
      print("Yes")
    else:
      print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import numpy as np
from functools import lru_cache
import time

def main(): 
    if True:
        N,A,B,C,D = list(map(int, input().split()))
        S = np.asarray(list(str(input())))
    else:
        pass

    scount = 0
    dcount = 0
    swapok = False
    #print(S[A:D])
    for s in S[A:max(C,D)]:
        if s == "#":
            dcount = 0
            scount += 1
            if scount == 2:
                print("No")
                exit()
        else:
            scount = 0
            dcount += 1
            if dcount == 3:
                swapok = True
    
    if (C>D) & (not swapok):
        print("No")
    else:
        print("Yes")

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-1:]:
  ans = "No"
elif C < D:
  ans = "Yes"
else:
  if "..." in S[B-1:]:
    ans = "Yes"
  else:
    ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
s = input()
if '##' in s:
    print('No')
else:
    if C > D:
        if '...' in s[: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()
print("No" if ("##" in s[a-1:c]) or ("##" in s[b-1:d]) or (c>d and "..." not in s[b-2:d]) else "Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
st = input()
if C == D :
  print("No")
elif C < D:#連続で岩が置かれていなければおっけー
  flag = 0
  st1 = st[A:C+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B:D+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
  if flag :
    print("No")
  else:
    print("Yes")
    
else:#入れ替わりを行う必要がある
  flag = 0
  irekaeble = 0
  st1 = st[A:C+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B:D+1]
  for i in range(len(st1)-1):
    if st1[i:i+2] == "##":
      flag = 1
      
  st1 = st[B-1:C+2]
  for i in range(len(st)-2):
    if st1[i:i+3] == "...":
      irekaeble = 1
  
  if flag or irekaeble == 0:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
import numpy as np

N,A,B,C,D = map(int,input().split())
S = np.array((True,)+tuple(map(lambda x: x == '#',input()))+(True,))

def check1(i,j):
    if S[i] or S[j]:
        return False
    return not np.any(S[i:j-1] & S[i+1:j])

def check2(i,j):
    return np.any((~S[i-1:j-1])&(~S[i:j])&(~S[i+1:j+1]))

if C < D:
    print('Yes' if check1(A,C) and check1(B,D) else 'No')
else:
    print('Yes' if check2(B,D) and check1(A,C) else 'No')

Submission status: Wrong Answer

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

cnt=0
def recur(s,cnt):
    cnt_temp=s.count('ABC')
    if cnt_temp > 0:
        s=s.replace("ABC","BCA")
        cnt += cnt_temp
        recur(s,cnt)
    else:
        print(cnt)
s=input()

recur(s,cnt)

Submission status: Wrong Answer

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

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

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

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

    for i in range(A,C):
        if S[B-1] == "#" or S[B+1] == "#":
            print("No")
            exit()

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)

for i in range(n-1) :
    if s[i] == '#' and s[i+1] == '#' : # 岩が2個連続である場合
        if i <= right :
            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 :
                    print('Yes')
                    break
        else :
            print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

# 2連続石が無いか調べる
# & 連続空白を調べる
isStone = False
spaceChainCount = 0
for ss in s:
    if ss == '#':
        if isStone:
            print("No")
            sys.exit()
        isStone = True
        spaceChainCount = 0
    else:
        isStone = False
        spaceChainCount += 1

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

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def SI(): return input()


def main():
    N, A, B, C, D = LI()
    S = SI()

    M = [0 for _ in range(A-1)]
    a = 0
    for s in S[A-1:max(C, D)]:
        if s == ".":
            a = 0
            M.append(0)
        else:
            if a == 1:
                print("No")
                return
            a = 1
            M.append(1)
    if D > C:
        print("Yes")
        return
    a = 1
    for m in M[B:D]:
        if m == 0:
            if a == 0:
                print("Yes")
                return
            a = 0
        else:
            a = 1
    if (A == B-1 or M[B-2] == 0) and M[B] == 0:
        print("Yes")
        return
    print("No")


main()

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map( int, input().split())
S = input()
check = "Yes"
for i in range(N-1):
    if S[i] == "#" and S[i+1] == "#":
        check = "No"
        break
if check == "Yes":
    if C < D:
        pass
    else:
        check = "No"
        A -= 1
        B -= 1
        C -= 1
        D -= 1
        t = 0
        for i in range(B-1, D+1):
            if S[i] == "#":
                if t <= 2:
                    t += 1
                elif t >= 3:
                    check = "Yes"
                    break
print(check)

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'
if needOver:
    canOver = False
    for i in range(B+1-1, C-1):
        if S[i-2] == '.' and S[i-1] == '.' and S[i] == '.':
            canOver = True
            break
    if canOver:
        for i in range(B+1-1, len(S)):
            if S[i-2] == '.' and S[i-1] == '.' and S[i] == '.':
                canOver = True
                break
    else:
        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:
N, A, B, C, D = map(int, input().split())
S = input()

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

if D < C:
	if not "..." in S:
		print("No")
		exit()

print("Yes")

Submission status: Wrong Answer

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

if '##' in S[A:C] or '##' in S[B:D]:
    print("No")
elif '...' in S[A:C]:
    print("Yes")
else:
    if C < D:
        print("Yes")
    elif S[B-2] == '.' and S[B] == '.':
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

if '##' in S:
    print('No')
elif (A<B) ^ (C<D):
    if '...' in S:
        print('Yes')
    else:
        print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

ans = "Yes"
cnt = 0
tmp = 0
for i in range(A - 1, max(C, D)):
  #岩が２個続いてたらダメ
  if i >= A and S[i] == "#" and S[i - 1] == "#":
    ans = "No"
    break
  #岩無しが何個続いてるかカウント
  if S[i] == ".":
    tmp += 1
  else:
    cnt = max(cnt, tmp)
    tmp = 0
cnt = max(cnt, tmp)
#追い越しが必要なら岩無しのスペースが3個続かなきゃダメ
if D < C and cnt < 3:
  ans = "No"
print(ans)

Submission status: Wrong Answer

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

if c < d:
  if "##" in s[a+1:d]:
    print('No')
  else:
    print('Yes')
else:
  if (('##' in s[a+1:c]) or not('...' in s[a+1:c])):
    print('No')
  else:
    print('Yes')

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:C].count('##') == 0 and S[B-1:D].count('##') == 0):
        if(D < C and S[A-1:D].count('...') == 0):
            print(NO)
        else:
            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:
#!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 c > d:
        for i in range(a+1,d-1):
            if s[i] == "." and s[i + 1] == "." and s[i - 1] == ".":
                flg = i
                break
        if not flg:
            print("No")
            return
    for i in range(a+1, max(c,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:
#!/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):
    ret = YES
    if '##' in S[A:C] or '##' in S[B:D]:
        ret = NO
    else:
        if D < C:
            #if S[B - 2:B] == '..' or S[B - 1:B + 1] == '..':
            if not '...' in S[B - 1:D + 1]:
                ret = NO
    print(ret)
    return


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:
#!/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[x] == '#' and S[x + 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

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

OK = True
if A < C < B < D or A < B < C < D:
    if S[A:C+1].count("##") == 0 and S[B:D+1].count("##") == 0:
        pass
    else:
        OK = False
else:
    if S[A:C+1].count("##") == 0 and S[B:D+1].count("##") == 0 and S[B-1:D+2].count("...") > 0:
        pass
    else:
        OK = False
if OK:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = [int(x) for x in input().split()]
# N < 200_000
S = " " + input()

# A sunuke -> C
# B funuke -> D
# .
# # 

def solve(N, A, B, C, D, S):
    if S[A:C].find("##") != -1:
        return "No"
    if S[B:D].find("##") != -1:
        return "No"

    # A C B D
    if A < C < B < D:
        return "Yes"

    # A B C D
    if A < B < C < D:
        return "Yes"

    # A B D C
    if A < B < D < C:
        if S[B-1:D+1].find("...") != -1:
            return "Yes"
    return "No"

print(solve(N, A, B, C, D, S))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def SI(): return input()


def main():
    N, A, B, C, D = LI()
    S = SI()

    M = [0 for _ in range(A-1)]
    a = 0
    for s in S[A-1:max(C, D)]:
        if s == ".":
            a = 0
            M.append(0)
        else:
            if a == 1:
                print("No")
                return
            a = 1
            M.append(1)
    if D > C:
        print("Yes")
        return
    a = 1
    for m in M[B:D]:
        if m == 0:
            if a == 0:
                print("Yes")
                return
            a = 0
        else:
            a = 1
    if M[B-2] == 0 and M[B] == 0:
        print("Yes")
        return
    print("No")


main()