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:
line = input().split()
object_ = input()

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

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

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

Submission status: Wrong Answer

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

# 3マス空きがあるか
white = []
for i in range(N - 2):
    if S[i] == "." == S[i + 1] == S[i + 2]:
        white.append(i + 1)

if C > D:
    # Aからスタート
    i = A - 1
    T = S.copy()
    T[B - 1] = "#"
    while C - 1 != i:
        if T[i + 1] == ".":
            i += 1
        elif T[i + 2] == ".":
            i += 2
        elif i + 1 == B - 1 or i + 2 == B - 1:
            es = False
            for w in white:
                if i < w <= D:
                    es = True
            if es:
                i = B - 1
            else:
                break
        else:
            break
    if i == C - 1:
        print("Yes")
        exit()
else:
    i = B - 1
    T = S.copy()
    while D - 1 != i:
        if T[i + 1] == ".":
            i += 1
        elif T[i + 2] == ".":
            i += 2
        else:
            break
    if i == D - 1:
        T2 = S.copy()
        T2[D-1] = "#"
        j = A - 1
        while C - 1 != j:
            if T[j + 1] == ".":
                j += 1
            elif T[j + 2] == ".":
                j += 2
            else:
                break
        if j == C - 1:
            print("Yes")
            exit()
print("No")

Submission status: Wrong Answer

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


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

  return s


def is_reachable(s, a, b):
  i = a
  while i < C:
    if i + 1 <= C and s[i + 1] == '.':
      i = i + 1
    elif i + 2 <= C and s[i + 2] == '.':
      i = i + 2
    else:
      break
  is_a = i == C

  i = b
  while i < D:
    if i + 1 <= D and s[i + 1] == '.':
      i = i + 1
    elif i + 2 <= D and s[i + 2] == '.':
      i = i + 2
    else:
      break
  is_b = i == D

  return is_a, is_b


def move(s, i, dest):
  i = i + 1

  if i == dest:
    return -1

  while i <= dest:
    if i == dest:
      return dest

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

    i = i + 1

  return -1


def main():
  a = A
  b = B

  for _ in range(1000):
    s = get(a, b)
    is_a, is_b = is_reachable(s, a, b)
    # print(_, (is_a, is_b), s)
    if is_a and is_b:
      return True
    elif not is_a:
      b = move(s, b, D)
      if b < 0:
        return False
    elif not is_b:
      a = move(s, a, C)
      if a < 0:
        return False
    else:
      return False


print('Yes' if main() else 'No')

Submission status: Wrong Answer

Solution code:
def clear_check(s,start,target):
    block_len = 0
    for i in range(start,target+1):
        if s[i] == '#':
            block_len += 1
        else:
            block_len = 0

        if block_len > 1:
            return False

    return True

def rev_check(s,start,end):
    space_len = 0
    for i in range(start,end+1):
        if s[i] == '.':
            space_len += 1
        else:
            space_len = 0

        if space_len >= 3:
            return True

    return False

def calc():
    n, a, b, c, d = [int(i) for i in input().split()]
    s = input()
    result = clear_check(s,a-1,c-1) or clear_check(s,b-1,d-1)

    if result and  c > d :
        result = rev_check(s,b-1,d-1)

    if result:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    calc()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def check(list,a,b,c,d):
    if c==d:
        return False
    i=a-1
    counter1=0
    while i<b-1:
        if list[i]=='#':
            counter1+=1
        else:
            counter1=0
        if counter1>=2:
            return False
        i+=1
    counter1=0
    check2,counter2=0,0
    i+=1
    while i<min(c-1,d-1):
        if list[i]=='#':
            counter1+=1
            counter2=0
        else:
            counter2+=1
            counter1=0
        if counter1>=2:
            return False
        if counter2>=3:
            check2+=1
        i+=1
    i+=1
    counter1=0
    while i<max(c-1,d-1):
        if list[i]=='#':
            counter1+=1
        else:
            counter1=0
        if counter1>=2:
            return False
        i+=1
    if d>c:
        return True
    else:
        if check2>=1:
            return True
        else:
            return False
m=list(map(int,input().strip().split()))
l=list(input())
if check(l,m[1],m[2],m[3],m[4]):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

S_rock = [s for s in S.split('.') if s ]
rock = list(set(S_rock))

if rock != ['#']:
    a = 1

S_mass = [s for s in S.split('#') if s]
mass = list(set(S_mass))

if mass == ['.','..'] or mass == ['.'] or mass == ['..'] or mass == ['..','.']:
    b = 0
else:
    b = 1

if D < C and b == 0:
    if S_list[D - 2] == '#':
        a = 1
    if S_list[D] == '#':
        a = 1

if a == 1:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
class KenkenRace:
    def __init__(self):
        N, A, B, C, D = map(int, input().split())
        S = [str(c) for c in input()]

        self.N = N
        self.A = A
        self.B = B
        self.C = C
        self.D = D
        self.S = S

    def main(self):
        result = False

        # C < B のとき
        if self.C < self.B:
            # 割れているので, A -> C and B -> D を検証
            result = self.__canSepClear__(self.A, self.C) and self.__canSepClear__(self.B, self.D)

        # C < D のとき
        elif self.C < self.D:
            # クリアできるか確かめる
            result = self.__canClear__(self.D)

        # D < C のとき
        else:
            # 追い越せるかどうかを確かめる and クリアできるか確かめる
            result = self.__canClear__(self.C) and self.__canOvertake__(self.D)

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

    def __canClear__(self, higher):
        isDouble = False
        preObject = ""
        for i in range(self.A - 1, higher):
            c = self.S[i]
            if c == "#" and preObject == "#":
                isDouble = True
                break
            else:
                preObject = c

        return not isDouble

    def __canSepClear__(self, start, end):
        isDouble = False
        preObject = ""

        for i in range(start - 1, end):
            c = self.S[i]
            if c == "#" and preObject == "#":
                isDouble = True
                break
            else:
                preObject = c

        return not isDouble

    def __canOvertake__(self, lower):
        isTriple = False
        objectCount = 0
        severalCount = 0

        for i in range(self.B - 1, lower):
            c = self.S[i]
            objectCount += 1

            # 何もない箇所が何連続目か, カウント
            if c == ".":
                severalCount += 1
            else:
                severalCount = 0

            if objectCount == lower:
                # この位置 or 次の位置で3連続でない場合, 追い越せない
                if severalCount < 2:
                    break
                elif severalCount == 2 and self.S[i + 1] == ".":
                    isTriple = True
                    break

            # 3連続で何もなければ追い越し可能か
            if severalCount == 3:
                isTriple = True
                break

        return isTriple


kenkenRace = KenkenRace()
kenkenRace.main()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if s[a-1:max(c,d)].count("##")>0:
    print("No")
elif c<d:
    print("Yes")
else:
    if s[b-2:d].count("...")!=0:
        print("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:C].find('##') >= 0 or st[B:D].find('##') >= 0:
        print('No')
    else:
        print('Yes')
else:
    # Cの方がおおきいケース 入れ替わる
    if st[A:C].find('##') >= 0:
        print('No')
    else:
        fnd = st.find('...', A-1, D+1)
        if fnd >= 0:
            if fnd+1 == B or fnd+3 == B:
                fnd = st.find('...', fnd+1, D+1)
                if fnd >= 0:
                    if fnd+1 == D or fnd+3 == D:
                        if st[D] == '.':
                            print('Yes')
                        else:
                            print('No')
                    else:
                        print('Yes')
                else:
                    print('No')
            else:
                print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
def count_renzoku_char(s, char):
    max_len = 0
    current_len = 0
    for c in s:
        if c == char:
            current_len += 1
        else:
            if max_len < current_len:
                max_len = current_len
            current_len = 0

    return max_len

if __name__ == "__main__":
    N, A, B, C, D = [int(x) for x in input().split()]
    S = input()

    def main():
        global A, B
        if C < D:
            raw_sharp = count_renzoku_char(S[A+1: D], '#')
            if raw_sharp >= 2:
                print('No')
                return
            else:
                print('Yes')
                return
        else:
            is_reached = False
            while(True):
                if A + 1 == C or A + 2 == C:
                    is_reached = True
                    break
                su2 = S[A+2]
                if su2 == '.':
                    A = A + 2
                    continue
                elif su2 == '#':
                    pass
                elif A + 2 == B:
                    if not (B == D or S[B+1] == '#'):
                        B = B + 1
                        A = A + 2
                        continue
                
                su1 = S[A+1]
                if su1 == '.':
                    A = A + 1
                    continue
                elif su1 == '#':
                    break
                elif A + 1 == B:
                    if not (B == D or S[B+1] == '#'):
                        B = B + 1
                        A = A + 1
                        continue
                    else:
                        break
                
                break
            
            print('Yes' if is_reached else 'No')

    main()

Submission status: Wrong Answer

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

        if max(cnt,tmp) < 3:
                result = 'No'
        elif result =='Yes':
            for i in range(a,c-1):
                if s[i]=='#'and s[i+1]=='#':
                    result='No'
    else:
        for i in range(b,d-1):
            if s[i] =='#' and s[i+1]=='#':
                result ='No'
                break
        if result=='Yes':
            for i in range(a,c-1):
                if s[i] =='#' and s[i+1]=='#':
                    result = 'No'
    print(result)

main()

Submission status: Wrong Answer

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

a_to_c = s[a-1:c-1]
b_to_d = s[b-1:d-1]
if (b-1)-1 >= 0:
    b_to_d2 = s[b-1-1:d-1]
else:
    b_to_d2 = s[b-1:d-1]

possibility = True

if a_to_c.find("##")!=-1 or b_to_d.find("##")!=-1:
    possibility = False
if c>d:
    if not(b_to_d2.find('...')!=-1):
        possibility = False

if possibility:
    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:
    s = list(s)
    h = s[b:d]
    for i in range(1,len(h)):
        if h[i]==h[i-1] and h[i]=="#":
            print("No")
            break
    else:
        hh = s[a:c]
        for i in range(1,len(hh)):
            if hh[i]==hh[i-1] and hh[i]=="#":
                print("No")
                break
        else:
            print("Yes")
else:
    if "..." in s[a:d]:
        h = s[a:c]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            hh = s[b:d]
            for i in range(1,len(hh)):
                if hh[i]==hh[i-1] and hh[i]=="#":
                    print("No")
                    break
            else:
                print("Yes")
    else:
        s = list(s)
        h = s[b:d]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            print("No")

Submission status: Wrong Answer

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

#for i in range(firstsunuke, lastsunuke-1):
#    if s[i] == '#' and s[i+1] == '#':
#        tobenaiflag += 1
#        break
#for k in range(firstfunuke, lastfunuke-1):
#    if s[k] == '#' and s[k+1] == '#':
#        tobenaiflag += 1
#        break
tobenaiflag=0
# if lastfunuke < lastsunuke:
#    for j in range(max(firstsunuke, firstfunuke)-1, lastfunuke-1):
#        if s[j] == '.' and s[j+1] == '.' and s[j+2] == '.':
#            nukaseruflag += 1
#            break
# else:
#    nukaseruflag += 1
nukaseruflag += 1
if tobenaiflag == 0 and nukaseruflag == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
T = S
if "##" in S[B:D-1] or "##" in S[A:C-1]:
    ans = False
else:
    if "..." in S[B:D-1]:
        ans = True
    elif S[B-2] == "." and S[B] == "." and "..." in S[A:C-1]:
        ans = True
    else:
        #B先動かす
        S = S[:D-1] + "#" + S[D:]
        if "##" in S[A:C]:
            ans = False
        else:
            ans = True
    #A先
    if ans == False:
        S = T
        if S[B-2] == "#" or S[B] == "#":
            ans = False
        else:
            S = S[:C-1] + "#" + S[C:]
            if "##" in S[B:D]:
                ans = False
            else:
                ans = True

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

Submission status: Wrong Answer

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

'''
7 1 2 3 4
....

7 1 3 5 7
.#.#.#.#.#.#

'''
#print(S)
iwa_cnt = 0
kusa_cnt = 0
result ='No'
for i,s in enumerate(S[A:max(C,D)-1]):
    #print(s)
    #print(i)
    #print(iwa_cnt)
    #print(kusa_cnt)
    if s =='#':
        iwa_cnt +=1
        kusa_cnt = 0
    else:
        if i + A - 1 > B -1:
            kusa_cnt +=1
        iwa_cnt = 0
    if iwa_cnt == 2:
        break
    if kusa_cnt == 1 and C < D:
        result = 'Yes'
    #if kusa_cnt == 2:
    #    result = 'Yes'
    if S[B-2] == '.' and kusa_cnt == 1 and  D < C:
        result = 'Yes'

print(result)



'''
Aの現在地からCまでに...が三つ続いていれば、
そこにCをおける
Cは##がない限り、さきに動かせばいいので、問題ない


'''
#print(N,M)
#print(target)
#print(P)

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 c > d and '...' not in roadc:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)

# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

def main():
	N, A, B, C, D = map(int, input().split(" "))
	#N = int(input())
	S = input()
	S = list(S)
	S = S[:-1]

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

	if C < D:
		S = S[A:D+1]
	else:
		S = S[A:C+1]

	iwa = []
	kara = []
	nige = []
	for i, val in enumerate(S):
		if val == "#":
			if len(iwa) > 1 and iwa[-1] == i-1:
				print("No")
				sys.exit()
			iwa.append(i)
		else:
			if len(kara) > 2 and kara[-1] == i-1 and kara[-2] == i-2:
				nige.append(i)
			kara.append(i)
	'''
	for i in range(A+1, C):
		if i in iwa:
			tmp = iwa.index(i)
			if len(iwa)-1 > tmp and iwa[tmp+1] == i+1:
				print("No")
				sys.exit()

	for i in range(B+1, D):
		if i in iwa:
			tmp = iwa.index(i)
			if len(iwa)-1 > tmp and iwa[tmp+1] == i+1:
				print("No")
				sys.exit()
	'''
	if A < B and B < C and C < D:
		print("Yes")
		sys.exit()
	elif A < C and C < B and B < D:
		print("Yes")
		sys.exit()
	else:
		for i in nige:
			if B < i and i+2 < D:
				print("Yes")
				sys.exit()
	'''
	elif A < B and B < D and D < C:
		for i in range(A+1, C):
			if i in kara:
				tmp = kara.index(i)
				if C >= i+2 and len(kara)-2 > tmp :
					if (kara[tmp+1] == i+1) and (kara[tmp+2] == i+2):
						print("Yes")
						sys.exit()
		print("No")
		sys.exit()
	'''
	print("No")
	

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

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

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

ans = 0
cnt = 0

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

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

Submission status: Wrong Answer

Solution code:
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum) 
 
flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if ((cumsum[i+2] - cumsum[i]) == 2):
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3] and (j + 2 <= D):
        flag_oinuki = True
 
if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000000)
 
N, A, B, C, D = map(int, input().split())
s = list(input())
 
A -= 1
B -= 1
C -= 1
D -= 1
 
for i in range(len(s)):
    if i == len(s) - 1:
        continue
    else:
        if s[i] == '#' and s[i+1] == '#':
            print("No")
            exit()
 
if D < C:
    tmp = 0
    for i in range(len(s)):
        if i == len(s) - 2 or i == len(s) - 1:
            continue
        else:
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.' and i + 2 <= D and A <= i and B - 1 <= i:
                tmp = 1
    if tmp != 1:
        print("No")
        exit()
 
 
 
def check(s, start, goal, ans):
    if start == goal:
        return 1
    if s[start] == '#':
        return 0
    if start + 1 <= N - 1:
        ans += check(s, start + 1, goal, ans)
    if start + 2 <= N - 1:
        ans += check(s, start + 2, goal, ans)
    return ans
 
ans = 0
if not check(s, B, D, ans):
    print("No")
    exit()
#s[D] = '#'
if not check(s, A, C, ans):
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
cou1 = 0
ans1 = 0
cou2 = 0
ans2 = 0
if C < D:
    S1 = S[A: D-1]
    for i in S1:
        if i == "#":
            cou1 += 1
        else:
            ans1 = max(ans1, cou1)
            cou1 = 0
    if ans1 < 2:
        print("Yes")
    else:
        print("No")
else:
    S1 = S[A: C-1]
    S2 = S[B: D+1]
    for i in S1:
        if i == "#":
            cou1 += 1
        else:
            ans1 = max(ans1, cou1)
            cou1 = 0
    for j in S2:
        if i == ".":
            cou2 += 1
        else:
            ans2 = max(ans2, cou2)
            cou2 = 0
    if ans1 < 2 and ans2 >= 3:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

S0 = S[:A]
Sa = S[A:C]
Sb = S[B:D]
S1 = S[D:]
if S0.rfind('##')>=0 and S1.find('##')>=0 :
    Sfe = S[S0.rfind('##'):S1.find('##')]
elif S0.rfind('##')>=0 :
    Sfe = S[S0.rfind('##'):]
elif S1.find('##')>=0 :
    Sfe = S[:S1.find('##')]
else :
    Sfe = S


#if S.find('##')>=0 and A<S.find('ABC')<C or B<S.find('ABC')<D:
if Sa.find('##')>=0 or Sb.find('##')>=0:
    ans = "No"

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

print(ans)

Submission status: Wrong Answer

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

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

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

    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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

Submission status: Wrong Answer

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

S = input()

def AA(mojiretu):
    if '##' in mojiretu:
     print("No")
    else:
     print("Yes")

Scp = S
if C < D:
      AA(Scp[A:D])
      
else:
    if "..." in Scp[B-1:D-1]:
      AA(Scp[A:C])
    else:
      Scp = Scp[:D-1]+"#" + Scp[D:]
      AA(Scp[A:C])

Submission status: Wrong Answer

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

a_to_c = s[a-1:c-1]
b_to_d = s[b-1:d-1]
if (b-1)-2 >= 0:
    b_to_d2 = s[b-1-2:d-1]
else:
    b_to_d2 = s[b-1:d-1]

possibility = True

if a_to_c.find("##")!=-1 or b_to_d.find("##")!=-1:
    possibility = False
if c>d:
    if not(b_to_d2.find('...')!=-1):
        possibility = False

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

Submission status: Wrong Answer

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

curval = "x"
cnt = 0
initidx = 0
ngarea = [-1]
triarea = [-1]

for idx,val in enumerate(S):
    if val == curval:
        cnt += 1
    else:
        if cnt >= 2 and curval == '#':
            ngarea.append(initidx + 1)
        elif cnt >= 3 and curval == '.':
            for i in range(3,cnt+1):
                triarea.append(initidx + 1 + i - 3)
        initidx = idx
        cnt = 1
    curval = val
else:
    if cnt >= 2 and curval == '#':
        ngarea.append(initidx + 1)
    elif cnt >= 3 and curval == '.':
        triarea.append(initidx + 1)

if C < D:
    isBflg = True
    isABflg = True
    for ngp in ngarea:
        if ngp > B and ngp < D:
            isBflg = False
        if ngp > A and ngp < B:
            isABflg = False
    if isBflg and isABflg:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
else:
    isChangeFlg = False
    # Changepoint = -1
    for trp in triarea:
        if trp >= A and trp + 1 >= B:
            Changepoint = trp + 1
            isChangeFlg = True
            break
    if isChangeFlg == False or Changepoint >= C or Changepoint >= D:
        print('No')
        exit()
    else:
        isBflg = True
        isABflg = True
        isChange2DFlg = True
        for ngp in ngarea:
            if ngp > B and ngp < Changepoint:
                isBflg = False
            if ngp > A and ngp < B:
                isABflg = False
            if ngp > Changepoint and ngp < D:
                isChange2DFlg = False
        if isBflg and isABflg and isChange2DFlg:
            print('Yes')
            exit()
        else:
            print('No')
            exit()

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 '##' in s:
    flg = False
if flg:
    print('Yes')
else:
    print('No')