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:
def main():
    n, a, b, c, d = map(int, input().split())
    a -= 1; b -= 1; c -= 1; d -= 1;
    s = input()

    if c < d:
        for i in range(a, d-1):
            if s[i:i+2] == "##":
                print("No")
                return 0
        print("Yes")

    else:
        for i in range(a, c-1):
            if s[i:i+2] == "##":
                print("No")
                return 0
        for i in range(b, d-1):
            if s[i-1:i+2] == "...":
                print("Yes")
                return 0
        print("No")

main()

Submission status: Wrong Answer

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

    if c < d:
        for i in range(a, d-1):
            if s[i:i+2] == "##":
                print("No")
                return 0
        print("Yes")

    else:
        for i in range(a, c-1):
            if s[i:i+2] == "##":
                print("No")
                return 0
        for i in range(b, d-2):
            if s[i:i+3] == "...":
                print("Yes")
                return 0
        print("No")

main()

Submission status: Wrong Answer

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

    if c < d:
        for i in range(a, d):
            if s[i:i+2] == "##":
                print("No")
                return 0
        print("Yes")

    else:
        for i in range(a, c):
            if s[i:i+2] == "##":
                print("No")
                return 0
        for i in range(b, d-1):
            if s[i:i+3] == "...":
                print("Yes")
                return 0
        print("No")

main()

Submission status: Wrong Answer

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

    if c < d:
        for i in range(a, d):
            if s[i:i+2] == "##":
                print("No")
                return 0
        print("Yes")

    else:
        for i in range(a, c):
            if s[i:i+2] == "##":
                print("No")
                return 0
        for i in range(a, d-1):
            if s[i:i+3] == "...":
                print("Yes")
                return 0
        print("No")

main()

Submission status: Wrong Answer

Solution code:
def reach(s, x, y):
    for i in range(x, y-1):
        if s[i] == "#" and s[i+1] == "#":
            return False
    return True
def search(s, x, y):
    for i in range(x, y):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            return True
        if s[i] == "#" and s[i+1] == "#":
            break
    return False

def main():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = input().rstrip()
    if reach(s, a, c) and reach(s, b, d):
        if c < d:
            print("Yes")
        else:
            if search(s, a, d):
                print("Yes")
            else:
                print("No")

    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def reach(s, x, y):
    for i in range(x, y-1):
        if s[i] == "#" and s[i+1] == "#":
            return False
    return True
def search(s, x, y):
    for i in range(x, y):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            return True
        if s[i] == "#" and s[i+1] == "#":
            break
    return False

def main():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = input().rstrip()
    if reach(s, a, c) and reach(s, b, d):
        if c < d:
            print("Yes")
        else:
            if search(s, b, d):
                print("Yes")
            else:
                print("No")

    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def reach(s, x, y):
    for i in range(x, y-1):
        if s[i] == "#" and s[i+1] == "#":
            return False
    return True
def search(s, x):
    for i in range(x, len(s)-2):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            return True
        if s[i] == "#" and s[i+1] == "#":
            break
    for i in reversed(range(x-1)):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            return True
        if s[i+1] == "#" and s[i+2] == "#":
            break
    return False

def main():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = input().rstrip()
    if reach(s, a, c) and reach(s, b, d):
        if c < d:
            print("Yes")
        else:
            if search(s, b):
                print("Yes")
            else:
                print("No")

    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def reach(s, x, y):
    for i in range(x, y-1):
        if s[i] == "#" and s[i+1] == "#":
            return False
    return True
def search(s, x):
    for i in range(x, len(s)-2):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            return True
        if s[i] == "#" and s[i+1] == "#" and s[i+2] == "#":
            break
    for i in reversed(range(x-1)):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            return True
        if s[i] == "#" and s[i+1] == "#" and s[i+2] == "#":
            break
    return False

def main():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = input().rstrip()
    if reach(s, a, c) and reach(s, b, d):
        if c < d:
            print("Yes")
        else:
            if search(s, b):
                print("Yes")
            else:
                print("No")

    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
E=min(C,D)
F=max(C,D)
if S.find('##',A,F)>0:
  print('No')
else:
  if C<D:
    print('Yes')
  else:
    if S.find('...',B,E)>0:
      print('Yes')
    else:
      print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
E=min(C,D)
if S.find('##',B,E)> -1:
  print('No')
else:
  if C<D:
    print('Yes')
  else:
    if S.find('...',B-2,E+1)>-1:
      print('Yes')
    else:
      print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
E=min(C,D)
if S.find('##',B,E)>0:
  print('No')
else:
  if C<D:
    print('Yes')
  else:
    if S.find('...',B-2,E+1)>0:
      print('Yes')
    else:
      ('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
E=min(C,D)
if S.find('##',B,E)>0:
  print('No')
else:
  if C<D:
    print('Yes')
  else:
    if S.find('...',B,E)>0:
      print('Yes')
    else:
      ('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
for i in range(N-1):
  if S[i]=='#' and S[i+1]=='#':
    print('No')
    exit()
if C<D:
  print('Yes')
else:
  E=S[B-1:D]
  for i in range(len(E)-2):
    if E[i:i+3]=='...':
      print('Yes')
      exit()
  print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c ,d = map(int, input().split())
s = [i for i in input()]
if c > d:
    idx = b
    cnt = 0
    while idx < c:
        if s[idx] == "#":
            cnt = 0
        else:
            cnt += 1
        if cnt == 3:
            print("Yes")
            exit()
        idx += 1
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n, a, b, c ,d = map(int, input().split())
s = [i for i in input()]
if c > d:
    if s[c-2] == "#":
        print("No")
        exit()
    idx = b
    cnt = 0
    while idx < d:
        if s[idx] == "#":
            cnt = 0
        else:
            cnt += 1
        if cnt == 3:
            print("Yes")
            exit()
        idx += 1
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
n, a, b, c ,d = map(int, input().split())
s = [i for i in input()]
if c > d:
    idx = b
    cnt = 0
    while idx < d:
        if s[idx] == "#":
            cnt = 0
        else:
            cnt += 1
        if cnt == 3:
            print("Yes")
            exit()
        idx += 1
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

s = input()

if s.find('##',a,max(c, d)) < 0:
    if c<d :
        print('Yes')
    else :
        if s.find('...',a,d+1)>=0:
            print('Yes')
        else :
            print('No')
else :
    print('No')

Submission status: Wrong Answer

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

s = input()

if s.find('##',a,c) < 0 and s.find('##',b,d) < 0:
    if c<d :
        print('Yes')
    else :
        if s.find('...',b,d+1)>=0:
            print('Yes')
        else :
            print('No')
else :
    print('No')

Submission status: Wrong Answer

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

s = input()

if s.find('##',a,c) < 0 and s.find('##',b,d) < 0:
    if c<d :
        print('Yes')
    else :
        if s.find('...',b,d)>=0:
            print('Yes')
        else :
            print('No')
else :
    print('No')

Submission status: Wrong Answer

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

s = input()

if s.find('##') < 0:
    if c<d :
        print('Yes')
    else :
        if s.find('...',b-2,d+1)>=0:
            print('Yes')
        else :
            print('No')
else :
    print('No')

Submission status: Wrong Answer

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

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

s = input()

if s.find('##',a+1,c+1) < 0 and s.find('##',b+1,d+1) < 0:
    if c<d :
        print('Yes')
    else :
        if s.find('...',b-1,d)>=0:
            print('Yes')
        else :
            print('No')
else :
    print('No')

Submission status: Wrong Answer

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

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

s = input()

if s.find('##',a,c+1) < 0 and s.find('##',b,d+1) < 0:
    if c<d :
        print('Yes')
    else :
        if s.find('...',b-1,d)>=0:
            print('Yes')
        else :
            print('No')
else :
    print('No')

Submission status: Wrong Answer

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

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

s = input()

if s.find('##',a,b) < 0 and s.find('##',c,d) < 0:
    if c<d :
        print('Yes')
    else :
        if s.find('...',b-1,d)>=0:
            print('Yes')
        else :
            print('No')
else :
    print('No')

Submission status: Wrong Answer

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

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

s = input()

if s.find('##',a,c) < 0 and s.find('##',b,d) < 0:
    if c<d :
        print('Yes')
    else :
        if s.find('...',b-1,d)>=0:
            print('Yes')
        else :
            print('No')
else :
    print('No')

Submission status: Wrong Answer

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

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

s = input()

ans = 'Yes'

if c < d:
    for i in range(b+2, d):
        if s[i-1] == '#' and s[i] == '#':
            ans = 'No'
    for i in range(a+2, c):
        if s[i-1] == '#' and s[i] == '#':
            ans = 'No'
else :
    ans = 'No'
    for i in range(b+3, d):
        if s[i-2] == '.' and s[i-1] =='.' and s[i] == '.':
            ans = 'Yes'
    for i in range(b+2, d):
        if s[i-1] == '#' and s[i] == '#':
            ans = 'No'
    for i in range(a+2, c):
        if s[i-1] == '#' and s[i] == '#':
            ans = 'No'

print(ans)

Submission status: Wrong Answer

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

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

s = input()

ans = 'Yes'

if c < d:
    for i in range(b+2, d):
        if s[i-1] == '#' and s[i] == '#':
            ans = 'No'
    for i in range(a+2, c):
        if s[i-1] == '#' and s[i] == '#':
            ans = 'No'
else :
    ans = 'No'
    for i in range(b+3, d):
        if s[i-2] == '.' and s[i-1] =='.' and s[i] == '.':
            ans = 'Yes'
    for i in range(a+2, c):
        if s[i-1] == '#' and s[i] == '#':
            ans = 'No'

print(ans)

Submission status: Wrong Answer

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

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

s = list(input())

s[a] = 'a'
s[b] = 'b'

ans = 'Yes'

if c < d:
    for i in range(b+2, d):
        if s[i-1] == '#' and s[i] == '#':
            ans = 'No'
else :
    ans = 'No'
    for i in range(b+3, d):
        if s[i-2] == '.' and s[i-1] =='.' and s[i] == '.':
            ans = 'Yes'

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
ng = '##'
if c < d:
    rt1 = s[a-1:c]
    rt2 = s[b-1:d]
    if (ng not in rt1) and (ng not in rt2):
        print('Yes')
    else:
        print('No')
else:
    rt2 = s[b-1:d]
    if ng in rt2:
        print('No')
    else:
        rt1 = s[a-1:c]
        if len(rt1)>=3:
            for i in range(len(rt1)-2):
                if rt1[i:i+3]=='...':
                    print('Yes')
                    exit()
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
ng = '##'
if c < d:
    rt1 = s[a-1:c]
    rt2 = s[b-1:d]
    if (ng not in rt1) and (ng not in rt2):
        print('Yes')
    else:
        print('No')
else:
    rt2 = s[b-1:d]
    if ng in rt2:
        print('No')
    else:
        rt1 = s[a-1:c]
        for i in range(len(rt1)-2):
            if rt1[i:i+3]=='...':
                print('Yes')
                exit()
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
ng = '##'
if c < d:
    rt1 = s[a-1:c]
    rt2 = s[b-1:d]
    if (ng not in rt1) and (ng not in rt2):
        print('Yes')
    else:
        print('No')
else:
    rt2 = s[b-1:d]
    if ng in rt2:
        print('No')
    else:
        for i in range(b-1, d):
            if s[i] != '#':
                tmp_s = s[:i]+'#'+s[i+1:]
                rt1 = tmp_s[a-1:c]
                if ng not in rt1:
                    print('Yes')
        print('No')

Submission status: Wrong Answer

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

ans = 'Yes'
if (C < D):
  for i in range(A-1,C-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
else:
  can_over = False
  for i in range(A-1,C-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
    
  for i in range(B-1,D):
    if (S[i-1] == '.' and S[i] == '.' and S[i+1] == '.'):
      can_over = True
  if (can_over == False):
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

ans = 'Yes'
if (C < D):
  for i in range(A-1,C-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
else:
  can_over = False
  for i in range(A-1,C-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
    
  for i in range(B-1,D-1):
    if (S[i-1] == '.' and S[i] == '.' and S[i+1] == '.'):
      can_over = True
  if (can_over == False):
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

ans = 'Yes'
if (C < D):
  for i in range(B-1,D-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
  for i in range(A-1,C-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
else:
  cnt1 = 0
  max1 = 0
  for i in range(A-1,C-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
    if (S[i] == '.'):
      cnt1 += 1
      max1 = max(max1,cnt1)
    else:
      cnt1 = 0
  if (cnt1 != 2 and max1 < 3):
    ans = 'No'
    
  cnt2 = 0
  max2 = 0
  for i in range(B-1,D-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
    if (S[i] == '.'):
      cnt2 += 1
      max2 = max(max2,cnt2)
    else:
      cnt2 = 0
  if (cnt2 != 2 and max2 < 3):
    ans = 'No'
    
print(ans)

Submission status: Wrong Answer

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

ans = 'Yes'
if (C < D):
  for i in range(B-1,D-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
  for i in range(A-1,C-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
else:
  cnt1 = 0
  max1 = 0
  for i in range(A-1,C-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
    if (S[i] == '.'):
      cnt1 += 1
      max1 = max(max1,cnt1)
    else:
      cnt1 = 0
  if (max1 < 3):
    ans = 'No'
    
  cnt2 = 0
  max2 = 0
  for i in range(B-1,D-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
    if (S[i] == '.'):
      cnt2 += 1
      max2 = max(max2,cnt2)
    else:
      cnt2 = 0
  if (max2 < 3):
    ans = 'No'
    
print(ans)

Submission status: Wrong Answer

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

ans = 'Yes'
if (C < D):
  for i in range(B-1,D-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
  for i in range(A-1,C-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
else:
  cnt1 = 0
  max1 = 0
  for i in range(A-1,C-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
    if (S[i] == '.'):
      cnt1 += 1
      max1 = max(max1,cnt1)
    else:
      cnt = 0
  if (max1 < 3):
    ans = 'No'
    
  cnt2 = 0
  max2 = 0
  for i in range(B-1,D-1):
    if (S[i] == '#' and S[i+1] == '#'):
      ans = 'No'
      break
    if (S[i] == '.'):
      cnt2 += 1
      max2 = max(max2,cnt2)
    else:
      cnt2 = 0
  if (max2 < 3):
    ans = 'No'
    
print(ans)

Submission status: Wrong Answer

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

ans = [1]*2
ss = [1]*2

s1 = copy.copy(S)
s1[B-1] = '#'
for i in range(A-1,C-1):
  if (s1[i] == '#' and s1[i+1] == '#'):
    ss[0] = 0
    break
    
s2 = copy.copy(S)
s2[A-1] = '#'
for i in range(B-1,D-1):
  if (s2[i] == '#' and s2[i+1] == '#'):
    ss[1] = 0
    break
print(ss)
for i,s in enumerate(ss):
  if (s == 0):
    ans[i] = 0
    continue
    
  if (i == 0):
    s1[B-1] = '.'
    s1[C-1] = '#'
    for i in range(B-1,D-1):
      if (s1[i] == '#' and s1[i+1] == '#'):
        ans[0] = 0
        break
  else:
    s2[A-1] = '.'
    s2[D-1] = '#'
    for i in range(A-1,C-1):
      if (s2[i] == '#' and s2[i+1] == '#'):
        ans[1] = 0
        break
if (ans[0] or ans[1]):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

for i in range(1,n-1):
    if s[i-1:i+1]=="##":
        if a<i<c or b<i<d:
            ans=2
            break
    if s[i-1:i+2]=="...":
        jump.append(i)

if ans==2:
    print("No")
else:
    if c<d:
        ans=0
    else:
        for i in jump:
            if b<=i<=d:
                ans=0
                break

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
a-=1
b-=1
c-=1
d-=1
s=input()
bl_bl=[]
jump=[]
ans=1
for i in range(1,n-1):
    if s[i-1:i+1]=="##":
        if min(a,b) < i < max(c,d):
            ans=2
            break
    if s[i-1:i+2]=="...":
        jump.append(i)

if ans==2:
    print("No")
else:
    if c<d:
        ans=0
    else:
        for i in jump:
            if b<=i<=d:
                ans=0
                break

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
for i in (a,b,c,d):
    i-=1
s=input()
bl_bl=[]
jump=[]
ans=1
for i in range(1,n-1):
    if s[i-1:i+1]=="##":
        if min(a,b) < i < max(c,d):
            ans=2
            break
    if s[i-1:i+2]=="...":
        jump.append(i)

if ans==2:
    print("No")
else:
    if c<d:
        ans=0
    else:
        for i in jump:
            if b<=i<=d:
                ans=0
                break

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
for i in (a,b,c,d):
    i-=1
s=input()
bl_bl=[]
jump=[]
ans=1
for i in range(2,n-1):
    if s[i-1:i+1]=="##":
        if min(a,b) < i < max(c,d):
            ans=2
            break
    if s[i-1:i+2]=="...":
        jump.append(i)

if ans==2:
    print("No")
else:
    if c<d:
        ans=0
    else:
        for i in jump:
            if b<=i<=d:
                ans=0
                break

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
for i in (a,b,c,d):
    i-=1
s=input()
jump=[]
ans=1
for i in range(2,n-1):
    if s[i-1:i+1]=="##":
        ans=2
        break
    elif s[i-1:i+2]=="...":
        jump.append(i)
if ans==2:
    print("No")
else:
    if c<d:
        ans=0
    else:
        for i in jump:
            if b<=i<=d:
                ans=0
                break

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

Submission status: Wrong Answer

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

ans = "Yes"
if C < D:
    for i in range(A-1, C-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
    for i in range(B-1, D-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
else:
    for i in range(A-1, C-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
    flag = True
    for i in range(B-1, D-1):
        if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
            flag = False
    if flag:
        ans = "No"
print(ans)

Submission status: Wrong Answer

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

ans = "Yes"
if C < D:
    for i in range(A-1, C-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
    for i in range(B-1, D-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
else:
    for i in range(A-1, C-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
    flag = True
    for i in range(B-1, D-2):
        if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
            flag = False
    if flag:
        ans = "No"
print(ans)

Submission status: Wrong Answer

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

ans = "Yes"
if C < D:
    for i in range(A-1, D-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
else:
    for i in range(A-1, C-1):
        if S[i] == "#" and S[i+1] == "#":
            ans = "No"
    flag = True
    for i in range(B-1, C-2):
        if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
            flag = False
    if flag:
        ans = "No"
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

dp = [0]*N
if C < D:
    if A < B:
        for i in range(B-1, D):
            if i == -2 or i == -1:
                continue
            if dp[i-1] == 1:
                count = 0
            if (S[i-1] != '#' or S[i-2] != '#') and S[i] == '.':
                dp[i] = 1
        for i in range(A-1, B-1):
            if i == -2 or i == -1:
                continue
            if (S[i-1] != '#' or S[i-2] != '#') and S[i] == '.':
                dp[i] = 1
    else:
        S[C-1] = '#'
        for i in range(B-1, D):
            if i == -2 or i == -1:
                continue
            if (S[i-1] != '#' or S[i-2] != '#') and S[i] == '.':
                dp[i] = 1
            if dp[i] == 1 and dp[i-1] == 1 and dp[i-2] == 1 and A < i - 2 and i < C-1:
                S[C-1] = '.'

else:
    if A < B:
        S[D-1] = '#'
        for i in range(A-1, C):
            if i == -2 or i == -1:
                continue
            if (S[i-1] != '#' or S[i-2] != '#') and S[i] == '.':
                dp[i] = 1
            if dp[i] == 1 and dp[i-1] == 1 and dp[i-2] == 1 and B < i - 2 and i < D-1:
                S[D-1] = '.'
    else:
        for i in range(A-1, C):
            if i == -2 or i == -1:
                continue
            if (S[i-1] != '#' or S[i-2] != '#') and S[i] == '.':
                dp[i] = 1
        for i in range(B-1, A-1):
            if i == -2 or i == -1:
                continue
            if (S[i-1] != '#' or S[i-2] != '#') and S[i] == '.':
                dp[i] = 1

if dp[C-1] == 1 and dp[D-1] == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int, input().split())
S=input()
if S.find("##", A, B)<0 and S.find("##", C, D)<0:
    if C<D:
        print("Yes")
    else:
        if S.find("...", B-2, D+2)>=0:
            print("Yes")
        else:
            print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int, input().split())
S=input()
if S.find("##", A, B)<0 and S.find("##", C, D)<0:
    if C<D:
        print("Yes")
    else:
        if S.find("...", B-1, D+2)>=0:
            print("Yes")
        else:
            print("No")
else:
    print("No")

Submission status: Wrong Answer

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

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

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

for i in range(B, min(D, N - 1)):
    if S[i] == "#" and S[i + 1] == "#":
        print("No")
        exit()

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

if D < C:
    for i in range(B, min(D, N - 1)):
        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()

for i in range(B, D - 1):
    if S[i] == "#" and S[i + 1] == "#":
        print("No")
        exit()

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

if D < C:
    for i in range(B, D - 1):
        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()

for i in range(B, D - 1):
    print(i)
    if S[i] == "#" and S[i + 1] == "#":
        print("No")
        exit()

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

if D < C:
    for i in range(B, D - 1):
        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()

for i in range(B, D):
    if S[i] == "#" and S[i + 1] == "#":
        print("No")
        exit()

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

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

for i in range(B, D):
    if S[i] == "#" and S[i + 1] == "#":
        print("No")
        exit()

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

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