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()
max_cont_cnt = {'.': 1, '#': 1}
cont_cnt = 1
for i in range(N - 1):
    if S[i] != S[i + 1]:
        max_cont_cnt[S[i]] = max(max_cont_cnt[S[i]], cont_cnt)
        cont_cnt = 1
    else:
        cont_cnt += 1

if C < D:
    if max_cont_cnt['#'] <= 1:
        print('Yes')
    else:
        print('No')
else:
    if max_cont_cnt['#'] <= 1 and max_cont_cnt['.'] >= 3:
        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:
  if "##" not in s:
    print("Yes")
  else:
    print("No")
else:
  if "..." in s[b-2:d]:
    print("Yes")
  else:
    if s[d-2]=="#":
      print("No")
    else:
      print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


def main():
    N, A, B, C, D = map(int, input().split())
    S = input().rstrip()

    if C < D:
        can_jump_on_rock = True if "##" not in S[A - 1: D] else False
        if can_jump_on_rock:
            ans = "Yes"
        else:
            ans = "No"
    else:
        can_jump_on_rock = True if "##" not in S[A - 1: C] else False
        can_jump_on_B = True if "..." in S[B - 1: D + 1] else False
        if can_jump_on_rock and can_jump_on_B:
            ans = "Yes"
        else:
            ans = "No"

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
canA = "##" not in S[A-1:C]
canB = "##" not in S[B-1:D]
if C < D:
    if canA and canB:
        print("Yes")
    else:
        print("No")
else:
    if canA and canB and ("..." 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()
canA = "##" not in S[A:C]
canB = "##" not in S[B:D]
if C < D:
    if canA and canB:
        print("Yes")
    else:
        print("No")
else:
    if canA and canB and ("..." 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()
canA = "##" not in S[A:C]
canB = "##" not in S[B:D]
if C < D:
    if canA and canB:
        print("Yes")
    else:
        print("No")
else:
    if canA and canB and ("..." in S[B-2:C]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
canA = "##" not in S[A:C]
canB = "##" not in S[B:D]
if C < D:
    if canA and canB:
        print("Yes")
    else:
        print("No")
else:
    if canA and canB and "..." in S[B-2:C]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
canA = "##" not in S[A:C]
canB = "##" not in S[B:D]
if C < D:
    if canA and canB:
        print("Yes")
    else:
        print("No")
else:
    if canA and canB and "..." in S[B-1: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]+"."+s[b-1:d] or ("..." not in s[b-2:c+1]+"#"+s[b-1:c+1] and d<c):print("No")
else:print("Yes")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = int(input())
n, a, b, c, d  = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s  = input()
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

is_rock2 = '##' in s[a:d+1]
is_empty3 = '...' in s[b-2:d+2]

joken = (not is_rock2) and (is_empty3 if c > d else 1)
print('Yes' if joken else 'No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = int(input())
n, a, b, c, d  = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s  = input()
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

is_rock2 = '##' in s[a:d+1]
is_empty3 = '...' in s[b-1:d+1]

joken = (not is_rock2) and (is_empty3 if c > d else 1)
print('Yes' if joken else 'No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = int(input())
n, a, b, c, d  = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s  = input()
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

is_rock2 = '##' in s[a:max([b, c, d])+1]
is_empty3 = '...' in s[b-1:d+1]

joken = (not is_rock2) and (is_empty3 if c > d else 1)
print('Yes' if joken else 'No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = int(input())
n, a, b, c, d  = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s  = input()
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

is_rock2 = '##' in s[a:max([b, c, d])+1]
is_empty3 = '...' in s[a:max([b, c, d])+1]

joken = (not is_rock2) and (is_empty3 if c > d else 1)
print('Yes' if joken else 'No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = int(input())
n, a, b, c, d  = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s  = input()
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

is_rock2 = '##' in s[a:max([b, c, d])+1]
is_empty3 = '...' in s

joken = (not is_rock2) and (is_empty3 if c > d else 1)
print('Yes' if joken else 'No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = int(input())
n, a, b, c, d  = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s  = input()
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

is_rock2 = '##' in s[a:max([b, c, d])]
is_empty3 = '...' in s

joken = (not is_rock2) and (is_empty3 if c > d else 1)
print('Yes' if joken else 'No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = int(input())
n, a, b, c, d  = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s  = input()
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

if '##' in s[a:max([b, c, d])]:
    print('No')
    exit()

s_ = list(s)
s_[a] = '#'
s_[c] = '#'
s_ = ''.join(s_)
is_case_snuke = ('##' not in s_[a:c+1])
#print(s_)
s_ = list(s)
if c > d:
    s_[b] = '#'
    s_[d] = '#'
s_ = ''.join(s_)
is_case_fnuke = ('##' not in s_[b:d+1])
#print(s_)
#print(is_case_snuke, is_case_fnuke)
print('Yes' if is_case_snuke or is_case_fnuke else 'No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = int(input())
n, a, b, c, d  = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s  = input()
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

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

s_ = list(s)
s_[a] = '#'
s_[c] = '#'
s_ = ''.join(s_)
is_case_snuke = ('##' not in s_[a:c+1])
#print(s_)
s_ = list(s)
if c > d:
    s_[b] = '#'
    s_[d] = '#'
s_ = ''.join(s_)
is_case_fnuke = ('##' not in s_[b:d+1])
#print(s_)
#print(is_case_snuke, is_case_fnuke)
print('Yes' if is_case_snuke or is_case_fnuke else 'No')

Submission status: Wrong Answer

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

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

#hunuke

h = S[A-1:D].count('##')
m3 = S[B-2:D].count('...')

if C < D:
    if h == 0: print('Yes')
    else: print('No')
else:
    if m3 != 0 and h == 0:
        print('Yes')
    else: print('No')

Submission status: Wrong Answer

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

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

#hunuke

h = S[A-1:D+1].count('##')
m3 = S[B-1:D+1].count('...')

if C < D:
    if h == 0: print('Yes')
    else: print('No')
else:
    if m3 == 0: print('No')
    elif h != 0: print('No')
    else: print('Yes')

Submission status: Wrong Answer

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

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

#hunuke

h = S[B-1:D+1].count('##')
m3 = S[B-1:D+1].count('...')

if C < D:
    if h == 0: print('Yes')
    else: print('No')
else:
    if m3 == 0: print('No')
    else: print('Yes')

Submission status: Wrong Answer

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

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

#hunuke

h = S[B-1:D+1].count('##')
m3 = S[B-1:C+1].count('...')

if C < D:
    if h == 0: print('Yes')
    else: print('No')
else:
    if m3 == 0: print('No')
    else: print('Yes')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = int(input())
n, a, b, c, d  = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s  = input()
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

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

s_ = list(s)
s_[a] = '#'
s_[c] = '#'
s_ = ''.join(s_)
is_case_snuke = ('##' not in s_[a:c+1])
#print(s_)
s_ = list(s)
s_[b] = '#'
s_[d] = '#'
s_ = ''.join(s_)
is_case_fnuke = ('##' not in s_[b:d+1])
#print(s_)
#print(is_case_snuke, is_case_fnuke)
print('Yes' if is_case_snuke or is_case_fnuke else 'No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if "##" in s[a-1:d] or "..." not in s[b-1:c+1]:print("No")
else:print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def myAnswer(N:int,A:int,B:int,C:int,D:int,S:list) -> str:
   flag = False
   for i in range(N-1):
      if(S[i] == S[i + 1] == "#"): return "No"
   for i in range(N - 2):
      if(S[i] == S[i + 1] == S[i + 2]== "."):flag = True


   if(C < D): return "Yes"
   return "Yes" if(flag) else "No"

def modelAnswer():
   return
def main():
   N,A,B,C,D = map(int,input().split())
   S = list(input())
   print(myAnswer(N,A,B,C,D,S[:]))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
n=list(map(int,input().split()))
track=input()
# print(n,'\n',track)
if (track[n[3]-1]=='#' or track[n[4]-1]=='#'):
    print("No")
    quit()
for i in range(n[2],n[0]-1):
    # print(track[i],i+1,track[i+1],i+1)
    if (track[i]=='#' and track[i+1]=='#'):
        print("No")
        quit()
track=list(track)
track[n[4]-1]='#'
for i in range(n[2],n[3]-1):
    # print(track[i],i+1,track[i+1],i+1)
    if (track[i]=='#' and track[i+1]=='#'):
        print("No")
        quit()

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools

import copy

# import heapq
# from collections import deque
# import decimal

# sys.setrecursionlimit(100001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, a, b, c, d = ns()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = list(input())

    stone_twice_flg = True
    for i in range(a, max(c, d)):
        if s[i] == s[i + 1] == "#":
            stone_twice_flg = False
            break

    pass_flg = False
    if c > d:
        for i in range(b, d):
            if s[i - 1] == s[i] == s[i + 1] == ".":
                pass_flg = True
                break
    else:
        pass_flg = True

    if stone_twice_flg and pass_flg:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import re
N,A,B,C,D = (int(x) for x in input().split())
S = input()
if re.search(r'##',S[A-1:max(C,D)]):
    print('No')
else:
    if D < C:
        if re.search(r'\.\.\.',S[B-2:D+2]):
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
import re
N,A,B,C,D = (int(x) for x in input().split())
S = input()
if re.search(r'##',S[A-1:max(C,D)]):
    print('No')
else:
    if D < C:
        if re.search(r'\.\.\.',S[A-1:D+2]):
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline  # NOQA


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

    can_jump_R = True  # '##'
    can_jump_B = False  # '...'
    for i in range(A + 1, N - 1):
        if S[i] == S[i+1] == "#":
            if A < i < C or B < i < D:
                can_jump_R = False
        if S[i-1] == S[i] == S[i+1] == ".":
            if B <= i < C:
                can_jump_B = True

    if C < D:
        if can_jump_R:
            ans = "Yes"
        else:
            ans = "No"
    else:
        if can_jump_R and can_jump_B:
            ans = "Yes"
        else:
            ans = "No"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline  # NOQA


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

    can_jump_R = True  # '##'
    can_jump_B = False  # '...'
    for i in range(A, N - 1):
        if S[i] == S[i+1] == "#":
            if A < i < C or B < i < D:
                can_jump_R = False
        if S[i-1] == S[i] == S[i+1] == ".":
            if B <= i < C:
                can_jump_B = True

    if C < D:
        if can_jump_R:
            ans = "Yes"
        else:
            ans = "No"
    else:
        if can_jump_R and can_jump_B:
            ans = "Yes"
        else:
            ans = "No"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline  # NOQA


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

    can_jump_R = True  # '##'
    can_jump_B = False  # '...'
    for i in range(B, N - 1):
        if S[i] == S[i+1] == "#":
            if A < i < C or B < i < D:
                can_jump_R = False
        if S[i-1] == S[i] == S[i+1] == ".":
            if B <= i < C:
                can_jump_B = True

    if C < D:
        if can_jump_R:
            ans = "Yes"
        else:
            ans = "No"
    else:
        if can_jump_R and can_jump_B:
            ans = "Yes"
        else:
            ans = "No"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline  # NOQA


def main():
    N, A, B, C, D = map(int, input().split())
    S = input().rstrip()

    can_jump_R = True  # '##'
    can_jump_B = False  # '...'
    for i in range(B - 1, N - 1):
        if S[i] == S[i+1] == "#":
            can_jump_R = False
        if S[i-1] == S[i] == S[i+1] == "." and B <= i and i+1 <= C:
            can_jump_B = True

    if C < D:
        if can_jump_R:
            ans = "Yes"
        else:
            ans = "No"
    else:
        if can_jump_R and can_jump_B:
            ans = "Yes"
        else:
            ans = "No"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if C<D:
    if ("##" in S[A:C]) or ("##" in S[B:D]):
        print("No")
        exit()
    else:
        print("Yes")
        exit()
else:
    if ("##" in S[A:C]) or ("##" in S[B:D]):
        print("No")
        exit()
    else:
        if ("..." in S[B:D]):
            print("Yes")
            exit()
        else:
            print("No")
            exit()

Submission status: Wrong Answer

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

ans = 'Yes'
if s[a-1:c].find('##') > -1:
    ans = 'No'
elif s[b-1:d].find('##') > -1:
    ans = 'No'
else:
    if d < c:
        if s[b-1:d].find('...') == -1:
            ans = 'No'

print(ans)

Submission status: Wrong Answer

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

ans = 'Yes'
if s.find('##') > -1:
    ans = 'No'
else:
    if d < c:
        if s[b-1:d].find('...') == -1:
            ans = 'No'

print(ans)

Submission status: Wrong Answer

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

ans = 'Yes'
if s.find('##') > -1:
    ans = 'No'
else:
    if d < c:
        if s[b:d+1].find('...') == -1:
            ans = 'No'

print(ans)

Submission status: Wrong Answer

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

        for i in range(b-1,d-3):
            if s[i] == s[i+1] == s[i+2] and s[i] == '.':
                print('Yes')
                return


        print('No')



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, a, b, c, d = map(int,input().split())
    s = list(input())
    if c<d:
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        print('Yes')
    else:
        tmp = [0,n-1]
        flg = False
        for i in range(len(s)-2):
            if s[i] == s[i+1] and s[i] == '#':
                flg = True
            if flg and s[i+1] == '.':
                flg = False
                tmp.append(i)
        tmp.sort()
        flg = False
        for i in range(len(tmp)-1):
            if tmp[i] <= a-1 <= tmp[i+1] and tmp[i] <= b-1 <= tmp[i+1] and  tmp[i] <= c-1 <= tmp[i+1] and tmp[i] <= d-1 <= tmp[i+1]:
                flg = True
                break
        if not flg:
            print('No')
            return

        for i in range(tmp[i], tmp[i+1]-2):
            if s[i] == s[i+1] == s[i+2] and s[i] == '.':
                print('Yes')
                return
        print('No')



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, a, b, c, d = map(int,input().split())
    s = list(input())
    if c<d:
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        print('Yes')
    else:
        tmp = [0,n-1]
        flg = False
        for i in range(len(s)-2):
            if s[i] == s[i+1] and s[i] == '#':
                flg = True
            if flg and s[i+1] == '.':
                flg = False
                tmp.append(i)
        tmp.sort()
        flg = False
        for i in range(len(tmp)-1):
            if tmp[i] <= a-1 <= tmp[i+1] and tmp[i] <= b-1 <= tmp[i+1] and  tmp[i] <= c-1 <= tmp[i+1] and tmp[i] <= d-1 <= tmp[i+1]:
                flg = True
                break
        print(tmp)
        if not flg:
            print('No')
            return

        for i in range(tmp[i], tmp[i+1]-2):
            if s[i] == s[i+1] == s[i+2] and s[i] == '.':
                print('Yes')
                return
        print('No')



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, a, b, c, d = map(int,input().split())
    s = list(input())
    if c<d:
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        print('Yes')
    else:
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        s[b-1] = '#'
        flg = True
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                flg = False
                break
        if flg:
            print('Yes')
            return
        flg = True
        s[b-1] = '.'
        s[d-1] = '#'
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                flg = False
                break
        if flg:
            print('Yes')
            return

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

        print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, a, b, c, d = map(int,input().split())
    s = list(input())
    if c<d:
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        print('Yes')
    else:
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        s[b-1] = '#'
        flg = True
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                flg = False
                break
        if flg:
            print('Yes')
            return
        flg = True
        s[b-1] = '.'
        s[d-1] = '#'
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                flg = False
                break
        if flg:
            print('Yes')
            return

        for i in range(a-1,c-3):
            if s[i] == s[i+1] == s[i+2] and s[i] == '.':
                print('Yes')
                return
            
        print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, a, b, c, d = map(int,input().split())
    s = list(input())
    if c<d:
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        print('Yes')
    else:
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        s[b-1] = '#'
        flg = True
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                flg = False
                break
        if flg:
            print('Yes')
            return
        flg = True
        s[b-1] = '.'
        s[d-1] = '#'
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                flg = False
                break
        if flg:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

for i in range(a + 1, max(c, d) - 1):
    if s[i: i + 2] == '##':
        print('No')
        sys.exit()

if c < d:
    print('Yes')
    sys.exit()

for i in range(b, d):
        if s[i - 1: i + 2] == '...':
            print('Yes')
            sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys

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

maximum = max(c, d)
for i in range(a, maximum):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        sys.exit()

if c < d:
    print('Yes')
    sys.exit()

for i in range(b, d):
    if 0 < i and i + 1 < n:
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            print('Yes')
            sys.exit()

print('No')

Submission status: Wrong Answer

Solution code:
import sys

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

flg = False
maximum = max(c, d)
for i in range(a, maximum):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        sys.exit()

for i in range(b, d):
    if 0 < i and i + 1 < n:
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            flg = True

if c < d:
    print('Yes')
else:
    if flg:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys

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

flg = False
for i in range(a, d + 1):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        sys.exit()

for i in range(b, d):
    if 0 < i and i + 1 < n:
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            flg = True

if c < d:
    print('Yes')
else:
    if flg:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys

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

flg = False
for i in range(a, d + 1):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        sys.exit()
    
    if 0 < i and i + 1 < n:
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            flg = True

if c < d:
    print('Yes')
else:
    if flg:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys

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

flg = False
for i in range(b, d + 1):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        sys.exit()
    
    if 0 < i and i + 1 < n:
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            flg = True

if c < d:
    print('Yes')
else:
    if flg:
        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:d]):
    print('No')
    exit()
if(c < d):
    print('Yes')
else:
    if('...' in s[b-3:d]):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

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