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:
num_list = input().split()
S = input()
num_list = [int(x) for x in num_list]
# print(num_list)

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

"""
A = 1
B = 3
C = 7
D = 6
N = 7
"""
# print(S)
l_s = list(S)
cnt = 1
for i in range(0, len(l_s)):
    if l_s[i] == ".":
        l_s[i] = cnt
    cnt += 1
# print(l_s)

ans = 0
while True:
    if A + 1 != B and A + 1 != '#':
        A += 1
    if A + 2 != B and A + 2 != '#':
        A += 2  
    if B + 1 != A and B + 1 != '#':
        B += 1
    if B + 2 != A and B + 2 != '#':
        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:
n,a,b,c,d=map(int,input().split())
s=input()
if s[:max(c,d)].count("##")>0:
    print("No")
elif c<d:
    print("Yes")
else:
    if s[b-1:d+1].count("...")==0:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    split = input().split(' ')
    n = int(split[0]) - 1
    a = int(split[1]) - 1
    b = int(split[2]) - 1
    c = int(split[3]) - 1
    d = int(split[4]) - 1
    s = input()
    isOK = False
    if c < d:
        isOK = not ('##' in s[a:c] or '##' in s[b:d])
    else:
        if d - b == 1:
            isOK = (not'##' in s[a:c]) and (not s[d+1] == '#')
        else:
            isOK = (not ('##' in s[a:c] or '##' in s[b:d])) and ('...' in s[b:d+1])
    print('Yes' if isOK else 'No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
# import re
import sys
# print(S[min(A,B):max(C,D)-1], S[min(A,B):max(C,D)-1].count("##"))
# print(S[B:D-1], S[B:D-1].count("..."))
# print(S[A:C-1], S[A:C-1].count("..."))

if S[A:max(C,D)-1].count("##"):
    print("No")
    sys.exit()
if C > D:
    if not S[B:D+1].count("..."):
        # if not S[D-2] == "." and S[D] == ".":
        print("No")
        sys.exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: int, B: int, C: int, D: int, S: str): 
    if(C < D):
        if(S[A-1:C].count('##') == 0 and S[B-1:D].count('##') == 0):
            print(YES)
    elif(C > D):
            if(S[B-1:D].count('...') == 0):
                print(NO)
            else:
                st = ''.join(list(S[:D]))
                # st = list(S)
                # st[B-1] = '#'
                # print(''.join(st[B-1:D]))
                if(st.rfind('...')+2 == B):
                    print(NO)
                else:
                    print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, a, b, c, d = map(int, input().split())
s = input()

for idx, masu in enumerate(s):
    if idx < b:
        continue
    if masu == '.':
        start = idx
        break

# construct rle
rle = list()
last_masu = s[start]
cnt = 0
for masu in s[start:]:
    if masu == last_masu:
        cnt += 1
    else:
        rle.append(cnt)
        last_masu = masu
        cnt = 1
rle.append(cnt)

for idx in range(1, len(rle), 2):
    if rle[idx] > 1:
        print('No')
        exit()

if c > d:
    is_reverse = True
else:
    is_reverse = False

if is_reverse:
    flag = False
    for idx in range(0, len(rle), 2):
        if rle[idx] > 2:
            flag = True
            break
    if flag:
        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()
flag=0
span=0
buf=-5
if(c<d):
    for i in range(a-1,d):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
else:
    for i in range(a-1,c):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
        elif s[i]=='#' or i==d-1:
            buf=max([span,buf])
            span=0
        elif i<d+1:
            span+=1
    if buf<=2:
        flag=1
        #print(buf)
print('No' if flag==1 else 'Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
bn=b-1
bflg=False
while True:
    if bn==d-1:
        bflg=True
        break
    if s[bn+1]=='.':
        bn+=1
        continue
    elif s[bn+2]=='.':
        bn+=2
        continue
    else:
        break
if not bflg:
    print('No')
    exit()

if c>d:
    if s[b:bn-1].count('..')==0:
        if b==d-1:
            print('No')
            exit()
        if s[b-2]=='#' or s[b]=='#':
            print('No')
            exit()

an=a-1
aflg=False
while True:
    if an==c-1:
        aflg=True
        break
    if s[an+1]=='.':
        an+=1
        continue
    elif s[an+2]=='.':
        an+=2
        continue
    else:
        break
if not aflg:
    print('No')
    exit()
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 < D のとき
        if 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 __canOvertake__(self, lower):
        isTriple = False
        objectCount = 0
        severalCount = 0

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

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

            if objectCount == lower:
                # この位置 or 次の位置で3連続でない場合, 追い越せない
                if severalCount < 2:
                    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())
a,b,c,d=a-1,b-1,c-1,d-1
s=input()
dp=[[0 for i in range(n)]for j in range(4)]
if c>d:
    c,d=d,c
    a,b=b,a
dp[0][a]=1
dp[1][b]=1
dp[2][c]=1
dp[3][d]=1
for i in range(n):
    for j in range(4):
        if j<2:
            if dp[j][i]==1:
                if i+1<n and s[i+1]=='.':
                    dp[j][i+1]=1
                if i+2<n and s[i+2]=='.':
                    dp[j][i+2]=1
        else:
            ii=n-i-1
            if dp[j][ii]==1:
                if ii-1>=0 and s[ii-1]=='.':
                    dp[j][ii-1]=1
                if ii-2>=0 and s[ii-2]=='.':
                    dp[j][ii-2]=1

if dp[0][c]==1 and dp[1][d]==1:
    if a<b<c<d:
        print('Yes')
        exit()
    elif a<c<b<d:
        print('Yes')
        exit()
    if '...' in s[max(a,b):min(c,d)+1]:
        print('Yes')
        exit()
    for i in range(max(a,b),min(c,d)+1):
        if dp[0][i]==dp[2][i] and dp[1][i]==dp[3][i] and dp[0][i]!=dp[1][i]:
            print('Yes')
            exit()
    print('No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
j = 0
flag = False
fflag = False

for i, k in enumerate(s):
  if k == '.':
    j += 1
  else:
    if j >= 3 and i - j + 1 < d and b < i:
      flag = True
    if s[i-1] == '#' and i < max(c, d):
      fflag = True
    j = 0

if fflag:
  print('No')
else:
  if c > d and flag:
    print('Yes')
  elif c < d:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=list(map(int,input().split()))
s=input().rstrip()
vis=[False]*(n)
vis2=[False]*(n)
flag=1
vis[b-1]=True
set1=set()
set2=set()

for i in range(b-1,n):
    if vis[i]==True:
        set1.add(i)
        if i+1<n:
            if s[i+1]=='.':
                set1.add(i+1)
                vis[i+1]=True
        if i+2<n:
            if s[i+2]=='.':
                vis[i+2]=True
vis2[a-1]=True
for i in range(a-1,n):
    
    if vis2[i]==True:
        set2.add(i)
        if i+1<n:
            if s[i+1]=='.':
                vis2[i+1]=True
        if i+2<n:
            if s[i+2]=='.':
                vis2[i+2]=True

if vis[d-1]==True and vis2[c-1]==True and c!=d:
    if d<c:
        if (vis2[d-1]==True and vis2[d-2]==False):
            
            print('No')
        elif len(set1&set2)==0:
            print('No')
            
        else:
            print('Yes')
    else:
        print('Yes')
        
else:
    print('No')

Submission status: Wrong Answer

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

flag = True

# c < dならbを先にゴールさせれば良い
s_bd = s[b:d-1]
for i in range(len(s_bd)-1):
    if s_bd[i:i+2] == "##":
        flag = False
        break
s_ac = s[a:c-1]
for i in range(len(s_ac)-1):
    if s_ac[i:i+2] == "##":
        flag = False
        break

if c > d:
    # ゴールの左が#
    if s[d-2] == "#" or s[b] == "#":
        s_bd = s[b-1:d]
        has_ddd = False
        for i in range(len(s_bd)-2):
            if s_bd[i:i+3] == "...":
                has_ddd = True
        if has_ddd == False:
            flag = False

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

Submission status: Wrong Answer

Solution code:
# coding:utf-8


def main():
    N, A, B, C, D = map(int, input().split())
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    iwa = "#"
    S = input()
    ans = True
    canexchange = False

    exchagable_list = []
    for i in range(N-2):
        temps = S[i:i+3]
        if temps == "...":
            exchagable_list.append(i)

    if len(exchagable_list) > 0:
        for i in exchagable_list:
            if i >= B and i <= min(C, D):
                canexchange = True

    for i in range(N-1):
        if S[i] == iwa and S[i+1] == iwa:
            if not (i+1 < A or i > max(C, D)):
                ans = False

    if ans:
        if C < D:
            ans = True
        elif C > D and canexchange:
            ans = True
        elif C > D and not canexchange:
            if S[D-1] == iwa or S[D+1] == iwa:
                ans = False
            else:
                ans = True

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys

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

lst = [0] * (n+1)
for i in range(1, n+1):
    if s[i-1] == '#':
        lst[i] = 1

if c < d:
    stone = 0
    for i in range(b+1, d+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    stone = 0
    for i in range(a+1, c+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    print('Yes')
else:
    brank = 0
    three = 0
    for i in range(b-1, c+1):
        if lst[i] == 0:
            brank += 1
            if brank == 3:
                three = 1
                break
        else:
            brank = 0
    if three == 0:
        print('No')
        sys.exit()
    stone = 0
    for i in range(b+1, d+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    stone = 0
    for i in range(a+1, c+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    print('Yes')

Submission status: Wrong Answer

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

if '##' in s:
    print('No')
elif c < d:
    print('Yes')
elif ('...' in s) and (s.find('...',-1) < d):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:






def check(b,d,path):
    seq = False
    for s in path[b:d]:
        if s == '#':
            if seq:
                return False
            else:
                seq = True
        else:
            seq = False  

    return True  


n,a,b,c,d = map( int, input().split() ) 
npath = input()
path = []
for s in npath:
    path.append(s)

a -= 1
b -= 1
c -= 1
d -= 1


ans = True
if c < d:
    ans = check(b,d,path) and check(a,c,path)
else:
    triple = 0
    for s in path[b-1:c+1]:
        if triple == 3:
            break
        if s == '#':
            triple = 0
        else:
            triple += 1

    if triple == 3:
        ans = check(a,d,path) and check(b,c,path)
    else:
        ans = False

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

Submission status: Wrong Answer

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

if Sp[A-1:max([C, D])+1].find('##') != -1:
    print('No')
    exit()

if C < D:
    print('Yes')
    exit()

if Sp[B-2:D].find('...') >= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

for k in range(min(A,B)-1,max(C,D)-2):
    if S[k] == S[k+1] == "#":
        print("No")
        exit(0)

if C < D:
    print("Yes")
    exit(0)
for k in range(min(A,B)-1,N-2):
    if S[k] == S[k+1] == S[k+2] == ".":
        if k+2 <= D and k+3 <= C:
            print("Yes")
            exit(0)
print("No")
exit(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,raw_input().split())
s=raw_input()
stone=0
i=min(a,b)-1
while i<max(c,d):
    count=0
    if s[i]=='#':
        count+=1
        for j in xrange(i+1,max(c,d)):
            if s[i]=='.':
                break
        if j != i:
            stone=2
            break
        i += abs(j-i)+1
    else:
        i += 1
if stone>=2:
    print "No"
else:
    if d>c:
        print "Yes"
    else:
        i=b-1
        empty=0
        while i<c:
            count = 0
            if s[i]==".":
                for j in xrange(i+1,c):
                    if s[i]=="#":
                        break
                if abs(j-i)+1>3:
                    empty=3
                    break
                i += abs(i-j)+1
            else:
                i += 1
        if empty>=3:
            print "Yes"
        else:
            print "No"

Submission status: Wrong Answer

Solution code:
import sys
import re
N, A, B, C, D = input().strip().split(" ")
S = input().strip()

m1 = re.finditer('##', S)
for match in m1:
    if match.start() > int(A) or match.end() < int(C) or match.end() < int(D):
        print('no')
        sys.exit()
if int(C) < int(D):
    print('yes')
    sys.exit()
else:
    m2 = re.finditer('...', S)
    for match in m2:
        if match.start() >= int(B) and match.end() < int(D):
            print('yes')
            sys.exit()
    print('no')
    sys.exit()

Submission status: Wrong Answer

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

ans = "Yes"
rock = list(filter(lambda i: s[i] == s[i + 1] == '#', range(n - 1)))
if 0 < len(rock) and max(a, b) - 1 <= rock[0] and rock[-1] <= min(c, d) - 1:
    ans = "No"
if b < c and not any(map(lambda i: b < i + 1 < min(c, d), list(filter(lambda i: s[i - 1] == s[i] == s[i + 1] == '.', range(1, n - 1))))):
    ans = "No"

print(ans)

Submission status: Wrong Answer

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

# 連続空白を調べる
isStone = False
spaceChainCount = 0
threeSpaceCenterIndex = -1
for i in range(len(s)):
    if s[i] == '#':
        # 2連続の場合
        if isStone:
            print("No")
            sys.exit()
        isStone = True
        spaceChainCount = 0
    else:
        isStone = False
        spaceChainCount += 1
        if spaceChainCount >= 3:
            threeSpaceCenterIndex = i - 1

# A,Bが入れ替わる場合
if ((a < b and c > d) or (a > b and c < d)):
    # 3連続空白が無い場合 or 3空白がA,B両方より左の場合
    if threeSpaceCenterIndex < 0 or (threeSpaceCenterIndex >= 0 and threeSpaceCenterIndex < max(a, b)):
        print("No")
        sys.exit()

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

Submission status: Wrong Answer

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

if B < C and C < D :
    if "##" in S[A-1:D-1] :
        print("No")
    else:
        print("Yes")
if B < D and D < C:
    if "##" in S[A-1:C-1] :
        print("No")
    else:
        # Bの一つ手前からDの次までに...があればよい
        if "..." in S[B-2:D]:
            print("Yes")
        else:
            print("No")

if C < B and B < D:
    # A..Cに2つ連続#がなければよい
    # B..Dに2つ連続#がなければよい
    if ("##" not in S[A-1:C-1]) and ("##" not 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()
for i in range(a, max(d - 2, c - 2)):
    if s[i] == "#" and s[i + 1] == "#":
        print("No")
        exit()
if c > d:
    f = s[b - 2:].find("...")
    if f == -1:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

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

judge = S.find("##")
#print(judge)
slist = list(S)
#print(slist[A::])
#print(judge)
if judge != -1:
  print("No")
else:
  if C < D:
    print("Yes")
  else:
    s_change= "".join(slist[A:C-1])
    #print(s_change)
    judge = s_change.count("..")
    #print(judge)
    if judge > 1:
      print("Yes")
    else:
      print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin

n, a, b, c, d = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()

# A..C 二つの岩 あったらだめ
# B..D二つの岩 あったらだめ
# D < Cのとき、 AがBを追い越せななかったらだめ

ans = "Yes"

rock = 0
for i in range(a, c):
    if '#' == s[i-1]:
        rock += 1
        if rock >= 2:
            ans = "No"
            break
    else:
        rock = 0

rock = 0
for i in range(b, d):
    if '#' == s[i-1]:
        rock += 1
        if rock >= 2:
            ans = "No"
            break
    else:
        rock = 0


space = 0
if d < c:
    ok = 0
    for i in range(b, d):
        if '.' == s[i-1]:
            space += 1
            if space >= 3:
                ok = 1
                break
        else:
            space = 0
    if '.' == s[d-1-1] and '.' == s[d+1-1]:
        ok = 1
    if '.' == s[d-1-1] and '.' == s[d-2-1]:
        ok = 1
    if '.' == s[b-1-1] and '.' == s[b+1-1]:
        ok = 1
    if b > 2 and '.' == s[b-1-1] and '.' == s[b-2-1]:
        ok = 1
    if 0 == ok:
        ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, A, B, C, D = map(int, input().split())
S = input()

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

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

Submission status: Wrong Answer

Solution code:
#Python標準入出力

import numpy as np

# 1行に複数の文字列（数字）を取得，整数に直す
# 今回は2つ受け取って，足し算する

# 0 len root 1 sunuke 2 funuke 3 point1 4 point2 funuke
Masu = list(map(int, input().split()))
Root = input()

#Answer 1 パターン入れ込み
# print(Masu[3])
# print(Root)

# print(Root[0])

Judge = True

Rock = []
for i in range(Masu[0]):
    if Root[i] == "#":
        Rock.append(i+1)

for j in range(Masu[0]):
    if Root[j] == "#" and Root[j-1] == "#":
        Judge = False
    if Masu[3] == j+1 and Masu[4] == j+1-1 and Root[j-2] == "#":
        Judge = False
    if Masu[3] == j+1 and Root[j-1] == "#" and Masu[4] == j+1-2:
        Judge = False

    if Masu[3] == j+1:
        for p in range(j):
            if Masu[4] == p+1 and Root[p-1] == "#":
                Judge = False

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




#Answer 2 動かし

Submission status: Wrong Answer

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

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:
    if "..." not in s[a-1:c]:
        print("No")
        exit()

if a > b and c < d:
    if "..." not in s[b-1:d]:
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
c1 = [0] * N
c2 = [0] * N
cnt1 = 0
cnt2 = 0
for i in range(N):
    if S[i] == '.':
        c2[i] = cnt2
        cnt2 = 0
        cnt1 += 1
    else:
        c1[i] = cnt1
        cnt1 = 0
        cnt2 += 1
res = [0] * N
index2 = []
index1 = []
for i in range(N):
    if c2[i] >= 2:
        index2.append(i)
    if c1[i] >= 3:
        index1.append(i)
flag = True
for i in index2:
    if A < i - c2[i] + 1 < C or B < i - c2[i] + 1 < D:
        flag = False
    if C < i < A or D < i < B:
        flag = False

if len(index1) == 0:
    if A < B and C > D:
        flag = False
    if A > B and C < D:
        flag = False

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

Submission status: Wrong Answer

Solution code:
def solve():
	cnt = 0
	for i in range(N):
		if S[i:i+1]=='#':
			cnt += 1
			if cnt==2:
				print('No')
				return
		else:
			cnt = 0

	if C<D:
		print('Yes')
		return

	cnt = 0
	for i in range(N):
		if S[i:i+1]=='.':
			cnt += 1
			if cnt==3 and i<=D:
				print('Yes')
				return
		else:
			cnt = 0
	print('No')

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

Submission status: Wrong Answer

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

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

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

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



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

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

Submission status: Wrong Answer

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

if Sp.find('##') != -1:
    print('No')
    exit()

if C < D:
    print('Yes')
    exit()

if Sp[B-2:D].find('...') >= 0:
    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[min(a,b)-1:max(c,d)]:
  print("No")
else:
  if c<d:
    print("Yes")
  else:
    if "..." in s[a-1:d+1]:
      print("Yes")
    else:
      print("No")

Submission status: Wrong Answer

Solution code:

N,A,B,C,D = map(int,input().split())
a= input()
f = 0
s = 0
d = 1
t = []
k = []

f1 = 0
s1 = 0
d1 = 1
t1 = []
k1 = []


for i in a[A-1:C]:
    if i == "." and f ==1:
        k.append(d)
        s = 1
        f = 0
    elif i == ".":s+=1
    
    elif i == "#" and f==0:
        t.append(s)
        d = 1
        f = 1
    elif i == "#":d+=1
else:
    if f==1:
        k.append(d)
    else:
        t.append(s)
for i in a[B-2:D]:
    if i == "." and f1 ==1:
        k1.append(d1)
        s1 = 1
        f1 = 0
    elif i == ".":s1+=1
    
    elif i == "#" and f1==0:
        t1.append(s1)
        d1 = 1
        f1 = 1
    elif i == "#":d1+=1
else:
    if f1==1:
        k1.append(d1)
    else:
        t1.append(s1)
# print(t,k)
# print(t1,k1)
if C < D :
    if len(k) == sum(k):
        print("Yes")
    else:
        print("No")
else:
    if len(k) == sum(k) and any([i > 2 for i in t1]) :
        print("Yes")
    elif len(k) == sum(k) and t1[-1] >1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if c < d:
    if '##' in s[a-1:d]:
        print('No')
    else:
        print('Yes')

else:
    if '##' in s[a-1:c]:
        print('No')
    elif '...' in s[b-2:d]:
        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()

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

    if s[d-2:d+1]=='#.#':
      return 'No'

  return 'Yes'

print(main())

Submission status: Wrong Answer

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

ans = True
d = False
for i in range(B,D-1):
    if(S[i] == "#" and d):
        ans = False
        break
    elif(S[i] == "#"):
        d = True
    else:
        d = False
d = False
for j in range(A,C-1):
    if(S[j] == "#" and d):
        ans = False
        break
    elif(S[j] == "#"):
        d = True
    else:
        d = False
if(C>D):
    ans = ans and S[B-1:D+1].count("...")!=0

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