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:
#coding:utf-8
def main():
    N,A,B,C,D = list(map(int,input().split()))
    S = input()
    A -=1
    B -=1
    C -=1
    D -=1
    #C>Dのとき:AがBを追い越す
    prev = -1
    if C < D:  #AがBを追い越さない場合
        
        for i in range(A+1,min(C+1,B)):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i
        for i in range(B,D):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i

        
        print('Yes')
    
    if C > D:  #AがBを追い越す時
        prev = A-1
        for i in range(A+1,B):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i
        f = False  #追い越せるか
        prev = B-1
        prevS = B-1

        for i in range(B+1,D):
            if S[i] == '#' :
                if i - prev == 1:
                    print('No')
                    return
                prev = i
            else:
                if i - prevS == 1:
                    f = True
                prevS = i
                
        if not f:
            print('No')
            return
        
        for i in range(C,D):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i
        print('Yes')
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#coding:utf-8
def main():
    N,A,B,C,D = list(map(int,input().split()))
    S = input()
    A -=1
    B -=1
    C -=1
    D -=1
    #C>Dのとき:AがBを追い越す
    prev = -1
    if C < D:  #AがBを追い越さない場合
        
        for i in range(A+1,min(C+1,B)):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i
        for i in range(B,D):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i

        
        print('Yes')
    if C > D:  #AがBを追い越す時
        for i in range(A+1,B):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i
        f = False  #追い越せるか
        prev = B-1
        for i in range(B+1,D):
            if S[i] == '#' :
                d = i - prev
                if d == 1:
                    print('No')
                    return
                elif d >= 3 and i >= B + 3:
                    f = True
                prev = i
        if not f:
            print('No')
            return
        
        for i in range(C,D):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i
        print('Yes')
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#coding:utf-8
def main():
    N,A,B,C,D = list(map(int,input().split()))
    S = input()
    A -=1
    B -=1
    C -=1
    D -=1
    #C>Dのとき:AがBを追い越す
    prev = -1
    if C < D:  #AがBを追い越さない場合
        
        for i in range(A+1,min(C+1,B)):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i
        for i in range(B,D):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i

        
        print('Yes')
    if C > D:  #AがBを追い越す時
        for i in range(A+1,B):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i
        f = False  #追い越せるか
        prev = B-1
        for i in range(B+1,D):
            if S[i] == '#' :
                d = i - prev
                if d == 1:
                    print('Noo')
                    return
                elif d >= 3 and i >= B + 3:
                    f = True
                prev = i
        if not f:
            print('No')
            return
        
        for i in range(C,D):
            if S[i] == '#' :
                if prev == i-1:
                    print('No')
                    return
                else:
                    prev = i
        print('Yes')
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
X = list(S[i] for i in range(len(S)))
for i in range(len(S)):
  if X[i] == '#':
    X[i] = int(1)
  elif X[i] == '.':
    X[i] = int(0)
Y = 1
Z = 1
if C < D:
  for j in range(A+1,D-1):
    if X[j] + X[j+1] == 0:
      Y = Y * 0
  if Y == 0:
    print('Yes')
  else:
    print('No')
elif D < C:
  for j in range(B,D-2):
    if X[j] + X[j+1] + X[j+2] == 0:
      Z = Z * 0
  if Z == 0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
X = list(S[i] for i in range(len(S)))
for i in range(len(S)):
  if X[i] == '#':
    X[i] = int(1)
  elif X[i] == '.':
    X[i] = int(0)
Y = 1
Z = 1
if C < D:
  for j in range(A-1,D-2):
    if X[j] + X[j+1] == 0:
      Y = Y * 0
  if Y == 0:
    print('Yes')
  else:
    print('No')
elif D < C:
  for j in range(B-1,D-3):
    if X[j] + X[j+1] + X[j+2] == 0:
      Z = Z * 0
  if Z == 0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
X = list(S[i] for i in range(len(S)))
for i in range(len(S)):
  if X[i] == '#':
    X[i] = int(1)
  elif X[i] == '.':
    X[i] = int(0)
Y = 1
Z = 1
if C < D:
  for j in range(A-1,D-1):
    if X[j] + X[j+1] == 0:
      Y = Y * 0
  if Y == 0:
    print('Yes')
  else:
    print('No')
elif D < C:
  for j in range(B-1,D-2):
    if X[j] + X[j+1] + X[j+2] == 0:
      Z = Z * 0
  if Z == 0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
X = list(S[i] for i in range(len(S)))
for i in range(len(S)):
  if X[i] == '#':
    X[i] = int(1)
  elif X[i] == '.':
    X[i] = int(0)
Y = 1
Z = 1
if C < D:
  for j in range(A,D-1):
    if X[j] + X[j+1] == 0:
      Y = Y * 0
  if Y == 0:
    print('Yes')
  else:
    print('No')
elif D < C:
  for j in range(B-1,D-2):
    if X[j] + X[j+1] + X[j+2] == 0:
      Z = Z * 0
  if Z == 0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
X = list(S[i] for i in range(len(S)))
for i in range(len(S)):
  if X[i] == '#':
    X[i] = int(1)
  elif X[i] == '.':
    X[i] = int(0)
Y = 0
Z = 0
if C < D:
  for j in range(A,D-2):
    if X[j] + X[j+1] + X[j+2] > 1:
      Y = Y + 1
  if Y == 0:
    print('Yes')
  else:
    print('No')
elif D < C:
  for j in range(B-2,D-3):
    if X[j] + X[j+1] + X[j+2] + X[j+3] > 1:
      Z = Z + 1
  if Z == 0:
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
import copy

def links_list(S):
  links = {}
  for i in range(len(S)-1):
    if i+1 < len(S):
      if S[i+1] == ".":
        links[i] = [i+1]
    if i+2 < len(S):
      if i in links:
        links[i].append(i+2)
      else:
        links[i] = [i+2]
  return links

def num_list(S):
  num_list = {}
  for i in range(len(S)):
    num_list[i] = False
  return num_list

def bfs(from_, to_, links, num_list):
  que = [from_]
  num_list[from_] = True
  while que != []:
    cur = que.pop(0)
    if cur == to_:
      return True
    for a in links[cur]:
      if num_list[a] == False:
        que.append(a)
        num_list[a] = True
  return False

def turn_False(num_list):
  for a in num_list:
    if num_list[a] == True:
      num_list[a] = False

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

links = links_list(S)
num_list = num_list(S)
B_can = bfs(B, D, links, num_list)
if B_can == False:
  print ("No")
  sys.exit()

S_mae = S[0: D]
S_at = S[D+1: len(S)]
S_sub = S_mae + "#" + S_at
links2 = links_list(S_sub)
turn_False(num_list)
A_can = bfs(A, C, links2, num_list)
if A_can == False:
  print ("No")
  sys.exit()
print ("Yes")

Submission status: Wrong Answer

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

if c > d:#追い抜きが必要な場合
    x = 0
    for i in range(b-1,d-1):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            x = 1
    if x == 0:
        print("No")#追い抜きが出来ない
    else:#追い抜き可能な場合
        check = 0#岩が2連続以上だと達成不能
        for i in range(a-1,c-1):
            if s[i] == "#" and s[i+1] == "#":
                check = 1
        if check == 1:
            print("No")
        else:
            print("Yes")
else:#a<b<c<dと並ぶ場合、もしくはacbdと並ぶ場合
    a_check = 0#Aがいけるか
    b_check = 0#Bがいけるか
    for i in range(a-1,c-1):
        if s[i] == "#" and s[i+1] == "#":
            a_check = 1
    for i in range(b-1,d-1):
        if s[i] == "#" and s[i+1] == "#":
            b_check = 1
    if a_check == 0 and b_check == 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:#追い抜きが必要な場合
    x = 0
    for i in range(b-1,d-2):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            x = 1
    if x == 0:
        print("No")#追い抜きが出来ない
    else:#追い抜き可能な場合
        check = 0#岩が2連続以上だと達成不能
        for i in range(a-1,c-1):
            if s[i] == "#" and s[i+1] == "#":
                check = 1
        if check == 1:
            print("No")
        else:
            print("Yes")
else:#a<b<c<dと並ぶ場合、もしくはacbdと並ぶ場合
    a_check = 0#Aがいけるか
    b_check = 0#Bがいけるか
    for i in range(a-1,c-1):
        if s[i] == "#" and s[i+1] == "#":
            a_check = 1
    for i in range(b-1,d-1):
        if s[i] == "#" and s[i+1] == "#":
            b_check = 1
    if a_check == 0 and b_check == 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:#追い抜きが必要な場合
    x = 0
    for i in range(b-1,d-2):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            x = 1
    if x == 0:
        print("No")#追い抜きが出来ない
    else:#追い抜き可能な場合
        check = 0#岩が2連続以上だと達成不能
        for i in range(1,c-1):
            if s[i] == "#" and s[i+1] == "#":
                check = 1
        if check == 1:
            print("No")
        else:
            print("Yes")
else:#a<b<c<dと並ぶ場合、もしくはacbdと並ぶ場合
    a_check = 0#Aがいけるか
    b_check = 0#Bがいけるか
    for i in range(a-1,c-1):
        if s[i] == "#" and s[i+1] == "#":
            a_check = 1
    for i in range(b-1,d-1):
        if s[i] == "#" and s[i+1] == "#":
            b_check = 1
    if a_check == 0 and b_check == 0:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split(" "))
n = input()
if "##" in n[a:max(c,d)]:
    print("No")
elif c < d:
    print("Yes")
else:
    if '...' in n[b:d]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split(" "))
n = input()
if "##" in n[a:max(c,d)]:
    print("No")
elif c < d:
    print("Yes")
else:
    if '...' in n[a:c]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
s = [0]
for i in range(N):
    if S[i] == '.':
        s.append(0)
    else:
        s.append(1)
if C < B and B < D: #ACBDの順番
    flag = 0
    for i in range(C - A):
        if s[A + i] == 1 and s[A + i + 1] == 1:
            flag = 1
            break
    if flag == 0:
        for i in range(D - B):
            if s[B + i] == 1 and s[B + i + 1] == 1:
                flag = 1
                break
    if flag == 1:
        print('No')
    else:
        print('Yes')
elif B < C and C < D: # ABCDの順番
    flag = 0
    for i in range(D - B):
        if s[B + i] == 1 and s[B + i + 1] == 1:
            flag = 1
            break
    if flag == 0:
        for i in range(D - A):
            if s[A + i] == 1 and s[A + i + 1] == 1:
                flag = 1
                break
    if flag == 1:
        print('No')
    else:
        print('Yes')
else: #ABDCの順番
    flag = 0
    for i in range(D - B):
        if s[B + i - 1] == 0 and s[B + i] == 0 and s[B + i + 1] == 0:
            flag = 1
            break
    if flag == 1:
        for i in range(C - A):
            if s[A + i] == 1 and s[A + i + 1] == 1:
                flag = 0
                break
    if flag == 1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
s = []
for i in range(N):
    if S[i] == '.':
        s.append(0)
    else:
        s.append(1)
if C < B and B < D: #ACBDの順番
    flag = 0
    for i in range(C - A):
        if s[A + i] == 1 and s[A + i + 1] == 1:
            flag = 1
            break
    if flag == 0:
        for i in range(D - B):
            if s[B + i] == 1 and s[B + i + 1] == 1:
                flag = 1
                break
    if flag == 1:
        print('No')
    else:
        print('Yes')
elif B < C and C < D: # ABCDの順番
    flag = 0
    for i in range(D - B):
        if s[B + i] == 1 and s[B + i + 1] == 1:
            flag = 1
            break
    if flag == 0:
        for i in range(D - A):
            if s[A + i] == 1 and s[A + i + 1] == 1:
                flag = 1
                break
    if flag == 1:
        print('No')
    else:
        print('Yes')
else: #ABDCの順番
    flag = 0
    for i in range(D - B):
        if s[B + i - 1] == 0 and s[B + i] == 0 and s[B + i + 1] == 0:
            flag = 1
            break
    if flag == 1:
        for i in range(C - A):
            if s[A + i] == 1 and s[A + i + 1] == 1:
                flag = 0
                break
    if flag == 1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
s = []
for i in range(N):
    if S[i] == '.':
        s.append(0)
    else:
        s.append(1)
if C < B and B < D: #ACBDの順番
    flag = 0
    for i in range(C-A):
        if s[A + i] == 1 and s[A + i + 1] == 1:
            flag = 1
            break
    if flag == 0:
        for i in range(D-B):
            if s[B + i] == 1 and s[B + i + 1] == 1:
                flag = 1
                break
    if flag == 1:
        print('No')
    else:
        print('Yes')
elif B < C and C < D: # ABCDの順番
    flag = 0
    for i in range(D-B):
        if s[B + i] == 1 and s[B + i + 1] == 1:
            flag = 1
            break
    if flag == 0:
        for i in range(B-A):
            if s[A + i] == 1 and s[A + i + 1] == 1:
                flag = 1
                break
    if flag == 1:
        print('No')
    else:
        print('Yes')
else: #ABDCの順番
    flag1 = 0
    flag2 = 0
    for i in range(D - B):
        if s[B + i - 1] == 0 and s[B + i] == 0 and s[B + i + 1] == 0:
            flag1 = 1
            break
    if flag1 == 1:
        for i in range(C - A):
            if s[A + i] == 1 and s[A + i + 1] == 1:
                flag2 = 1
                break
    if flag1 == 1 and flag2 == 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split()) # 横に2個
S = [0 if s == '.' else 1  for s in input()]

if C <= B:
    ans = 'Yes'
    for i in range(A, C):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
    for i in range(B, D):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break

elif C < D:
    ans = 'Yes'
    for i in range(A, D):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
else:
    ans = '?'
    for i in range(A, C):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
        if B - 1 <= i < D - 1 and S[i] == 0 and S[i-1] == 0 and S[i+1] == 0:
            ans = 'Yes'
            break
    if ans == '?':
        ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split()) # 横に2個
S = [0 if s == '.' else 1  for s in input()]

if C <= B:
    ans = 'Yes'
    for i in range(A, C):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
    for i in range(B, D):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break

elif C < D:
    ans = 'Yes'
    for i in range(A, D):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
else:
    ans = '?'
    for i in range(A, C):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
        if B < i < D - 1 and S[i] == 0 and S[i-1] == 0 and S[i+1] == 0:
            ans = 'Yes'
            break
    if ans == '?':
        ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split()) # 横に2個
S = [0 if s == '.' else 1  for s in input()]

if C <= B:
    ans = 'Yes'
    for i in range(A, C):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
    for i in range(B, D):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break

elif C < D:
    ans = 'Yes'
    for i in range(A, D):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
else:
    ans = '?'
    for i in range(A, C):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
        if i < C - 1 and S[i] == 0 and S[i-1] == 0 and S[i+1] == 0:
            ans = 'Yes'
            break
    if ans == '?':
        ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split()) # 横に2個
S = [0 if s == '.' else 1  for s in input()]

if C < B:
    ans = 'Yes'
    for i in range(A, C):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
    for i in range(B, D):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break

elif C < D:
    ans = 'Yes'
    for i in range(A, D):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
else:
    ans = '?'
    for i in range(A, C):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
        if i < C - 1 and S[i] == 0 and S[i-1] == 0 and S[i+1] == 0:
            ans = 'Yes'
            break
    if ans == '?':
        ans = 'No'

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split()) # 横に2個
S = [0 if s == '.' else 1  for s in input()]

if C < D:
    ans = 'Yes'
    for i in range(A, D):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
else:
    ans = '?'
    for i in range(A, C):
        if S[i] == 1 and S[i-1] == 1:
            ans = 'No'
            break
        if i < C - 1 and S[i] == 0 and S[i-1] == 0 and S[i+1] == 0:
            ans = 'Yes'
            break
    if ans == '?':
        ans = 'No'

print(ans)

Submission status: Wrong Answer

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

if "##" in S[A:C] or "##" in S[B:D]:
    ans = False
elif C > D:
    if "..." in S[B:D]:
        ans = True
    else:
        ans = False
        
print("Yes" if ans else "No")

Submission status: Wrong Answer

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

if "##" in S[A:C] or "##" in S[B:D]:
    ans = False
elif C > D:
    if "..." in S[A:C]:
        ans = True
    else:
        ans = False
        
print("Yes" if ans else "No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, input().split())
S = input()
s1 = list(S)
s1.append("0")
s1.append("0")
ans = True
for i in range(N):
    if s1[i] == "#" and s1[i+1] == "#":
        ans = False
        break
    elif C > D:
        if s1[i] == "." and s1[i+1] == "." and s1[i+2] == ".":
            ans = True
            break
        else:
            ans = False
            
print( "Yes" if ans else "No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
x='Yes'
if '##' in s[a-1:c]:
  x='No'
elif '##' in s[b-1:d]:
  x='No'
elif c>d:
  if '...' not in s[b-2:d]:
    x='No'  
print(x)

Submission status: Wrong Answer

Solution code:
def solve(n, a, b, c, d, s):
    for left, right in [(a, c), (b, d)]:
        for i in range(left, right):
            if s[i:i+2] == '##':
                return "No"
    if d < c:
        for i in range(b, d+1):
            if s[i-1:i+2] == "...":
                return "Yes"
        return "No"
    else:
        return "Yes"

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

Submission status: Wrong Answer

Solution code:
def solve(n, a, b, c, d, s):
    for left, right in [(a, c), (b, d)]:
        for i in range(left, right):
            if s[i:i+2] == '##':
                return "No"
    if d < c:
        for i in range(b, d):
            if s[i-1:i+2] == "...":
                return "Yes"
        return "No"
    else:
        return "Yes"

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

Submission status: Wrong Answer

Solution code:
def solve(n, a, b, c, d, s):
    if a > b:
        a, b = b, c
        c, d = d, c
    for left, right in [(a, c), (b, d)]:
        for i in range(left, right):
            if s[i:i+2] == '##':
                return "No"
    if d < c:
        for i in range(b+1, d):
            if s[i-1:i+2] == "...":
                return "Yes"
        return "No"
    else:
        return "Yes"

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

Submission status: Wrong Answer

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

count_dot = 0
count_sharp = 0
max_dot = 0

if(c>d):
  for i in range(a-1,d):
    if li[i]=='.':
      count_sharp = 0
      if b-2 <= i and i <= d:
        count_dot += 1
    else:
      max_dot = max(max_dot, count_dot)
      count_dot = 0
      count_sharp += 1
      if count_sharp>1:
        break
  max_dot = max(max_dot, count_dot)

  if(count_sharp<=1 and max_dot>2):
    print('Yes')
  else:
    print('No')
  # print(count_sharp,max_dot)
else:
  for i in range(a-1,d):
    if li[i]=='#':
      if not c<b:
        count_sharp += 1
        if count_sharp>1:
          break
    else:
      count_sharp = 0
  if(count_sharp<=1):
    print('Yes')
  else:
    print('No')
  # print(count_sharp)

Submission status: Wrong Answer

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

count_dot = 0
count_sharp = 0
max_dot = 0

if(c>d):
  for i in range(a-1,d):
    if li[i]=='.':
      count_sharp = 0
      if b-2 <= i and i <= d:
        count_dot += 1
    else:
      max_dot = max(max_dot, count_dot)
      count_dot = 0
      count_sharp += 1
      if count_sharp>1:
        break
  max_dot = max(max_dot, count_dot)

  if(count_sharp<=1 and max_dot>2):
    print('Yes')
  else:
    print('No')
  print(count_sharp,max_dot)
else:
  for i in range(a-1,d):
    if li[i]=='#':
      if not c<b:
        count_sharp += 1
        if count_sharp>1:
          break
    else:
      count_sharp = 0
  if(count_sharp<=1):
    print('Yes')
  else:
    print('No')
  print(count_sharp)

Submission status: Wrong Answer

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

count_dot = 0
count_sharp = 0
max_dot = 0

if(c>d):
  for i in range(a-1,d):
    if li[i]=='.':
      count_sharp = 0
      if b-2 <= i and i <= d:
        count_dot += 1
    else:
      max_dot = max(max_dot, count_dot)
      count_dot = 0
      count_sharp += 1
      if count_sharp>1:
        break
  max_dot = max(max_dot, count_dot)

  if(count_sharp<=1 and max_dot>2):
    print('Yes')
  else:
    print('No')
else:
  for i in range(a-1,d):
    if li[i]=='#':
      count_sharp += 1
      if count_sharp>1:
        break
    else:
      count_sharp = 0
  if(count_sharp<=1):
    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:
    flag = True
    for i in range(a-1,d):
        if s[i] == '#' and s[i+1] == '#':
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')
else:
    flag = False
    for i in range(b,d):
        if i+1 < len(s):
            if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
                flag = True
                break
    if flag:
        for i in range(a-1,c):
            if s[i] == '#' and s[i+1] == '#':
                flag = False
                break
    if flag:
        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:
    flag = True
    for i in range(a-1,d):
        if s[i] == '#' and s[i+1] == '#':
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')
else:
    flag = False
    for i in range(a-1,d):
        if i+1 < len(s):
            if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
                flag = True
                break
    if flag:
        for i in range(a-1,c):
            if s[i] == '#' and s[i+1] == '#':
                flag = False
                break
    if flag:
        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:
    flag = True
    for i in range(a-1,d):
        if s[i] == '#' and s[i+1] == '#':
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')
else:
    flag = False
    if s[d-2] == '#':
        for i in range(a-1,d-1):
            if i+1 < len(s) and i+2 < len(s):
                if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
                    flag = True
                    break
    else:
        for i in range(a-1,d):
            if i+1 < len(s) and i+2 < len(s):
                if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
                    flag = True
                    break
    if flag:
        for i in range(a-1,c):
            if s[i] == '#' and s[i+1] == '#':
                flag = False
                break
    if flag:
        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:
    flag = True
    for i in range(a-1,d):
        if s[i] == '#' and s[i+1] == '#':
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')
else:
    flag = False
    for i in range(a-1,d-1):
        if i+1 < len(s) and i+2 < len(s):
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
                flag = True
                break
    if flag:
        for i in range(a-1,c):
            if s[i] == '#' and s[i+1] == '#':
                flag = False
                break
    if flag:
        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:
    flag = True
    for i in range(a-1,d):
        if s[i] == '#' and s[i+1] == '#':
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')
else:
    flag = False
    for i in range(a-1,d):
        if i+1 < len(s) and i+2 < len(s):
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
                flag = True
                break
    if flag:
        for i in range(a-1,c):
            if s[i] == '#' and s[i+1] == '#':
                flag = False
                break
    if flag:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

#入力
N,A,B,C,D = map(int,input().split())
S = input()
#print("Nは"+str(N))
#print("Aは"+str(A))
#print("Bは"+str(B))
#print("Cは"+str(C))
#print("Dは"+str(D))
#print("Sは"+S)

#☑関数の定義 (##)を見つける
isgood = True
def check(start, end):
    route = S[start:end-1]
    #[##]が含まれていればNo
    if "##" in route:
        global isgood
        isgood = False


#☑関数の定義 (...)を見つける
isgood_pts = False
def check_pts(start, end):
    route = S[start:end-1]
    #[...]が含まれていればNo
    if "..." in route:
        global isgood_pts
        isgood_pts = True

#分岐処理
goto22 = False

#1. C<Dのとき、Bから動かしてB→D☑、A→C☑
if C < D:
    #print("Pattern1: D>C")
    check(B, D)
    check(A, C)

#2. D<Cのとき、
else:
    #print("Pattern2: C>D")
    #2-1.Dの左右に#がなければ、B→D☑、A→C☑
    if (S[D-2] == "#") or (S[D] == "#"):
        #print("Dの両隣どちらかに#がある")
        goto22 = True
    else:
        #print("Dの両隣どちらにも#がない")
        check(B, D)
        check(A, C)

    #2-2.あれば、B-1～C+1内に連続した...があるか確認
    if goto22:
        check_pts(B-1, C+1)
        #2-2-1.あれば、B→D☑のあと（Bを取り除いて)A→C☑
        if isgood_pts:
            #print("2-2-1処理")
            check(B, D)
            check(A, C)
        #2-2-2.なければNo
        else:
            isgood = False
            #print("2-2-2: No")

if isgood == True:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
ans =True
if a>b and c<d:
  for i in range(len(s)-1):
    if s[i]=='#':
      if s[i+1]=='#':
        ans=False
if a<b and c>d:
  for i in range(len(s)-1):
    if s[i]=='#':
      if s[i+1]=='#':
        ans=False
if ans==True:
  print('Yes')
else:
  print('No')