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:
#!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+1, c-1):
        if s[i] == "#" and s[i + 1] == "#":
            print("No")
            return
    for i in range(b+1, d-1):
        if s[i] == "#" and s[i + 1] == "#":
            print("No")
            return
    print("Yes")
    
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

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

Submission status: Wrong Answer

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

if C < B:
    if S[A-1:C].find('##') < 0 and S[B-1:D].find('##') < 0: print 'Yes'
    else: print 'No'
else:
    if S[B-1:D].find('##') >= 0: print 'No'
    else:
        if S[A-1:C].find('##') >= 0: print 'No'
        list_s = list(S)
        list_s[D-1] = '#'
        S = ''.join(list_s)
        if S[A-1:C].find('##') >= 0:
            if S[B-1:D].find('...'): 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()

flagA = True
flagB = True

for i in range(d - b - 1):
    if s[b + i] == "#" and s[b + i + 1] == "#":
        flagB = False

for i in range(c - a - 1):
    if ((s[a + i] == "#") or (a + i == d - 1)) and ((s[a + i + 1] == "#") or (a + i + 1 == d - 1)):
        flagA = False
        for j in range(c - a - 2):
            if (s[a + j] == "." and s[a + j + 1] == "." and s[a + j + 2] == "."):
                flagA = True

if flagA and flagB:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)

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

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

n,a,b,c,d=intinput()
s=input()
if c<d:
    if x(s[a-1:d]):
        print("Yes")
    else:
        print("No")
else:
    try:
        s[b-1:d].index("...")
    except:
        print("No")
    else:
        if x(s[a - 1:c]):
            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] and C < D or '...' in S[A:C]:
        print('Yes')
    else:
        print('No')
    return

main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n, a, b, c, d = map(lambda x: int(x) - 1, input().split())
s = list(input())

if c < d:
    while b < d:
        if s[b + 1] == '.':
            b += 1
        elif b + 2 < n and s[b + 2] == '.':
            b += 2
        else:
            print('No')
            exit()
    while a < c:
        if s[a + 1] == '.':
            a += 1
        elif a + 2 < n and s[a + 2] == '.':
            a += 2
        else:
            print('No')
            exit()
    print('Yes')
else:
    s[b] = 'b'
    while a < b:
        if s[a + 1] == '.':
            a += 1
        elif a + 2 < n and s[a + 2] == '.':
            a += 2
        elif b < d:
            if s[b + 1] == '.':
                s[b] = '.'
                s[b + 1] = 'b'
                b += 1
            elif b + 2 <= d and b + 2 < n and s[b + 2] == '.':
                s[b] = '.'
                s[b + 2] = 'b'
                b += 2
            else:
                print('No')
                exit()
        else:
            print('No')
            exit()
    while a < c:
        if s[a + 1] == '.':
            a += 1
        elif a + 2 < n and s[a + 2] == '.':
            a += 2
        else:
            print('No')
            exit()
    while b < d:
        if s[b + 1] == '.':
            b += 1
        elif b + 2 < n and s[b + 2] == '.':
            b += 2
        else:
            print('No')
            exit()
    print('Yes')

Submission status: Wrong Answer

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

S = list(input().split()[0])

result = "Yes"

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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


maxBtoDSeqSpaceLen=0
curSeqSpaceLen=0
curStoneLen=0

# 先にBがいけるか考える
# いけなければOUT
for b in range(B-1,D):
	if S[b] == ".":
		curSeqSpaceLen += 1
		curStoneLen = 0
	else:
		curSeqSpaceLen = 0
		curStoneLen += 1

	if 2 == curStoneLen:
		print("No")
		exit(0)

	maxBtoDSeqSpaceLen=max(maxBtoDSeqSpaceLen,curSeqSpaceLen)


# print(maxBtoDSeqSpaceLen)

curStoneLen=0

if D < C and maxBtoDSeqSpaceLen < 3:
	# AはBをかわさないといけないのに、かわすスペースが無い
	print("No")
	exit(0)	
else:
	# その他の場合は、Bを無視して良い
	for a in range(A-1,C):
		if S[a] == ".":
			curStoneLen = 0
		else:
			curStoneLen += 1

		if 2 == curStoneLen:
			print("No")
			exit(0)


print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

fin = sys.stdin.readline
N, A, B, C, D = [int(elem) for elem in fin().split()]
cell_list = fin().split()[0]

init_max = max(A, B)
init_min = min(A, B)
end_max = max(C, D)
end_min = min(C, D)

after_min_cells = cell_list[init_min:end_max-2]
after_max_cells = cell_list[init_max:end_min+1]
# 途中に#が2つ連続しないか
if '##' in after_min_cells:
    result = 'No'
# 入れ替えが必要かどうか
elif (A-B) * (C-D) < 0:
    # 途中に.が3つ連続するかどうか（＝入れ替えが可能かどうか）
    if '...' in after_max_cells:
        result = 'Yes'
    else:
        result = 'No'
else:
    result = 'Yes'

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    inp = input()
    st = inp.split()
    n = int(st[0])
    a = int(st[1])
    b = int(st[2])
    c = int(st[3])
    d = int(st[4])
    inp = input()
    # 2 rocks
    rock_count = 0
    for i in range(a, b):
        if inp[i] == '#':
            rock_count += 1
        elif inp[i] == '.':
            rock_count = 0
        if rock_count == 2:
            print("No")
            return

    max_cd = c if c > d else d
    continuous_count = 0
    nothing_count = 0
    nothing_3 = False
    if inp[b-1] == '.':
        nothing_count += 1
    for i in range(b, max_cd):
        if inp[i] == '#':
            continuous_count += 1
            nothing_count = 0
        elif inp[i] == '.':
            continuous_count = 0
            nothing_count += 1
        if continuous_count == 2:
            print("No")
            return
        if nothing_count == 3 and i < d + 2:
            nothing_3 = True

    # c < d
    if c < d or nothing_3:
        print("Yes")
    else:
        print("No")
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def checker(start, end, S):
    check_rock = 0
    check_emp = 0
    M = "Only"
    for i in range(start, end):
        if S[i] == ".":
            check_emp += 1
            check_rock = 0
            if check_emp == 3:
                M = "Yes"
        else:
            check_rock += 1
            check_emp = 0
            if check_rock == 2:
                return "No"
    return M


checkB = checker(B, D, S)
checkA = checker(A, C, S)

if C > D:
    if checkA == "No" or checkB == "No" or checkB == "Only":
        print("No")
    else:
        print("Yes")
else:
    if checkA == "No" or checkB == "No":
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

S=input()

if C<D:
    for i in range(B, D-1):
        if S[i]=='#' and S[i+1]=="#":
            print("No")
            exit(0)
    for i in range(A, B-1):
        if S[i]=='#' and S[i+1]=="#":
            print("No")
            exit(0)
    print("Yes")
else:
    flag=False
    for i in range(B, D-1):
        if S[i]=='#' and S[i+1]=="#":
            print("No")
            exit(0)
        if S[i]=='.' and S[i+1]=='.' and S[i+2]=='.':
            flag=True
    for i in range(A, C-1):
        if S[i]=='#' and S[i+1]=="#":
            print("No")
            exit(0)
    print("Yes" if flag else "No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
mx = max(C,D)
r_count = [len(s) for s in S[A-1:mx+1].split('.') if len(s) > 1]
if r_count != []:
    print('No')
    exit()
if C < D:
    print('Yes')
    exit()

count = [len(s) for s in S[A-1:D+1].split('#') if len(s) > 2]
print('Yes' if len(count) > 0 else 'No')

Submission status: Wrong Answer

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

S = [1] + [ 1 if x == "#" else 0 for x in input()]

S[A] = 2
S[B] = 3


if B < A:
    A, B = B, A
    C, D = D, C

enable = True

for i in range(min(A, B)+1, max(C, D)-1):
    if S[i] == S[i+1] == 1:
        enable = False
        break

if A < B < D < C:
    vcnt = 0
    for i in range(B-1, D+1+1):
        if S[i] == 0:
            vcnt += 1
            if vcnt >= 3:
                break
        else:
            vcnt = 0
    else:
        enable = False

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

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,d+1):
            if s[i]=='#'and s[i+1]=='#':
                result='No'
            if s[i]=='#':
                if tmp > cnt:
                    cnt = tmp
                    tmp=0
            else:
                tmp +=1
        if cnt < 3:
                result = 'No'
        if result =='Yes':
            for i in range(a,c):
                if s[i]=='#'and s[i+1]=='#':
                    result='No'
    else:
        for i in range(b,d):
            if s[i] =='#' and s[i+1]=='#':
                result ='No'
                break
        if result=='Yes':
            for i in range(a,c):
                if s[i] =='#' and s[i+1]=='#':
                    result = 'No'
    print(result)

main()

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = list(map(int, input().split()))
S = input()
X = [".", "#"]
Ans = ["Yes", "No"]

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

f = 0
if A < B:
  if (B < C and D < C) or (A > D and C > D):
    f = 1


if A < C:
  a, b = A, C
else:
  a, b = C, A
s = 0
for i in range(a, b + 1):
  if S[i] == X[1]:
    if s == 1:
      print(Ans[1])
      exit()
    s = 1
  else:
    s = 0

if B < D:
  a, b = B, D
else:
  a, b = D, B
for i in range(a, b + 1):
  if S[i] == X[1]:
    if s == 1:
      print(Ans[1])
      exit()
    s = 1
  else:
    s = 0

if f == 0:
  print(Ans[0])
  exit()


s = 0
for i in range(B - 1, min(D + 1, N)):
  if S[i] == X[1]:
    if s == 1:
      break
    else:
      s = 1
  else:
    if s == 1:
      s = -1
    else:
      s -= 1
      if s == -3:
        print(Ans[0])
        exit()

print(Ans[1])

Submission status: Wrong Answer

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

if ('##' in s[b:d]) and ('##' in s[a:c]):
    print('No')
elif c > d:
    if '...' in s[b - 1:d + 1]:
        print('Yes')
    else:
        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):
    A -= 1
    B -= 1
    C -= 1
    D -= 1

    S_original = S
    S = list(S_original)

    flag = False
    
    # case1 Cに先にたどり着くパターン
    S[C] = '#'
    S[B] = '#'

    S = ''.join(S)
    if '##' in S[A+1:C]:
        pass
    elif '##' in S[B+1:D]:
        pass
    else:
        flag = True

    # case2 Dに先にたどり着くパターン
    S = list(S_original)

    S[D] = '#'
    S[A] = '#'

    S = ''.join(S)
    if '##' in S[A+1:C]:
        pass
    elif '##' in S[B+1:D]:
        pass
    else:
        flag = True

    # case 3
    S = list(S_original)

    S = ''.join(S)
    if '...' in S[B:C] or '..' == S[B+1:B+1+2] or '..' == S[C-2:C]:
        if '##' in S[A+1:C]:
            pass
        elif '##' in S[B+1:D]:
            pass
        else:
            flag = True

    if flag == True:
        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:
n,a,b,c,d=map(int, input().split())
S='.'+input()
dpa=[0]*(n+1)
dpb=[0]*(n+1)
seta=[c]
setb=[d]
if d<c:
    if S[b:d+2].find('...')>0:
        S[b:d+2].replace('...', '.#.', 1)
        while seta:
            i = seta.pop()
            if i>0 and S[i-1]=='.' and dpa[i-1]==0:
                dpa[i-1]=1
                seta.append(i-1)
            if i>1 and S[i-2]=='.' and dpa[i-2]==0:
                dpa[i-2]=1
                seta.append(i-2)
        while setb:
            i = setb.pop()
            if i>0 and S[i-1]=='.' and dpb[i-1]==0:
                dpb[i-1]=1
                setb.append(i-1)
            if i>1 and S[i-2]=='.' and dpb[i-2]==0:
                dpb[i-2]=1
                setb.append(i-2)

else:
    while setb:
        i = setb.pop()
        if i>0 and S[i-1]=='.' and dpb[i-1]==0:
            dpb[i-1]=1
            setb.append(i-1)
        if i>1 and S[i-2]=='.' and dpb[i-2]==0:
            dpb[i-2]=1
            setb.append(i-2)
    while seta:
        i = seta.pop()
        if i>0 and S[i-1]=='.' and dpa[i-1]==0:
            dpa[i-1]=1
            seta.append(i-1)
        if i>1 and S[i-2]=='.' and dpa[i-2]==0:
            dpa[i-2]=1
            seta.append(i-2)
if dpa[a]==1 and dpb[b]==1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

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

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

print("Yes")

Submission status: Wrong Answer

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

str_ac = str[A:C-1]
str_bd = str[B:D-1]
#print(str_ac)
#print(str_bd)

if C<D:
  if str_ac.find("##") == -1 and str_bd.find("##") == -1:
    print("Yes")
  else:
    print("No")
else:
  if str_ac.find("##") != -1 or str_bd.find("##") != -1 or str_bd.find("...") == -1:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

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

def check() :
    if '##' in S[A-1:C] or '##' in S[B-1:D] :
        return 'No'

    if C < D or '...' in S[B-1:D] or S[B-2:B+1] == '...' :
        return 'Yes'

    return 'No'
        

print(check())

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
koerunka = (not ((A<B and C<D) or (B<A and D<C)))# or (C<B or A<D)
koreikoukoerenyo=float('inf')
for i in range(min(A,B), N):
	if S[i-1] == S[i] == '#':
		koreikoukoerenyo = i
		break
	if S[i-3] == S[i] == '#':
		if koerunka:
			koreikoukoerenyo = i-2
			break
muripo=koreikoukoerenyo < max(C,D)

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

Submission status: Wrong Answer

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

#jumpable
jumpable = 1
for i in range(A, max(D, C)):
    if S[i]=="#":
        if S[i+1]=="#":
            jumpable = 0
            break;

#飛び越える
if(D<C):
    changable = 0
    for i in range(B-1, D-1):
        if S[i]==".":
            if S[i+1]==".":
                if S[i+2]==".":
                    changable=1
                    break
    if(changable==0):
        jumpable=0

if(jumpable==0):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

# bをさきに
if c > d:
        a,b = b,a
        c,d = d,c

if a < b:
        # bだけ考える
        # aはうごかさない
        t = s[b:d]
        if t.count('##'):
                print('No')
                exit()
        t = s[a:c]
        if t.count('##'):
                print('No')
                exit()
        print('Yes')
        exit()
else:
        t = s[b:d]
        if t.count('##'):
                print('No')
                exit()
        t = s[a-1:c+1]
        if t.count('...') == 0:
                print('No')
                exit()
        print('Yes')
        exit()

Submission status: Wrong Answer

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

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

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

if rock==0 and ((a-b)*(c-d)>0 or (blank==1 and (a-b)*(c-d)<0)):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

def judge(start,goal):
    for i in range(start,goal-1):
        if s[i] == "#" and s[i+1] == "#":
            return 0
    return 1

def full_judge (start,obst,obfin,goal):
    if s[obst-2] == "." and s[obst] == "." :
        return 1
    for i in range(start-1,goal-2):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            return 1
    return 0


if c<b:
    if (judge(a,c) and judge(b,d)):
        print("Yes")
    else:
        print("No")
elif c<d:
    if (judge(a,c) and judge(b,d)):
        print("Yes")
    else:
        print("No")
else:
    if judge(b,d) and full_judge(a,b,d,c) and judge(a,c):
        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")
    quit()

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

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


print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=list(input())
s[c-1]="c"
s[d-1]="d"
flag=False
lim=max(c,d)
for i in range(a+1,lim-1):
  if s[i]!="#":
    if s[i-1]!="#" and s[i+1]!="#":
      flag=True
    continue
  if s[i+1]=="#":
    print("No")
    exit()
if flag==False and d<c and (s[d-2]=="#" or s[d]=="#"):
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

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

if '#' not in s:
    print('YES')
elif '#.#' in s and a < s.index('#.#') and s.index('#.#') < c:
    print('NO')
elif '#.#' in s and b < s.index('#.#') and s.index('#.#') < d:
    print('NO')
elif '#..#' in s and a < b and c > d:
    print('NO')
elif '#..#' in s and a > b and c < d:
    print('NO')
elif '...' in s:
    print('YES')
elif c < d:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

Solution code:
def valid_check(n, a, b, c, d, s):
    if not two_rocks(s[b:d]):
        return 0
    # if not two_rocks()
    if c < d:
        return two_rocks(s[a:c])
    else:
        return three_spaces(s[a:c+1])


        # for possibility in enumerate_possibilities(b, d, s):
        #     if two_rocks(possibility[a:c]):
        #         return 1
        # return 0

def three_spaces(s):
    for i in range(len(s)-2):
        if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
            return 1
    return 0

# def enumerate_possibilities(b, d, s):
#     possibilities = []
#     for i in range(d-b+1):
#         if s[b+i]=='.':
#             tmp = s.copy()
#             tmp[b+i] = '#'
#             possibilities.append(tmp)
#     return possibilities


def two_rocks(s):
    for i in range(len(s)-1):
        if s[i]=='#' and s[i+1]=='#':
            return 0
    return 1

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


if valid_check(n, a, b, c, d, s):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
s = input()
State = "Yes"
for i in range(B-1,D-1):
    if s[i] == "#" and s[i+1] == "#":
        State == "No"
        break
if C < D:
    for i in range(A-1,C-1):
        if s[i] == "#" and s[i+1] == "#":
            State = "No"
            break
elif State == "Yes":
    State = "No"
    for i in range(B-2,D-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            State = "Yes"
            break
    for i in range(D,C-1):
        if s[i] == "#" and s[i+1] == "#":
            State = "No"
            break
    for i in range(A-1,B-1):
        if s[i] == "#" and s[i+1] == "#":
            State = "No"
            break
print(State)

Submission status: Wrong Answer

Solution code:
# coding:utf-8

import math

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

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
for i in range(a - 1, d - 1):
    if s[i] == "#" and s[i + 1] == "#":
        print("No")
        exit()
if c > d:
    f = s[b - 1:].find("...")
    if f == -1:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
L=input()[a:max(c,d)+1]
f=0
r="."
for i in list(L):
  if r=="#" and i=="#":
    f=1
    break
  r=i

if c < d:
  print('No' if f==1 else 'Yes')
else:
  g=0
  t="#"
  s="#"
  for i in range(b-1,d):
    if L[i-1:i+2]=="...":
      g=1
      break
    s=i
  print('No' if f==1 or g==0 else '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(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
if lastfunuke < lastsunuke:
    for j in range(max(firstsunuke, firstfunuke)-2, min(lastsunuke, lastfunuke)-1-1):
        if s[j] == '.' and s[j+1] == '.' and s[j+2] == '.':
            nukaseruflag += 1
            break
else:
    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())
a-=1
b-=1
c-=1
d-=1
s=input()
m=[0 for i in range(n)]
#a-c,b-d
#abcd
#abdc
for i in range(n):
  if s[i]=="#":
    m[i]=1
if c<d:#abcd
  if "##" in s[a:d]:
    print("NO")
  else:
    print("YES")
else:#d<c abdc
  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())

Sstr=input()


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

Submission status: Wrong Answer

Solution code:
def check(list,a,b,e,d):
    i,z,count,counter,c=a,True,0,0,0
    check1=0
    while i<b:
        if list[i]=='#':
            c+=1
        if list[i]=='.':
            c=0
        if c>=2:
            check1+=1
        i+=1
    if check1>0:
        return False
    c=0
    check1=0
    i=max(a,b)
    while i<max(e,d) and z:
        if list[i]=='#':
            counter=0
            c+=1
        if list[i]=='.':
            counter+=1
            c=0
        if counter>=3:
            count+=1
        if c>=2:
            check1+=1
        i+=1
    
    if check1>0:
        return False
    else:
        if d>e:
            return True
        elif d==c:
           
            return False
        else:
            if count>1:
                
                return True
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 = S + '#'
 
def continuous_rock_search(S):
    for i in range(len(S) - 1):
        if S[i] == '#' and S[i+1] == '#':
            return True
    return False
  
def validation_funuke_move(S, B, D):
    '''
    ふぬけ君が両隣に岩がなくなるまで移動したとき、Dより向こうにはイカないことを確認する。
    True/False and ふぬけの移動後の位置
    '''
    funuke_position = B
    while (B <= D):
        if (S[B-2] == '#' or S[B] == '#'):
            if S[B] == '.' :
                B = B + 1
            else:
                B = B + 2
        elif (S[B-2] == '.' and S[B] == '.'):
            return True, B
    
    return False, -1
  
def KenKenRace(S, A, B, C, D):
    if continuous_rock_search(S):
        return False
    
    if C < D:
        return True
    
    if D < C:
        valid , _ = validation_funuke_move(S, B, D)
        if valid:
            return True
        else:
            return False
          
if KenKenRace(S, A, B, C, D):
    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[A-1:C]:
	print("No")
elif "##" in S[B-1:D]:
	print("No")
elif D < C:	# need to reverse
	if not "..." in S[A-1:C]:
		print("No")
	elif S[D-2:D] == "#..":
		print("No")
	else:
		print("Yes")
else:
	print("Yes")