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()

T = ""
for i in range(n):
    if i == a - 1:
        T += "A"
    elif i == b - 1:
        T += "B"
    else:
        T += S[i]
# print(T)

cnt = 0
rok = 0
if c < d:
    for i in range(a, d):
        if T[i] == "#":
            rok += 1

        else:
            rok = 0

        if rok >= 2:
            print("No")
            exit()
    print("Yes")

else:
    for i in range(a, c):
        if T[i] == "#":
            cnt = 0
            rok += 1

        elif T[i] == ".":
            cnt += 1
        rok = 0

        if cnt >= 3:
            print("Yes")
            exit()

        if rok >= 2:
            print("No")
            exit()
    print("No")

Submission status: Wrong Answer

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

T = ""
for i in range(n):
    if i == a - 1:
        T += "A"
    elif i == b - 1:
        T += "B"
    else:
        T += S[i]
# print(T)

cnt = 0
rok = 0
if c < d:
    for i in range(a, d):
        if T[i]  == "#":
            rok += 1
        
        else:
            rok = 0

        if rok >= 2:
            print("No")
            exit()    
    print("Yes")
    
else:
    for i in range(a, c):
        if T[i] == "#":
            cnt = 0
            rok += 1

        else:
            cnt += 1
            rok = 0

        if cnt >= 3:
            print("Yes")
            exit()

        if rok >= 2:
            print("No")
            exit()            
    print("No")

Submission status: Wrong Answer

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

T = ""
for i in range(n):
    if i == a - 1:
        T += "A"
    elif i == b - 1:
        T += "B"
    else:
        T += S[i]
# print(T)

cnt = 0
rok = 0
for t in T:
    if t == "A" or t == "B":
        cnt = 0
        rok = 0
    elif t == "#":
        cnt = 0
        rok += 1
        
    else:
        cnt += 1
        rok = 0

    if cnt >= 3:
        print("Yes")
        exit()

    if rok >= 2:
        print("No")
        exit()
    #print(t, cnt, rok)

if c < d:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

T = ""
for i in range(n):
    if i == a - 1:
        T += "A"
    elif i == b - 1:
        T += "B"
    else:
        T += S[i]
# print(T)

cnt = 0
rok = 0
for t in T:
    if t == ".":
        cnt += 1
        rok = 0
    if t == "#":
        cnt = 0
        rok += 1
    else:
        cnt = 0
        rok = 0
    
    if cnt >= 3:
        print("Yes")
        exit()
    
    if rok >= 2:
        print("No")
        exit()

if c < d:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

T = ""
for i in range(n):
    if i == a-1:
        T += "A"
    elif i == b-1:
        T += "B"
    else:
        T += S[i]

cnt = 0
#print(T)
for t in T:
    if t == ".":
        cnt += 1
    else:
        cnt = 0
    
    if cnt >= 3:
      print("Yes")
      exit()

if c < d:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

T = ""
for i in range(n):
    if i == a-1:
        T += "A"
    elif i == b-1:
        T += "B"
    else:
        T += S[i]

cnt = 0
#print(T)
for t in T:
    if t == ".":
        cnt += 1
    else:
        cnt = 0

if cnt >= 3:
    print("Yes")
    exit()

if c < d:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

# c<dの場合
tooi = max(c, d)
for i in range(a, tooi - 1):
    # 二連続石は無理
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        exit()
# d<cなら飛び越え必要=b~d区間に3マス連続空きが必要
if d < c:
    for i in range(b, d):
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            print('Yes')
            exit()
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

# c<dの場合
tooi = max(c, d)
for i in range(a, tooi - 1):
    # 二連続石は無理
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        exit()
# d<cなら飛び越え必要=a~d区間に3マス連続空きが必要
if d < c:
    for i in range(a, d):
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            print('Yes')
            exit()
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

# c<dの場合
tooi = max(c, d)
for i in range(a, tooi - 1):
    # 二連続石は無理
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        exit()
# d<cなら飛び越え必要=a~d区間に3マス連続空きが必要
if d < c:
    for i in range(a + 1, d):
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            print('Yes')
            exit()
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,a,b,c,d = list(map(int, input().split()))
s = input()
if "##" in s[a:c+1]:
    ans = "No"
elif "##" in s[b:d+1]:
    ans = "No"
elif c>d and "..." not in s[b-1:d+2]:
    ans = "No"
else:
    ans = "Yes"
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,a,b,c,d = list(map(int, input().split()))
s = input()
if "##" in s[a:c+1]:
    ans = "NO"
elif "##" in s[b:d+1]:
    ans = "NO"
elif c>d and "..." not in s[b-1:d+2]:
    ans = "NO"
else:
    ans = "YES"
print(ans)

Submission status: Wrong Answer

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

flag = True
if C < D:
  for i in range(A, C-2):
    if (S[i]=='#') and (S[i+1]=='#'):
      flag = False
      break
else:
  for i in range(A, C-2):
    if (S[i]=='#') and (S[i+1]=='#'):
      flag = False
      break
  if flag:
    flag = False
    for i in range(B-1, D):
      if (S[i-1]=='.') and (S[i]=='.') and (S[i+1]=='.'):
        flag = True
        break
        
if flag:
  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
if C < D:
  for i in range(A, C-1):
    if (S[i]=='#') and (S[i+1]=='#'):
      flag = False
      break
else:
  for i in range(A, C-1):
    if (S[i]=='#') and (S[i+1]=='#'):
      flag = False
      break
  if flag:
    flag = False
    for i in range(B-1, D):
      if (S[i-1]=='.') and (S[i]=='.') and (S[i+1]=='.'):
        flag = True
        break
        
if flag:
  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
if C < D:
  for i in range(A, N-1):
    if (S[i]=='#') and (S[i+1]=='#'):
      flag = False
      break
else:
  for i in range(A, C-1):
    if (S[i]=='#') and (S[i+1]=='#'):
      flag = False
      break
  if flag:
    flag = False
    for i in range(B-1, D):
      if (S[i-1]=='.') and (S[i]=='.') and (S[i+1]=='.'):
        flag = True
        break
        
if flag:
  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
if C < D:
  for i in range(A, N-1):
    if (S[i]=='#') and (S[i+1]=='#'):
      flag = False
      break
else:
  for i in range(A, C-1):
    if (S[i]=='#') and (S[i+1]=='#'):
      flag = False
      break
  if flag:
    flag = False
    for i in range(B-2, min(C-2, D-1)):
      if (S[i]=='.') and (S[i+1]=='.') and (S[i+2]=='.'):
        flag = True
        break
        
if flag:
  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
if C < D:
  for i in range(A, N-1):
    if (S[i]=='#') and (S[i+1]=='#'):
      flag = False
      break
else:
  for i in range(A, C-1):
    if (S[i]=='#') and (S[i+1]=='#'):
      flag = False
      break
  if flag:
    flag = False
    for i in range(B-2, D-1):
      if (S[i]=='.') and (S[i+1]=='.') and (S[i+2]=='.'):
        flag = True
        break
        
if flag:
  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
if C < D:
  for i in range(A, N-1):
    if (S[i]=='#') and (S[i+1]=='#'):
      flag = False
      break
else:
  for i in range(A, N-1):
    if (S[i]=='#') and (S[i+1]=='#'):
      flag = False
      break
  if flag:
    flag = False
    for i in range(B-2, N-2):
      if (S[i]=='.') and (S[i+1]=='.') and (S[i+2]=='.'):
        flag = True
        break
        
if flag:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N, A, B, C, D = [int(item) for item in input().split()]
    S = input()


    if C < D:
        is_goal = True
        for i in range(A, D+1):
            if S[i-1:i+1] == '##':
                is_goal = False
                break
    else:
        is_goal = False
        for i in range(A, C+1):
            if S[i-1:i+1] == '##':
                is_goal = False

            if 1+B <= i <= D:
                if S[i-2:i+1] == '...' :
                    is_goal = True

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N, A, B, C, D = [int(item) for item in input().split()]
    S = input()


    if C < D:
        is_goal = True
        for i in range(A, D):
            if S[i-1:i+1] == '##':
                is_goal = False
                break
    else:
        is_goal = False
        for i in range(A, C):
            if S[i-1:i+1] == '##':
                is_goal = False

            if 1+B <= i <= D:
                if S[i-2:i+1] == '...' :
                    is_goal = True

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N, A, B, C, D = [int(item) for item in input().split()]
    S = input()


    if C < D:
        is_goal = True
        for i in range(A, D):
            if S[i-1:i+1] == '##':
                is_goal = False
                break
    else:
        is_goal = False
        for i in range(A, C):
            if S[i-1:i+1] == '##':
                is_goal = False

            if 2+B <= i < D:
                if S[i-2:i+1] == '...' :
                    is_goal = True

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N, A, B, C, D = [int(item) for item in input().split()]
    S = input()


    if C < D:
        is_goal = True
        for i in range(A, D):
            if S[i-1:i+1] == '##':
                is_goal = False
                break
    else:
        is_goal = False
        for i in range(A, C):
            if S[i-1:i+1] == '##':
                is_goal = False

            if 2+B <= i <= D:
                if S[i-2:i+1] == '...' :
                    is_goal = True

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N, A, B, C, D = [int(item) for item in input().split()]
    S = input()


    if C < D:
        is_goal = True
        for i in range(A, D):
            if S[i-1:i+1] == '##':
                is_goal = False
                break
    else:
        is_goal = False
        for i in range(A, C):
            if S[i-1:i+1] == '##':
                is_goal = False

            if 1+B <= i < D:
                if S[i-2:i+1] == '...' :
                    is_goal = True

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N, A, B, C, D = [int(item) for item in input().split()]
    S = input()


    if C < D:
        is_goal = True
        for i in range(1, N):
            if S[i-1:i+1] == '##':
                is_goal = False
                break
    else:
        is_goal = False
        for i in range(A, N):
            if S[i-1:i+1] == '##':
                is_goal = False

            if 1+B <= i < D:
                if S[i-2:i+1] == '...' :
                    is_goal = True

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N, A, B, C, D = [int(item) for item in input().split()]
    S = input()


    if C < D:
        is_goal = True
        for i in range(1, N):
            if S[i-1:i+1] == '##':
                is_goal = False
                break
    else:
        is_goal = False
        for i in range(A, N):
            if S[i-1:i+1] == '##':
                is_goal = False

            if 2+B <= i <= D:
                if S[i-2:i+1] == '...' :
                    is_goal = True

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N, A, B, C, D = [int(item) for item in input().split()]
    S = input()


    if C < D:
        is_goal = True
        for i in range(1, N):
            if S[i-1:i+1] == '##':
                is_goal = False
                break
    else:
        is_goal = False
        for i in range(A, N):
            if S[i-1:i+1] == '##':
                is_goal = False

            if i >= 2+B:
                if S[i-2:i+1] == '...' :
                    is_goal = True

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N, A, B, C, D = [int(item) for item in input().split()]
    S = input()


    if C < D:
        is_goal = True
        for i in range(1, N):
            if S[i-1:i+1] == '##':
                is_goal = False
                break
    else:
        is_goal = False
        for i in range(1, N):
            if S[i-1:i+1] == '##':
                is_goal = False
                break

            if i >= 2+B:
                if S[i-2:i+1] == '...' :
                    is_goal = True

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N, A, B, C, D = [int(item) for item in input().split()]
    S = input()


    if C < D:
        is_goal = True
        for i in range(1, N):
            if S[i-1:i+1] == '##':
                is_goal = False
                break
    else:
        is_goal = False
        for i in range(1, N):
            if S[i-1:i+1] == '##':
                is_goal = False
                break

            if i >= 1+B:
                if S[i-2:i+1] == '...' :
                    is_goal = True

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N, A, B, C, D = [int(item) for item in input().split()]
    S = input()


    if C < D:
        is_goal = True
        for i in range(1, N):
            if S[i-1:i+1] == '##':
                is_goal = False
                break
    else:
        is_goal = False
        for i in range(1, N):
            if S[i-1:i+1] == '##':
                is_goal = False
                break

            if i>=2:
                if S[i-2:i+1] == '...' :
                    is_goal = True

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N, A, B, C, D = [int(item) for item in input().split()]
    S = input()


    if C < D:
        is_goal = True
        for i in range(1, N):
            if S[i] == '#' and S[i-1] == '#':
                is_goal = False
    else:
        is_goal = False
        for i in range(1, N):
            if S[i-1:i+1] == '##':
                is_goal = False
                break

            if i>=2:
                if S[i-2:i+1] == '...' :
                    is_goal = True

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

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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


def can_reach(x, y):
    return 0 == s[x:y+1].count('##')


def can_reach_cross(x, y, a, b):
    t = s[x:y+1]
    if 0 != t.count('##'):
        return False
    if '...' in s[a:b+1]:
        return True
    return False


if c < d:
    # parallel
    if can_reach(a, c) and can_reach(b, d):
        print('Yes')
    else:
        print('No')
else:
    # cross
    if can_reach(b, d) and can_reach_cross(a, c, b, d):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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


def can_reach(x, y):
    return 0 == s[x:y+1].count('##')


def can_reach_cross(x, y, z):
    t = s[x:y+1]
    if 0 != t.count('##'):
        return False
    if t.count('...') == 0:
        return False
    if z <= t.index('...'):
        return False
    return True


if c < d:
    # parallel
    if can_reach(a, c) and can_reach(b, d):
        print('Yes')
    else:
        print('No')
else:
    # cross
    if can_reach(b, d) and can_reach_cross(a, c, d):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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


def can_reach(x, y):
    return 0 == s[x:y+1].count('##')


def can_reach_cross(x, y):
    return 0 == s[x:y+1].count('##') and 1 <= s[x:y+1].count('...')


if c < d:
    # parallel
    if can_reach(a, c) and can_reach(b, d):
        print('Yes')
    else:
        print('No')
else:
    # cross
    if can_reach(b, d) and can_reach_cross(a, c):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if c<d and b<c:
  s=s[a-1:d]
elif c>d and b<c:
  t=s[b-2:d+2]
  s_=s[a-1:c]
elif a<c<b<d:
  s_=s[a-1:c]
  s=s[b-1:d]
  f=0
  f_=0
  for i in range(len(s_)):
    if s_[i]=='.':
      f=0
    elif s_[i]=='#' and f==0:
      f=1
    elif s_[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(s)):
    if s[i]=='.':
      f_=0
    elif s[i]=='#' and f_==0:
      f_=1
    elif s[i]=='#' and f_==1:
      print('No')
      exit()
  print('Yes')
  exit()
if c<d:
  f=0
  for i in range(len(s)):
    if s[i]=='.':
      f=0
    elif s[i]=='#' and f==0:
      f=1
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  print('Yes')
else:
  f=0
  g=0
  h='No'
  for i in range(len(s_)):
    if s_[i]=='.':
      f=0
    elif s_[i]=='#' and f==0:
      f=1
    elif s_[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(t)):
    if t[j]=='.':
      g+=1
      if g==3:
        h='Yes'
    else:
      g=0
  print(h)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if c<d and b<c:
  s=s[a-1:d]
elif c>d and b<c:
  t=s[b-1:d+2]
  s_=s[a-1:c]
elif a<c<b<d:
  s_=s[a-1:c]
  s=s[b-1:d]
  f=0
  f_=0
  for i in range(len(s_)):
    if s_[i]=='.':
      f=0
    elif s_[i]=='#' and f==0:
      f=1
    elif s_[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(s)):
    if s[i]=='.':
      f_=0
    elif s[i]=='#' and f_==0:
      f_=1
    elif s[i]=='#' and f_==1:
      print('No')
      exit()
  print('Yes')
  exit()
if c<d:
  f=0
  for i in range(len(s)):
    if s[i]=='.':
      f=0
    elif s[i]=='#' and f==0:
      f=1
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  print('Yes')
else:
  f=0
  g=0
  h='No'
  for i in range(len(s_)):
    if s_[i]=='.':
      f=0
    elif s_[i]=='#' and f==0:
      f=1
    elif s_[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(t)):
    if t[j]=='.':
      g+=1
      if g==3:
        h='Yes'
    else:
      g=0
  print(h)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if c<d and b<c:
  s=s[a-1:d]
elif c>d and b<c:
  t=s[b-1:d]
  s_=s[a-1:c]
elif a<c<b<d:
  s_=s[a-1:c]
  s=s[b-1:d]
  f=0
  f_=0
  for i in range(len(s_)):
    if s_[i]=='.':
      f=0
    elif s_[i]=='#' and f==0:
      f=1
    elif s_[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(s)):
    if s[i]=='.':
      f_=0
    elif s[i]=='#' and f_==0:
      f_=1
    elif s[i]=='#' and f_==1:
      print('No')
      exit()
  print('Yes')
  exit()
if c<d:
  f=0
  for i in range(len(s)):
    if s[i]=='.':
      f=0
    elif s[i]=='#' and f==0:
      f=1
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  print('Yes')
else:
  f=0
  g=0
  h='No'
  for i in range(len(s_)):
    if s_[i]=='.':
      f=0
    elif s_[i]=='#' and f==0:
      f=1
    elif s_[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(t)):
    if t[j]=='.':
      g+=1
      if g==3:
        h='Yes'
    else:
      g=0
  print(h)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if c<d and b<c:
  s=s[a-1:d]
elif c>d and b<c:
  t=s[b-1:d]
  s=s[a-1:c]
elif a<c<b<d:
  s_=s[a-1:c]
  s=s[b-1:d]
  f=0
  f_=0
  for i in range(len(s_)):
    if s_[i]=='.':
      f=0
    elif s_[i]=='#' and f==0:
      f=1
    elif s_[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(s)):
    if s[i]=='.':
      f_=0
    elif s[i]=='#' and f_==0:
      f_=1
    elif s[i]=='#' and f_==1:
      print('No')
      exit()
  print('Yes')
  exit()
if c<d:
  f=0
  for i in range(len(s)):
    if s[i]=='.':
      f=0
    elif s[i]=='#' and f==0:
      f=1
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  print('Yes')
  exit()
else:
  f=0
  g=0
  h='No'
  for i in range(len(s)):
    if s[i]=='.':
      f=0
    elif s[i]=='#' and f==0:
      f=1
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(t)):
    if t[j]=='.':
      g+=1
      if g==3:
        h='Yes'
    else:
      g=0
  print(h)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if c<d and b<c:
  s=s[a-1:d]
elif c>d and b<d:
  t=s[b-1:d]
  s=s[a-1:c]
elif a<c<b<d:
  s_=s[a-1:c]
  s=s[b-1:d]
  f=0
  f_=0
  for i in range(len(s_)):
    if s_[i]=='.':
      f=0
    elif s_[i]=='#' and f==0:
      f=1
    elif s_[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(s)):
    if s[i]=='.':
      f_=0
    elif s[i]=='#' and f_==0:
      f_=1
    elif s[i]=='#' and f_==1:
      print('No')
      exit()
  print('Yes')
  exit()
if c<d:
  f=0
  for i in range(len(s)):
    if s[i]=='.':
      f=0
    elif s[i]=='#' and f==0:
      f=1
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  print('Yes')
  exit()
else:
  f=0
  g=0
  h='No'
  for i in range(len(s)):
    if s[i]=='.':
      f=0
    elif s[i]=='#' and f==0:
      f=1
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(t)):
    if t[j]=='.':
      g+=1
      if g==3:
        h='Yes'
    else:
      g=0
  print(h)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if c<d and b<c and not(a<c<b<d):
  s=s[a-1:d]
elif c>d and b<d and not (a<c<b<d):
  t=s[b-1:d]
  s=s[a-1:c]
elif a<c<b<d:
  s_=s[a-1:c]
  s=s[b-1:d]
  f=0
  f_=0
  for i in range(len(s_)):
    if s_[i]=='.':
      f=0
    elif s_[i]=='#' and f==0:
      f=1
    elif s_[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(s)):
    if s[i]=='.':
      f_=0
    elif s[i]=='#' and f_==0:
      f_=1
    elif s[i]=='#' and f_==1:
      print('No')
      exit()
  print('Yes')
  exit()
if c<d:
  f=0
  for i in range(len(s)):
    if s[i]=='.':
      f=0
    elif s[i]=='#' and f==0:
      f=1
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  print('Yes')
else:
  f=0
  g=0
  h='No'
  for i in range(len(s)):
    if s[i]=='.':
      f=0
    elif s[i]=='#' and f==0:
      f=1
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(t)):
    if t[j]=='.':
      g+=1
      if g==3:
        h='Yes'
    else:
      g=0
  print(h)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if c<d:
  s=s[a-1:d]
else:
  s_=s[a-1:c]
  t=s[b-1:d]
if c<d:
  f=0
  for i in range(len(s)):
    if s[i]=='.':
      f=0
    elif s[i]=='#' and f==0:
      f=1
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  print('Yes')
else:
  f=0
  g=0
  h='No'
  for i in range(len(s_)):
    if s_[i]=='.':
      f=0
    elif s_[i]=='#' and f==0:
      f=1
    elif s_[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(t)):
    if t[j]=='.':
      g+=1
      if g==3:
        h='Yes'
    elif t[j]=='#':
      g=0
  print(h)
  exit()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if c<d and b<c and not(a<c<b<d):
  s=s[a-1:d]
elif c>d and b<d and not (a<c<b<d):
  s=s[a-1:c]
elif a<c<b<d:
  s_=s[a-1:c]
  s=s[b-1:d]
  f=0
  f_=0
  for i in range(len(s_)):
    if s_[i]=='.':
      f=0
    elif s_[i]=='#' and f==0:
      f=1
    elif s_[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(s)):
    if s[i]=='.':
      f_=0
    elif s[i]=='#' and f_==0:
      f_=1
    elif s[i]=='#' and f_==1:
      print('No')
      exit()
  print('Yes')
  exit()
if c<d:
  f=0
  for i in range(len(s)):
    if s[i]=='.':
      f=0
    elif s[i]=='#' and f==0:
      f=1
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  print('Yes')
else:
  f=0
  g=0
  h='No'
  for i in range(len(s)):
    if s[i]=='.':
      f=0
      g+=1
      if g==3:
        h='Yes'
    elif s[i]=='#' and f==0:
      f=1
      g=0
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  if h=='Yes':
    print('Yes')
    exit()
  else:
    print('No')
    exit()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if c<d and b<c:
  s=s[a-1:d]
elif c>d and b<d:
  s=s[a-1:c]
elif a<c<b<d:
  s_=s[a-1:c]
  s=s[b-1:d]
  f=0
  f_=0
  for i in range(len(s_)):
    if s_[i]=='.':
      f=0
    elif s_[i]=='#' and f==0:
      f=1
    elif s_[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(s)):
    if s[i]=='.':
      f_=0
    elif s[i]=='#' and f_==0:
      f_=1
    elif s[i]=='#' and f_==1:
      print('No')
      exit()
  print('Yes')
  exit()
if c<d:
  f=0
  for i in range(len(s)):
    if s[i]=='.':
      f=0
    elif s[i]=='#' and f==0:
      f=1
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  print('Yes')
else:
  f=0
  g=0
  h='No'
  for i in range(len(s)):
    if s[i]=='.':
      f=0
      g+=1
      if g==3:
        h='Yes'
    elif s[i]=='#' and f==0:
      f=1
      g=0
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  if h=='Yes':
    print('Yes')
    exit()
  else:
    print('No')
    exit()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if c<d:
  s=s[a-1:d]
else:
  s=s[a-1:c]
if c<d:
  f=0
  for i in range(len(s)):
    if s[i]=='.':
      f=0
    elif s[i]=='#' and f==0:
      f=1
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  print('Yes')
else:
  f=0
  g=0
  h='No'
  for i in range(len(s)):
    if s[i]=='.':
      f=0
      g+=1
      if g==3:
        h='Yes'
    elif s[i]=='#' and f==0:
      f=1
      g=0
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  if h=='Yes':
    print('Yes')
    exit()
  else:
    print('No')
    exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, a, b, c, d = [int(x) for x in input().split()]
    s = input() + '#'
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    
    gg = 0
    y = s.find('##', a)
    if y != -1 and y <= max(c, d) and y > min(a, b):
        gg = 1
    if c > d:
        x = s.find('...', b)
        xd = 1
        if ((s[b + 1] == s[b - 1] and s[b - 1] == '.') 
            or (s[b+1] == s[b+2]  and s[b+1] == '.')
            or (x != -1 and x + 2 <= c)):
            xd = 0
        if gg or xd:
            print("No")
        else:
            print("Yes")
    else:
        if gg:
            print("No")
        else:
            print("Yes")

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

abc

"""