Problem:


Score : 400 points

Problem Statement

There are N squares arranged in a row, numbered 1, 2, ..., N from left to right.
You are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.

In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.

You can repeat the following operation any number of times:

Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.

You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.

Determine whether this is possible.

Constraints

4 \leq N \leq 200\ 000

S is a string of length N consisting of . and #.

1 \leq A, B, C, D \leq N

Square A, B, C and D do not contain a rock.

A, B, C and D are all different.

A < B

A < C

B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

Print Yes if the objective is achievable, and No if it is not.

Sample Input 1

7 1 3 6 7
.#..#..

Sample Output 1

Yes

The objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)

A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB

Sample Input 2

7 1 3 7 6
.#..#..

Sample Output 2

No

Sample Input 3

15 1 3 15 13
...#.#...#.#...

Sample Output 3

Yes



Sample input:
7 1 3 6 7
.#..#..


Sample output:
Yes

Submission status: Wrong Answer

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

# AからDの間に岩が二つ連続で置かれている箇所があれば不可
# C > D の場合、すぬけ君はふぬけ君を追い越す必要があることに注意
ans = (
    'Yes' if ('##' not in S[(A - 1):D]) and (
        C < D or
        '...' in S[(A - 1):D]
    ) else
    'No'
)

# 出力
print(ans)

Submission status: Wrong Answer

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

# AからDの間に岩が二つ連続で置かれている箇所があれば不可
# C > D の場合、すぬけ君はふぬけ君を追い越す必要があることに注意
ans = (
    'Yes' if ('##' not in S[A:(D + 1)]) and (
        C < D or
        '...' in S[(A + 1):D]
    ) else
    'No'
)

# 出力
print(ans)

Submission status: Wrong Answer

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

# AからDの間に岩が二つ連続で置かれている箇所があれば不可
# C > D の場合、すぬけ君はふぬけ君を追い越す必要があることに注意
ans = (
    'Yes' if ('##' not in S[A:(D + 1)]) and (
        C < D or
        '...' in S[(A + 1):(D - 1)]
    ) else
    'No'
)

# 出力
print(ans)

Submission status: Wrong Answer

Solution code:
s=str(input())
a=0
b=0
c=0
s=s.replace('BC','0')
if(s.find('A0')==-1):
    print('{0}'.format(b))
    a=1
while (a==0):
    s=s.replace('A0','0A',1)
    b+=1
    if(s.find('A0')==-1):
        print('{0}'.format(b))
        a=1

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=s.replace('.','0')
s=s.replace('#','1')
x=0
y=0
f=0
g=0
for i in range(c-a-2):
    x=int(s[i+a])
    y=int(s[i+a+1])
    if(x*y==1):
        f=-1
for j in range(d-b-2):
    x=int(s[j+b])
    y=int(s[j+b+1])
    if(x*y==1):
        g=-1
if(d<c):
    if(s[b-1:d+1].find('000')==-1):
        f=-1
if(f==0 and g==0):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=s.replace('.','0')
s=s.replace('#','1')
x=0
y=0
f=0
g=0
for i in range(c-a-2):
    x=int(s[i+a+1])
    y=int(s[i+a+2])
    if(x*y==1):
        f=-1
for j in range(d-b-2):
    x=int(s[j+b+1])
    y=int(s[j+b+2])
    if(x*y==1):
        g=-1
if(d<c):
    if(s[b-1:d+1].find('000')==-1):
        f=-1
if(f==0 and g==0):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=s.replace('.','0')
s=s.replace('#','1')
x=0
y=0
f=0
g=0
for i in range(c-a-2):
    x=int(s[i+a+1])
    y=int(s[i+a+2])
    if(x*y==1):
        f=-1
for j in range(d-b-2):
    x=int(s[j+b+1])
    y=int(s[j+b+2])
    if(x*y==1):
        g=-1
if(d<c):
    if(s[b-1:d].find('000')==-1):
        f=-1
if(f==0 and g==0):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
s=s.replace('.','0')
s=s.replace('#','1')
x=0
y=0
f=0
g=0
for i in range(c-a-2):
    x=int(s[i+a+1])
    y=int(s[i+a+2])
    if(x*y==1):
        f=-1
for j in range(d-b-2):
    x=int(s[j+b+1])
    y=int(s[j+b+2])
    if(x*y==1):
        g=-1
if(d<c):
    if(s[b+1:d].find('000')==-1):
        f=-1
if(f==0 and g==0):
    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:
    for i in range(A-1,D-1):
        if S[i] == '#' and S[i+1] =='#':
            print('No')
            exit()
    print('Yes')

if C > D:
    for i in range(A-1,C-1):
        if S[i] == '#' and S[i+1] =='#':
            print('No')
            exit()
    for i in range(B-2,D-2):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            print('Yes')
            exit()
    print('No')

Submission status: Wrong Answer

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

if C < D:
    for i in range(A-1,D-2):
        if S[i] == '#' and S[i+1] =='#':
            print('No')
            exit()
    print('Yes')

if C > D:
    for i in range(A-1,C-2):
        if S[i] == '#' and S[i+1] =='#':
            print('No')
            exit()
    for i in range(B-2,D-2):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            print('Yes')
            exit()
    print('No')

Submission status: Wrong Answer

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

if C < D:
    for i in range(A-1,D-2):
        if S[i] == '#' and S[i+1] =='#':
            print('No')
            exit()
    print('Yes')

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

Submission status: Wrong Answer

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

if C < D:
    for i in range(A-1,D-2):
        if S[i] == '#' and S[i+1] =='#':
            print('No')
            exit()
    print('Yes')

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

Submission status: Wrong Answer

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

if C < D:
    for i in range(A-1,D-2):
        if S[i] == '#' and S[i+1] =='#':
            print('No')
            exit()
    print('Yes')

if C > D:
    for i in range(B-1,D-3):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            print('Yes')
            exit()
    print('No')

Submission status: Wrong Answer

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

if C < D:
    for i in range(A-1,D-2):
        if S[i] == '#' and S[i+1] =='#':
            print('No')
            exit()
    print('Yes')

if C > D:
    for i in range(B-1,D-3):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            print('yes')
            exit()
    print('No')

Submission status: Wrong Answer

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

if C < D:
    for i in range(N-1):
        if S[i] == '#' and S[i+1] =='#':
            print('No')
            exit()
    print('Yes')

if C > D:
    for i in range(B,D-2):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            print('yes')
            exit()
    print('No')

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")
elif c<d:
  print("Yes")
elif "..." in s[b-2:d] :#以下 d<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[a-1:c-a] or "##" in s[b-1:d-b] :
  print("No")
elif c<d:
  print("Yes")
elif "..." in s[b-2:d+3] :#以下 d<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[a-1:c-a] or "##" in s[b-1:d-b] :
  print("No")
elif c<d:
  print("Yes")
elif "..." in s[b-2:d-b+3] :#以下 d<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[a-1:c-a] or "##" in s[b-1:d-b] :
  print("No")
elif c<d:
  print("Yes")
elif "..." in s[b-2:c-b+3] :#以下 d<c の場合
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
 
index1 = s[a:c-a-1].find("##")
index2 = s[b:d-b-1].find("##")
 
if index1 != -1 or index2 != -1:
	print("No")
elif c < d :
	print("Yes")
elif s[b-2:d-b+3].find("...") != -1 : 
	print("Yes")
else :
	print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
 
index1 = s[a:c-a-1].find("##")
index2 = s[b:d-b-1].find("##")
 
if index1 != -1 or index2 != -1:
	print("No")
elif c < d :
	print("Yes")
elif s[int(max([b-2, 0])):d-b+2].find("...") != -1 : #s[d+1]またはs[d-1]が"#"のとき、つまり途中でsnukeがhnukeをこす
	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:C+1]) or ("##" in S[B:B+1]):
    print("No")
else:
    if C < D:
        print("Yes")
    else:
        if "..." in S[B-2:D+1]:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
if ("##" in S[A:C+1]) or ("##" in S[B:B+1]):
    print("No")
else:
    if C < D:
        print("Yes")
    else:
        if "..." in S[B-1:D+1]:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

Solution code:
import re

N, A, B, C, D = map(int, input().split())
S = input()
answer = "No"
if re.match("##", S[B-1:D+1]) == None:
    if C < D:
        answer = "Yes"
    else:   
        s = S[B-1:D+1]
        if re.match("...", s):
            answer = "Yes"
    
print(answer)

Submission status: Wrong Answer

Solution code:
import re

N, A, B, C, D = map(int, input().split())
S = input()
answer = "No"
if re.match("##", S) == None:
    if C < D:
        answer = "Yes"
    else:   
        s = S[B-1:D+1]
        if re.match("...", s):
            answer = "Yes"
    
print(answer)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = input().split()
N = int(N)
A = int(A)
B = int(B)
C = int(C)
D = int(D)
S = input()
a=max(C,D)
S = S[A-1:a+1:1]
L = list(S)
if ( "##" in S[A:C+1:1] or S[B:D+1:1]):
  print("NO")
elif(C==D):
  print("NO")
elif(D<C):
  L[B-1] == 'b'
  while(L[D-1] != 'b'):
    if(L[B-2] == '.' and L[B] == '.'):
      print("YES")
    else:
      if((L[B-2] == '.' or L[B-2] == '#') and L[B] == '#'):
        L[B+1] = 'b'
        L[B-1] = '.'
        B=B+2
      elif(L[B-2] == '#' and L[B] == '.'):
        L[B]='b'
        L[B-1] = '.'
        B=B+1
  if(L[D-2] == '#'):
    print('NO')

Submission status: Wrong Answer

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

flag = True

#search '##'
if "##" in S[A:C+1] or "##" in S[B:D+1]:
    flag = False

#search '...'
if C > D and flag:
    flag = False
    if "..." in S[B-1:D+2]:
        flag = True

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

Submission status: Wrong Answer

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

flag = True

#search '##'
if "##" in S[A:C+1] or "##" in S[B:D+1]:
    flag = False

#search '...'
if C > D:
    flag = False
    if "..." in S[B-1:D+2]:
        flag = True

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

Submission status: Wrong Answer

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

flag = True

#search '##'
for n in range(min(C,D)-1):
    if S[n:n+2] == '##':
        flag = False

#search '...'
if C > D:
    flag = False
    for n in range(B-1,min(C,D)-2):
        if S[n:n+3] == '...':
            flag = True

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

Submission status: Wrong Answer

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

flag = True

#search '##'
for n in range(max(C,D)-1):
    if S[n:n+2] == '##':
        flag = False

#search '...'
if C > D:
    flag = False
    for n in range(B-1,max(C,D)-2):
        if S[n:n+3] == '...':
            flag = True

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

Submission status: Wrong Answer

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

flag = True

#search '##'
for n in range(max(C,D)-1):
    if S[n:n+2] == '##':
        flag = False

#search '...'
if C > D:
    flag = False
    for n in range(B,max(C,D)-2):
        if S[n:n+3] == '...':
            flag = True

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

Submission status: Wrong Answer

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

flag = True

#search '##'
for n in range(N-1):
    if S[n:n+2] == '##':
        flag = False

#search '...'
if C > D:
    flag = False
    for n in range(B,max(C,D)-3):
        if S[n:n+3] == '...':
            flag = True

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

Submission status: Wrong Answer

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

flag = True

#search '##'
for n in range(N-1):
    if S[n:n+2] == '##':
        flag = False

#search '...'
if C > D:
    flag = False
    for n in range(B,min(C,D)-3):
        if S[n:n+3] == '...':
            flag = True

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

Submission status: Wrong Answer

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

index1 = s[a:c].find("##")
index2 = s[b:d].find("##")

if index1 != -1 or index2 != -1:
	print("No")
elif c < d :
	print("Yes")
elif s[d-1] != "#" and s[d-3] != "#" :
	print("Yes")
elif s[int(max([b-1, 0])):d+1].find("...") != -1 :	
    print("Yes")
else :
	print("No")

Submission status: Wrong Answer

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

index1 = s[a:c].find("##")
index2 = s[b:d].find("##")

ans = "No"

if index1 == -1 and index2 == -1:
  if c < d :
    ans = "Yes"
  elif s[b:d].find("...") != -1 :
    ans = "Yes"
  
print(ans)

Submission status: Wrong Answer

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

index1 = s[a:c].find("##")
index2 = s[b:d].find("##")

ans = "No"

if index1 == -1 and index2 == -1:
  if c < d :
    ans = "Yes"
  elif s[a:d].find("...") != -1 :
    ans = "Yes"
  
print(ans)

Submission status: Wrong Answer

Solution code:
import re

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

if re.match("##", S):
    print("No")
    exit()

if C < D:
    print("Yes")
else:
    S = list(S)
    S = S[B:D]
    i = 0
    for i in range(len(S)-2):
        if S[i] == '.':
            if S[i] == S[i+1] == S[i+2]:
                print("Yes")
                break
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin

N = 10
A = 3
B = 5
C = 10
D = 8
S = ".#.#.#...."

N, A, B, C, D = (int(i) for i in input().rstrip().split())
S = stdin.readline().rstrip()

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

swap_flag = False
swap_able = -1

for itr in range(len(S)):
    if itr < (len(S) - 1) and S[itr] == '#' and S[itr+1] == '#':
        print('No')
        exit()
    if swap_flag == False and (max(A, B) < itr and itr < min(C, D)) and (2 <= itr and itr <= (len(S)-1)) and S[itr] == '.' and S[itr-1] == '.' and S[itr+1] == '.':
        swap_able = itr
        swap_flag = True 

# print(swap_able)
# print(A, B, C, D)

if swap_able != -1:
    if A > B and C < D and S[C-1] == '#' and C < swap_able:
        print('No')
    elif A > B and C < D and C != N and S[C+1] == '#' and C < swap_able:
        print('No')
    elif A < B and D < C and S[D-1] == '#' and D < swap_able:
        print('No')
    elif A < B and D < C and D != N and S[D+1] == '#' and D < swap_able:
        print('No')
    else:
        print('Yes')
else:
    if A > B and C < D and S[C-1] == '#':
        print('No')
    elif A > B and C < D and C != N and S[C+1] == '#':
        print('No')
    elif A < B and D < C and S[D-1] == '#':
        print('No')
    elif A < B and D < C and D != N and S[D+1] == '#':
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
def hantei(n, a, b, c, d, s):
    if s[a - 1:c].find("##") > 0:
        return "No"
    if s[b - 1:d].find("##") > 0:
        return "No"
    if c > d:
        if s[b - 1:d].find("...") == -1:
            return "No"
    return "Yes"

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

Submission status: Wrong Answer

Solution code:


def check_two_stones(S, A, B, C, D):
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            return False
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            return False

    return True

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

S = S_org + "#"
if (B < C and C < D) or (C < B and B < D):
    if check_two_stones(S, A, B, C, D) is False:
        print("No")
        exit()
else:
    check = True
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            check = False

    #  ゴールと手前が"##"
    #if check is True and S[D-2] is "#":
         # 途中に"..."があれば回避できる

    S = S_org + "#."
    for j in range(B-1, D-1):
        if S[j] is "." and S[j+1] is "." and S[j+2] is ".":
            check = True
            break
        else:
            check = False

    if check is False:
        print("No")
        exit()

    S = S_org + "#"
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            print("No")
            exit()

print("Yes")

Submission status: Wrong Answer

Solution code:

def check_two_stones(S, A, B, C, D):
    for i in range(B, D+1):
        if S[i] is "#" and S[i+1] is "#":
            return False
    for i in range(A, C+1):
        if S[i] is "#" and S[i + 1] is "#":
            return False

    return True

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

S = S_org + "."
if (B < C and C < D) or (C < B and B < D):
    if check_two_stones(S, A, B, C, D) is False:
        print("No")
        exit()
else:
    check = True
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            check = False

    #  ゴールと手前が"##"
    #if check is True and S[D-2] is "#":
         # 途中に"..."があれば回避できる

    S = S_org + "#."
    for j in range(B-1, D-1):
        if S[j] is "." and S[j+1] is "." and S[j+2] is ".":
            check = True
            break
        else:
            check = False

    if check is False:
        print("No")
        exit()

    S = S_org + "."
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            print("No")
            exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
def check_two_stones(S, A, B, C, D):
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            return False
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            return False

    return True

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

S = S_org + "."
if (B < C and C < D) or (C < B and B < D):
    if check_two_stones(S, A, B, C, D) is False:
        print("No")
        exit()
else:
    check = True
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            check = False

    #  ゴールと手前が"##"
    #if check is True and S[D-2] is "#":
         # 途中に"..."があれば回避できる

    S = S_org + "#."
    for j in range(B-1, D-1):
        if S[j] is "." and S[j+1] is "." and S[j+2] is ".":
            check = True
            break
        else:
            check = False

    if check is False:
        print("No")
        exit()

    S = S_org + "."
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            print("No")
            exit()

print("Yes")

Submission status: Wrong Answer

Solution code:

def check_two_stones(S, A, B, C, D):
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            return False
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            return False

    return True

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

S = S_org + "."
if (B < C and C < D) or (C < B and B < D):
    if check_two_stones(S, A, B, C, D) is False:
        print("No")
        exit()
else:
    check = True
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            check = False

    #  ゴールと手前が"##"
    #if check is True and S[D-2] is "#":
         # 途中に"..."があれば回避できる

    S = S_org + "##"
    for j in range(B-1, D-1):
        if S[j] is "." and S[j+1] is "." and S[j+2] is ".":
            check = True
            break
        else:
            check = False

    if check is False:
        print("No")
        exit()

    S = S_org + "."
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            print("No")
            exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import re

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

if re.match("##", S):
    print("No")
    exit()

if C < D:
    print("Yes")
else:
    if re.match("\.\.\.", S):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:

def check_two_stones(S, A, B, C, D):
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            return False
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            return False

    return True

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

S = S_org + "."
if (B < C and C < D) or (C < B and B < D):
    if check_two_stones(S, A, B, C, D) is False:
        print("No")
        exit()
else:
    check = True
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            check = False

    #  ゴールと手前が"##"
    if check is True and S[D-2] is "#":
         # 途中に"..."があれば回避できる

        S = S_org + "##"
        for j in range(B, D-1):
            if S[j] is "." and S[j+1] is "." and S[j+2] is ".":
                check = True
                break
            else:
                check = False

    if check is False:
        print("No")
        exit()

    S = S_org + "."
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            print("No")
            exit()

print("Yes")

Submission status: Wrong Answer

Solution code:


def check_two_stones(S, A, B, C, D):
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            return False
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            return False

    return True

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

S = S_org + "."
if (B < C and C < D) or (C < B and B < D):
    if check_two_stones(S, A, B, C, D) is False:
        print("No")
        exit()
else:
    check = True
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            check = False

    #  ゴールと手前が"##"
    if check is True and S[D-2] is "#":
         # 途中に"..."があれば回避できる

        S = S_org + "##"
        for j in range(B, D-2):
            if S[j] is "." and S[j+1] is "." and S[j+2] is ".":
                check = True
                break
            else:
                check = False

    if check is False:
        print("No")
        exit()

    S = S_org + "."
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            print("No")
            exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
s = input()
s = s.split('BC')
count = [0]
count_all = 0
Icount = 0

for i in range(0,len(s)-1):
    Icount = 0
    j = 1
    while(j<=len(s[i]) and s[i][-j]=='A'):
        Icount = Icount + 1
        j = j + 1
        
    if (s[i]=='' or s[i]=='A'*len(s[i])):
        Icount = Icount + count[-1]
   
    count.append(Icount)
  
        
count_all = sum(count)  
print(count_all)

Submission status: Wrong Answer

Solution code:

def check_two_stones(S, A, B, C, D):
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            return False
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            return False

    return True

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

S = S_org + "."
if (B < C and C < D) or (C < B and B < D):
    if check_two_stones(S, A, B, C, D) is False:
        print("No")
        exit()
else:
    check = True
    for i in range(B, D):
        if S[i] is "#" and S[i+1] is "#":
            check = False

    #  ゴールと手前が"##"
    if check is True and S[D-2] is "#":
         # 途中に"..."があれば回避できる

        S = S_org + "##"
        for j in range(B-1, D-2):
            if S[j] is "." and S[j+1] is "." and S[j+2] is ".":
                check = True
                break
            else:
                check = False

    if check is False:
        print("No")
        exit()

    S = S_org + "."
    for i in range(A, C):
        if S[i] is "#" and S[i + 1] is "#":
            print("No")
            exit()

print("Yes")

Submission status: Wrong Answer

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

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


if D < C:
    S = S_org + "##"
    check = False
    for j in range(B, D):
        if S[j] is "." and S[j + 1] is "." and S[j + 2] is ".":
            check = True
            break

    if check is False:
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np


def main():
    n, a, b, c, d = [int(x) for x in input().split()]
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    nv = np.insert(np.array([1 if char == '#' else 0 for char in input()]).cumsum(), 0, 0)
    for i in range(a, max(c, d)):
        if nv[i + 2] - nv[i] == 2:
            print("No")
            sys.exit()
    if c < d:
        print("Yes")
        sys.exit()
    for i in range(b, d):
        if nv[i + 2] - nv[i - 1] == 0:
            print("Yes")
            sys.exit()
    print("No")


main()

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np


def main():
    n, a, b, c, d = [int(x) for x in input().split()]
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    nv = np.array([1 if char == '#' else 0 for char in input()]).cumsum()
    for i in range(a, max(c, d)):
        if nv[i + 1] - nv[i - 1] == 2:
            print("No")
            sys.exit()
    if c < d:
        print("Yes")
        sys.exit()
    for i in range(b, d):
        if nv[i + 1] - nv[i - 2] == 0:
            print("Yes")
            sys.exit()
    print("No")


main()

Submission status: Wrong Answer

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

e = 'Yes'
f = 0
g = 1

if c < d:
    for i in range(b-1,d-1):
        if s[i]=='#' and s[i+1]=='#':
            e ='No'
    if e =='Yes':
        for j in range(a-1,b-1):
            if s[j]=='#' and s[j+1]=='#':
                e ='No'
                        
if c > d:
    for i in range(a-1,c-1):
        if s[i]=='#' and s[i+1]=='#':
            f = 1
    
    for j in range(b-1,d-1):
        if s[j]=='.' and s[j+1]=='.' and s[j+2]=='.':
            g = 0

    if g == 0 and f ==0:
        e ='Yes'
    else:
        e ='No'
            
print(e)

Submission status: Wrong Answer

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

e = 'Yes'
f = 0
g = 1

if c < d:
    for i in range(b-1,d-1):
        if s[i]=='#' and s[i+1]=='#':
            e ='No'
    if e =='Yes':
        for j in range(a-1,b-1):
            if s[j]=='#' and s[j+1]=='#':
                e ='No'
                        
if c > d:
    for i in range(a-1,c-1):
        if s[i]=='#' and s[i+1]=='#':
            f = 1
    
    for j in range(b-1,d-2):
        if s[j]=='.' and s[j+1]=='.' and s[j+2]=='.':
            g = 0

    if g == 0 and f ==0:
        e ='Yes'
    else:
        e ='No'
            
print(e)

Submission status: Wrong Answer

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

e = 'Yes'
f = 0
g = 1

if c < d:
    for i in range(a-1,c-1):
        if s[i]=='#' and s[i+1]=='#':
            e ='No'
    if e =='Yes':
        for j in range(c-1,d-1):
            if s[j]=='#' and s[j+1]=='#':
                e ='No'
                        
if c > d:
    for i in range(a-1,c-1):
        if s[i]=='#' and s[i+1]=='#':
            f = 1
    
    for j in range(b-1,d-2):
        if s[j]=='.' and s[j+1]=='.' and s[j+2]=='.':
            g = 0

    if g == 0 and f ==0:
        e ='Yes'
    else:
        e ='No'
            
print(e)

Submission status: Wrong Answer

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

e = 'Yes'
f = 0
g = 1

if c < d:
    for i in range(a-1,c-1):
        if s[i]=='#' and s[i+1]=='#':
            e ='No'
        else:
            for j in range(c-1,d-1):
                if s[j]=='#' and s[j+1]=='#':
                    e ='No'
                        
if c > d:
    for i in range(a-1,c-1):
        if s[i]=='#' and s[i+1]=='#':
            f = 1
    
    for j in range(b-1,d-2):
        if s[j]=='.' and s[j+1]=='.' and s[j+2]=='.':
            g = 0

    if g == 0 and f ==0:
        e ='Yes'
    else:
        e ='No'
            
print(e)

Submission status: Wrong Answer

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

e = 'Yes'
f = 0
g = 1

if c < d:
    for i in range(a-1,c-1):
        if s[i]=='#' and s[i+1]=='#':
            e ='No'
        else:
            for j in range(b-1,a-1):
                if s[j]=='#' and s[j+1]=='#':
                    e ='No'
                        
if c > d:
    for i in range(a-1,c-1):
        if s[i]=='#' and s[i+1]=='#':
            f = 1
    
    for j in range(b-1,d-2):
        if s[j]=='.' and s[j+1]=='.' and s[j+2]=='.':
            g = 0

    if g == 0 and f ==0:
        e ='Yes'
    else:
        e ='No'
            
print(e)

Submission status: Wrong Answer

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

e = 'Yes'
f = 0
g = []

if c < d:
    for i in range(a-1,c-1):
        if s[i]=='#' and s[i+1]=='#':
            e ='No'
        else:
            for j in range(b-1,d-1):
                if s[j]=='#' and s[j+1]=='#':
                    e ='No'
                        
if c > d:
    for i in range(a-1,c-1):
        if s[i]=='#' and s[i+1]=='#':
            f = 1
    
    for j in range(a-1,c-2):
        if s[j]=='.' and s[j+1]=='.' and s[j+2]=='.':
            g.append(0)
        else:
            g.append(1)

    if min(g) == 0 and f ==0:
        e ='Yes'
    else:
        e ='No'
            
print(e)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = [int(x) for x in input().split()]
s = input()
for i in range(a, max(c, d)):
    if s[i - 1: i + 1] == "##":
        print("No")
        sys.exit()
if c < d:
    print("Yes")
    sys.exit()
for i in range(b, d - 1):
    if s[i - 1:i + 2] == "...":
        print("Yes")
        sys.exit()
print("No")