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())
a, b, c, d = a-1, b-1, c-1, d-1
s = input()
if "##" in s:
    print("No")
elif c < d:
    print("Yes")
elif "..." in s[a:c+1]:
    s = s[b:d+1].split("#")
    while "." in s: s.remove(".")
    while ".." in s: s.remove("..")
    if len(s) >= 1:
        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()
index = [(n+1) for n, v in enumerate(s) if s[n:n+3] == "..."]

if s.count("##")>=1:
    print("No")
    exit()

if C < D:
    print("Yes")

elif C > D:
    if len(index)>=1:
        for i in index:
            if B <= i+1 and i+1<=D:
                print("Yes")
                exit()
        print("No")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

S = input()

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

# 追い越す必要がある場合
p = 0
if A < B and C > D:
    p = 1

if C > D:
    for i in range(min(C,D)):
        if S[i:i+3] == '...':
            print('YES')
            sys.exit()

print('NO')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=[0 if i=='.' else 1 for i in input()]
#print(s)
t=[0]*n
cst=0
ans=0
for j in range(n-1):
    if s[j]*s[j+1]==1:
        t[j]=2
        t[j+1]=2
    elif j+2 <= n-1:
        if s[j]+s[j+1]+s[j+2]==0:
            t[j]=3
            t[j+1]=3
            t[j+2]=3
if b>c:
    if (2 in t[a-1:c]) or (2 in t[b-1:d]):
        print('No')
    else:
        print('Yes')
elif b<c and c<d:
    if 2 in t[a-1:d]:
        print('No')
    else:
        print('Yes')
elif b<c and d<c:
    if not(2 in t[a-1:d]) and (3 in t[b-2:d+1]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n = [int(i)-1 for i in input().split()]
s = input()

if n[3] > n[4]:
    s1 = n[1]
    s2 = n[2]
    g1 = n[3]
    g2 = n[4]

    ss2 = s[s2: g2].find('##')
    ss21 = s[s1:g1].find('##')
    if ss2 == -1 and ss21 == -1:
        if s2 > 0:
            s2 -= 1
        if g1 < len(s)-1:
            g1 += 1
        ssss = s[s2:g1].find('...')
        if ssss == -1:
            print('No')
        else:
            print('Yes')
    else:
        print('No')

else:
    s1 = n[2]
    s2 = n[1]
    g1 = n[4]
    g2 = n[3]
    ss2 = s[s2: g2].find('##')
    ss21 = s[s1:g1].find('##')
    if ss2 == -1 and ss21 == -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:
            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:
N, A, B, C, D = map(int, input().split())
S = input()

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

Submission status: Wrong Answer

Solution code:
length, a, b, c, d = [int(i) for i in input().split()]
road = input()

e = []
e.append(a)
e.append(b)
e.append(c)
e.append(d)

road = road[min(e) - 1:max(e) - 1]
roada = road[a-1:c-1]
roadb = road[b-1:d-1]
roadc = road[a-1:d-1]

if '##' in road:
    print('No')
if d > c:
    print('Yes')
else:
    if '...' in roadb:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

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

mac=max(c,d)
ans=1

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


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

Submission status: Wrong Answer

Solution code:
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


def go_left(start):
    now = start-1
    threes = set()
    while now >= 0:
        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_three1 = go_right(a_idx)
a_left, a_three2 = go_left(a_idx)
b_right, b_three1 = go_right(b_idx)
b_left, b_three2 = go_left(b_idx)
if a_right < c_idx or b_right < d_idx:
    print("No")
    quit()
if C < D:
    print("Yes")
else:
    inter = (a_three1 | a_three2) & (b_three1 | b_three2)
    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 C<B:
    if not '##' in s[A:C]:
        if not '##' in s[B:D]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    if C<D:
        if '##' in s[A:D]:
            print('No')
        else:
            print('Yes')
    else:
        if '##' in s[A:C]:
            print('No')
        else:
            if '...' in s[B-1:D+1]:
                print('Yes')
            else:
                print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
flg = False
if c < d:
    #最後まで動かす
    flg = True
else:#c>d
    if '...' in s[a-1:]:
        flg = True
        if not('...' in s[:d-1]):
            flg = False
        if (b>3):
            if '...' in s[:b]:
                flg = False
if '##' in s[a-1:max(d,c)-1]:
    flg = False
if flg:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# agc034/agc034_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, A, B, C, D = i2nn()
    S = i2s()
    if '##' not in S[B-1:D] and '##' not in S[A-1:C]:
        if C < D:
            print('Yes')
        elif  '...' in S[A-1:D]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
    return

main()

Submission status: Wrong Answer

Solution code:
length, a, b, c, d = [int(i) for i in input().split()]
road = input()

e = []
e.append(a)
e.append(b)
e.append(c)
e.append(d)

road = road[min(e) - 1:max(e) - 1]
roada = road[a-1:c-1]
roadb = road[b-1:d-1]
roadc = road[a-1:d-1]

if '##' in road:
    print('No')
if d > c:
    print('Yes')
else:
    if '...' in road:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n = [int(i)-1 for i in input().split()]
s = input()

if n[3] > n[4]:
    s1 = n[1]
    s2 = n[2]
    g1 = n[3]
    g2 = n[4]

    ss2 = s[s2: g2].find('##')
    ss21 = s[s1:g1].find('##')
    if ss2 == -1 and ss21 == -1:
        if s2 > 0:
            s2 -= 1
        if g1 < len(s)-1:
            g1 += 1
        ssss = s[s2:g1].find('...')
        if ssss == -1:
            print(2)
            print(ssss)
            print(s2, g1)
            print('No')
        else:
            print('Yes')
    else:
        print('No')

else:
    s1 = n[2]
    s2 = n[1]
    g1 = n[4]
    g2 = n[3]
    ss2 = s[s2: g2].find('##')
    ss21 = s[s1:g1].find('##')
    if ss2 == -1 and ss21 == -1:
        print("Yes")
    else:
        print('No')

Submission status: Wrong Answer

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

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

mac=max(c,d)
ans=1

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


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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = (map(int, input().split()))
S = input()
if '##' in S:
	print('No')
elif d < c and 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()
index = [(n+1) for n, v in enumerate(s) if s[n:n+3] == "..."]

if s.count("##")>=1:
    print("No")
    exit()

if C < D:
    print("Yes")

elif C > D:
    if len(index)>=1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

def solve(now,dest):
    for i in  range(now,dest):
        if s[i] == '#' and s[i+1] == '#':
            return False
    return True
if c < d:
    if solve(a,c) and solve(b,d):
        print('Yes')
    else:
        print('No')

else:
    q = False
    for i in range(b-1,d):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            q = True
            break
        if s[i-1] == '#' and s[i] == '#':
            print('No')
            exit()
    if q and solve(a,c) and solve(b,d):
        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'

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

# 岩が連続してないとき
if D > C:
    ans == 'YES'   

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

print(ans)
exit

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
a, b, c, d = a-1, b-1, c-1, d-1
s = input()
if "##" in s:
    print("No")
elif c < d:
    print("Yes")
elif "..." in s[a:c+1]:
    t = s
    s = s[b:d+1].split("#")
    while "." in s: s.remove(".")
    while ".." in s: s.remove("..")
    if len(s) >= 1 or t[d-1] == ".":
        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()
u = s[a-1: max(c, d)]
t = s[b-1: d]
if '##' in u:
    print('No')
elif c < d:
    print('Yes')
elif '...' in t:
    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[A:]:
    print('No')
elif C<D:
    print('Yes')
else:
    if '...' in S[B:D]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
length, a, b, c, d = [int(i) for i in input().split()]
road = input()

e = []
e.append(a)
e.append(b)
e.append(c)
e.append(d)

road = road[min(e) - 1:max(e) - 1]
roada = road[a-1:c-1]
roadb = road[b-1:d-1]
roadc = road[a-1:d-1]

if '##' in roada or '##' in roadb:
    print('No')
elif '...' in roadc:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
x = input().split()
s = input()
n = int(x[0])
a = int(x[1])
b = int(x[2])
c = int(x[3])
d = int(x[4])
 
 
kome_flag = False
santen_flag = False
 
a_s = s[a-1:c]
b_s = s[b-1:d]

if c < d:
  santen_flag = True
if d < c:
  if '...' in s[b-1:d]:
    santen_flag = True
  
if not '##' in a_s and not '##' in b_s:
  kome_flag = True
    
if not '#' in b_s:
	print('Yes')
else:
	if c < d:
		if kome_flag:
			print('Yes')
		else:
			print('No')
 
	if d < c:
		if kome_flag and santen_flag:
			print('Yes')
		else:
			print('No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

mac=max(c,d)
ans=1

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


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

Submission status: Wrong Answer

Solution code:
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]-1):
        if S[i:i+2]=="##":
            ans="No"
            break
    #更にAも行かせてみる
    for i in range(lis[1],lis[4]-1):
        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":
            a=S[:memo]
            b=S[memo+1:]
            S=a+"#"+b
            a=S[:lis[2]-1]
            b=S[lis[2]:]
            S=a+"."+b
            for i in range(lis[1],lis[3]):
                if S[i:i+2]=="##":
                    ans="No"
                    break
        if memo==0:
            ans="No"
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

rock = 0
max_rock = []
non = 0
max_non = []
k = 0
for i in s:
    if i == '#':
        rock += 1
        if non >= 3:
            max_non.append([non, k])
        non = 0
    else:
        non += 1
        if rock >= 2:
            max_rock.append([rock, k])
        rock = 0
    if k == n-1:
        k += 1
        if non >= 3:
            max_non.append([non, k])
        if rock >= 2:
            max_rock.append([rock, k])
    k += 1

# print(max_non)
max_non1 = [i for i in max_non if (i[1]-i[0]+2 < d and i[1]-i[0]+2 < c and i[1]-i[0]+2 >= b) or (i[1] != b and i[1]-2 < b)]
# max_rock1 = [i for i in max_rock if (i[1] < d and i[1] < c and i[1] > a and i[1] > b) or (i[1])]
max_rock1 = [i for i in max_rock if (i[1] > a and i[1] < b) or (i[1] > b and i[1] < c) or (i[1] > c and i[1] < d)]
max_rock3 = [i for i in max_rock if (i[1] > a and i[1] < b) or (i[1] > b and i[1] < d) or (i[1] > d and i[1] < c)]
max_rock2 = [i for i in max_rock if (i[1] < d and i[1] > b) or (i[1] > a and i[1] < c)]
# print(max_non1)
# print(max_rock1)
if b > c:
    if len(max_rock2) > 0:
        print('No')
    else:
        print('Yes')
elif c > d:
    if len(max_rock3) > 0:
        print('No')
    elif len(max_non1) > 0:
        print('Yes')
    else:
        print('No')
elif len(max_rock1) > 0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

def max_stone(seq):
  m = 0
  for j in range(len(seq)-1):
    if S[j:j+1] == '##':
      return False
  
  return True
  
def reachable(n, b):
  for j in range(n, b):
    s = S[j]
    n_sharp = 0
    n_dot = 0
    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
    
  for j in range(n):
    s = S[j]
    n_sharp = 0
    n_dot = 0
    
    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(S[A-1:C]) and max_stone(S[B-1:D]):
    print('Yes')
  else:
    print('No')
elif B < C and C < D:
  if max_stone(S[A-1:C]) and max_stone(S[B-1:D]):
    print('Yes')
  else:
    print('No')
elif B < C and C > D:
  if reachable(A-1, B-1) and max_stone(S[A-1:C-1]) and max_stone(S[B-1:D-1]):
    print('Yes')
  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')
elif d < c and not '...' in S:
        print('No')
elif d < c:
    if (d -1>=0 and S[d - 2 :d] == '.#') or (d <n and S[d-1:d+1]=='#.'):
        print('No')
    else:
        print('Yes')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = list(map(int,input().split()))
S = list(input())
S2 = []
max = 0
c = 0
for i in range(N):
    if c == 0 and S[i] == "#":
        c = i
    elif c != 0 and S[i] == "#":
        if max < i - c - 1:
            max = i - c - 1
        c = i
    S2.append(S[i])
A -= 1
B -= 1
C -= 1
D -= 1

if D < C and max < 3:
    print('No')
    exit()
elif D < C and max >= 3:
    if S[C-1] == "#":
        print('No')
        exit()
    if C < N - 1 and S[C+1] == "#":
        print('No')
        exit()
    else:
        print('Yes')
else:
    print('Yes')

Submission status: Wrong Answer

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

def solve(now,dest):
    for i in  range(now,dest):
        if s[i] == '#' and s[i+1] == '#':
            return False
    return True
if c < d:
    if solve(a,c) and solve(b,d):
        print('Yes')
    else:
        print('No')

else:
    q = False
    for i in range(b,d):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            q = True
            break
        if s[i-1] == '#' and s[i] == '#':
            print('No')
            exit()
    if q and solve(a,c) and solve(b,d):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

rock = 0
max_rock = []
non = 0
max_non = []
k = 0
for i in s:
    if i == '#':
        rock += 1
        if non >= 3:
            max_non.append([non, k])
        non = 0
    else:
        non += 1
        if rock >= 2:
            max_rock.append([rock, k])
        rock = 0
    if k == n-1:
        k += 1
        if non >= 3:
            max_non.append([non, k])
        if rock >= 2:
            max_rock.append([rock, k])
    k += 1

# print(max_non)
max_non1 = [i for i in max_non if (i[1]-i[0]+2 < d and i[1]-i[0]+2 < c and i[1]-i[0]+2 >= b) or (i[1] != b and i[1]-2 < a and i[1]-2 < b)]
# max_rock1 = [i for i in max_rock if (i[1] < d and i[1] < c and i[1] > a and i[1] > b) or (i[1])]
max_rock1 = [i for i in max_rock if (i[1] > a and i[1] < b) or (i[1] > b and i[1] < c) or (i[1] > c and i[1] < d)]
max_rock3 = [i for i in max_rock if (i[1] > a and i[1] < b) or (i[1] > b and i[1] < d) or (i[1] > d and i[1] < c)]
max_rock2 = [i for i in max_rock if (i[1] < d and i[1] > b) or (i[1] > a and i[1] < c)]
# print(max_non1)
# print(max_rock1)
if b > c:
    if len(max_rock2) > 0:
        print('No')
    else:
        print('Yes')
elif c > d:
    if len(max_rock3) > 0:
        print('No')
    elif len(max_non1) > 0:
        print('Yes')
    else:
        print('No')
elif len(max_rock1) > 0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split(' '))
s = input()
def rock(a,b):
    tmp = 0
    result = 'Yes'
    for i in s[a:b]:
        if tmp==2:
            result = 'No'
            break
        if i =='#':
            tmp +=1
        else:
            tmp=0
    return result
def main():
    result ='No'
    if c<d:
        result = rock(b,d-1)
        if result =='Yes':
            result = rock(a,c-1)
    else:
        tmp = 0
        for i in s[b-2:d+1]:
            if tmp ==3:
                result = 'Yes'
            if i =='.':
                tmp +=1
            else:
                tmp = 0
        if result =='Yes':
            result = rock(b, d - 1)
        if result =='Yes':
            result = rock(a,c-1)

    print(result)

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


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

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

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

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, input().split())
S = input()
S =S+"#"
S =S+"#"
S =S+"#"
answer = 1
a = 1
distance = []
distance_2 = []
for n in range(A-1,max(C-1,D-1)):
  a += 1
  if S[n] == "#":
    distance.append(a)
    a = 0
if 1 in distance:
  answer = 0
if D < C and answer == 1:
  a = 1
  for n in range(B-3,D):
    a += 1
    if S[n] == "#":
      distance_2.append(a)
      a = 0
  if max(distance_2) < 4:
    answer = 0
  if S[D] == "." and S[D-2] ==".":
    answer = 1
  if S[D-2] == "#" and max(distance_2) < 4:
    answer = 0
if answer == 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = [int(i) for i in input().split()]
s = input()
t = s.split("#")
cnt = -1
if(s.count('##') > 0):
    frag = 0
elif(c<d):
    frag = 1
else:
    frag = 0
    frag1 = 0
    frag2 = 0
    frag3 = 0
    frag4 = 0
    for i in range(len(t)): #cnt...(i個目の#までの文字数),cntがdより小さかったら追い越せる
        if(cnt < d and i > 0):
                if(t[i].count('.') >= 3):
                    frag1 = 1
        cnt += len(t[i])+1
    cnt -= t[len(t)-1].count('.')
    if(s[b] == '.' or frag1 == 1):
        frag2 = 1
    if((s[d-2] == '.' or s[d] == '.') or frag1 == 1):
        frag3 = 1
    if((d + 1 < c) or frag1 == 1):
        frag4 = 1
    if(frag1 == 1 and frag2 == 1 and frag3 == 1 and frag4 == 1):
        frag = 1
if(frag == 1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,a,b,c,d=LI()
  s=S()

  # print(s[a-1:c])
  # print(s[b-1:d])
  if '##' in s[a-1:c-1]:
    return 'No'
  if '##' in s[b-1:d-1]:
    return 'No'
  
  if d<c:
    if '...' not in s[b-2:d]:
      return 'No'
    if '#.#' not in s[b-2:d]:
      return 'No'

  return 'Yes'

print(main())

Submission status: Wrong Answer

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

s_cnt = 0
max_s_cnt = 0
pre_s = ''

goal = max(C, D)

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

for i in range(A-1, goal):
  if pre_s == "#":
    if S[i] == "#":
      print("No")
      exit()
  if i > B -1 and i < D + 1:
    if S[i] == '.':
      s_cnt += 1
      if max_s_cnt < s_cnt:
        max_s_cnt = s_cnt
    else:
      s_cnt = 0
  pre_s = S[i]
#  print(max_s_cnt)
  
if C < D:
  print("Yes")
else:
  if max_s_cnt >= 3:
    print("Yes")
  else:
    print("No")