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())
# 1-indexed
S = ["$"] + list(input())

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d-=1
    s = list(input())
    if c < d:
        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()
        print("Yes")
    else:
        for i in range(b, d):
            if s[i] == "#" and s[i + 1] == "#":
                print("No")
                exit()
        f = True
        for i in range(b, d):
            if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
                f = False
                break
        if f:
            print("No")
            exit()
        for i in range(a, c):
           if s[i] == "#" and s[i + 1] == "#":
               print("No")
               exit()
        print("Yes")



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d-=1
    s = list(input())
    if c < d:
        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()
        print("Yes")
    else:
        for i in range(b, d):
            if s[i] == "#" and s[i + 1] == "#":
                print("No")
                exit()
        f = True
        for i in range(b, d - 1):
            if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
                f = False
                break
        if f:
            print("No")
            exit()
        for i in range(a, c):
           if s[i] == "#" and s[i + 1] == "#":
               print("No")
               exit()
        print("Yes")



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d-=1
    s = list(input())
    if c < d:
        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()
        print("Yes")
    else:
        for i in range(b, d):
            if s[i] == "#" and s[i + 1] == "#":
                print("No")
                exit()
        f = True
        for i in range(max(1,b), min(n - 1,d)):
            if s[i-1] == "." and s[i] == "." and s[i+1] == ".":
                f = False
                break
        if f:
            print("No")
            exit()
        for i in range(a, c):
           if s[i] == "#" and s[i + 1] == "#":
               print("No")
               exit()
        print("Yes")



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d-=1
    s = list(input())
    if c < d:
        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()
        print("Yes")
    else:
        for i in range(b, d):
            if s[i] == "#" and s[i + 1] == "#":
                print("No")
                exit()
        f = True
        for i in range(max(1,b), max(n - 1,d)):
            if s[i-1] == "." and s[i] == "." and s[i+1] == ".":
                f = False
                break
        if f:
            print("No")
            exit()
        for i in range(a, c):
           if s[i] == "#" and s[i + 1] == "#":
               print("No")
               exit()
        print("Yes")



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    n, a, b, c, d = map(int, input().split())
    s = list(input())
    if c < d:
        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()
        print("Yes")
    else:
        for i in range(b, d):
            if s[i] == "#" and s[i + 1] == "#":
                print("No")
                exit()
        f = True
        for i in range(b, d):
            if s[i-1] == "." and s[i] == "." and s[i+1] == ".":
                f = False
                break
        if f:
            print("No")
            exit()
        for i in range(a, c):
           if s[i] == "#" and s[i + 1] == "#":
               print("No")
               exit()
        print("Yes")



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    n, a, b, c, d = map(int, input().split())
    s = list(input())
    if c < d:
        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()
        print("Yes")
    else:
        f=True
        for i in range(b, d):
            if s[i-1] == "." and s[i] == "." and s[i+1] == ".":
                f = False
                break
        if f:
            print("No")
            exit()
        for i in range(a, c):
           if s[i] == "#" and s[i + 1] == "#":
               print("No")
               exit()
        print("Yes")



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    n, a, b, c, d = map(int, input().split())
    s = list(input())
    if c < d:
        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()
        print("Yes")
    else:
        f=True
        for i in range(b, d-1):
            if s[i] == "." and s[i + 1] == "." and s[i+2] == ".":
                f = False
                break
        if f:
            print("No")
            exit()
        s[d - 1] = "#"
        for i in range(a, c):
           if s[i] == "#" and s[i + 1] == "#":
               print("No")
               exit()
        print("Yes")



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    n, a, b, c, d = map(int, input().split())
    s = input()
    if c < d:
        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()
        print("Yes")
    else:
        f=True
        for i in range(b, d-1):
            if s[i] == "." and s[i + 1] == "." and s[i+2] == ".":
                f = False
                break
        if f:
            print("No")
            exit()
        for i in range(a, c):
           if s[i] == "#" and s[i + 1] == "#":
               print("No")
               exit()
        print("Yes")



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, A, B, C, D = MAP()
M = input().rstrip()
M = [m for m in M]

if D>C:
	for i in range(B-1, D):
		if i!=D-1 and ((i < N-3 and M[i+1] == '#' and M[i+2] == '#') or (i == N-2 and M[i+1] == '#')): 
			print('No')
			sys.exit()
	M[D-1] = '#'
	for i in range(A-1, C):
		if i<C-1 and ((i < N-3 and M[i+1] == '#' and M[i+2] == '#') or (i == N-2 and M[i+1] == '#')): 
			print('No')
			sys.exit()
	print('Yes')
else:
	if A+1 == B and M[A+1]=='#' or A+2==B and M[A]=='#':
		print('No')
		sys.exit()
	for i in range(A-1, C):
		if i!=C-1 and ((i < N-3 and M[i+1] == '#' and M[i+2] == '#') or (i == N-2 and M[i+1] == '#')): 
			print('No')
			sys.exit()
	M[C-1] = '#'
	for i in range(B-1, D):
		if i!= D-1 and ((i < N-3 and M[i+1] == '#' and M[i+2] == '#') or (i == N-2 and M[i+1] == '#')): 
			print('No')
			sys.exit()
	print('Yes')

Submission status: Wrong Answer

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

if C < D:
    flag = True
    for i in range(A-1,D-2):
        if S[i]=='#' and S[i+1]=='#':
            flag = False
    print('Yes' if flag else 'No')
else:
    flag = False
    for i in range(B-1,D-1):
        cnt = 0
        for j in {-1,0,1}:
            if S[i+j]=='.':
                cnt += 1
        if cnt == 3:
            flag = True
    for i in range(A-1,C-2):
        if S[i]=='#' and S[i+1]=='#':
            flag = False

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

Submission status: Wrong Answer

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

if C < D:
    flag = True
    for i in range(A-1,D-2):
        if S[i]=='#' and S[i+1]=='#':
            flag = False
    print('Yes' if flag else 'No')
else:
    flag = False
    for i in range(B-1,D-1):
        cnt = 0
        for j in {-1,0,1}:
            if S[i+j]=='#':
                cnt += 1
        if cnt == 3:
            flag = True
    for i in range(A-1,C-2):
        if S[i]=='#' and S[i+1]=='#':
            flag = False

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

Submission status: Wrong Answer

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

if C < D:
    flag = True
    for i in range(A-1,D-2):
        if S[i]=='#' and S[i+1]=='#':
            flag = False
    print('Yes' if flag else 'No')
else:
    flag = False
    for i in range(B-1,D-2):
        cnt = 0
        for j in {-1,0,1}:
            if S[i+j]=='.':
            	cnt += 1
        if cnt == 3:
            flag = True
    for i in range(A-1,C-2):
        if S[i]=='#' and S[i+1]=='#':
            flag = False

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input().strip()
S = "."+S
flag=0
if C<B:
    for i in range(A,C):
        if S[i:i+2]=="##":
            flag=1
            break
    for i in range(B,D):
        if S[i:i+2]=="##":
            flag=1
            break
    if flag==1:
        print("No")
    else:
        print("Yes")
elif B<C<D:
    for i in range(A,D):
        if S[i:i+2]=="##":
            flag=1
            break
    if flag==1:
        print("No")
    else:
        print("Yes")
else:
    for i in range(A,C):
        if S[i:i+2]=="##":
            flag = 1
            break
    if flag==1:
        print("No")
    else:
        flag = 1
        for i in range(B,D):
            if S[i]=="#":continue
            if (S[i-1]=="#" and S[i+1]=="#") or (S[i-2:i]=="#." and S[i+1]=="#") or (S[i-1]=="#" and S[i+1:i+3]==".#"):continue
            else:
                flag=0
                break
        if flag==1:
            print("No")
        else:
            print("Yes")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input().strip()
S = "."+S
flag=0
if C<B:
    for i in range(A,C):
        if S[i:i+2]=="##":
            flag=1
            break
    for i in range(B,D):
        if S[i:i+2]=="##":
            flag=1
            break
    if flag==1:
        print("No")
    else:
        print("Yes")
elif B<C<D:
    for i in range(A,D):
        if S[i:i+2]=="##":
            flag=1
            break
    if flag==1:
        print("No")
    else:
        print("Yes")
else:
    for i in range(A,C):
        if S[i:i+2]=="##":
            flag = 1
            break
    if flag==1:
        print("No")
    else:
        flag = 1
        for i in range(B,D+1):
            if S[i]=="#":continue
            if (S[B-1]=="#" and S[B+1]=="#") or (S[B-2:B]=="#." and S[B+1]=="#") or (S[B-1]=="#" and S[B+1:B+3]==".#"):continue
            else:
                flag=0
                break
        if flag==1:
            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(n-1):
  if s[i]==s[i+1]=='#':
    print('No')
    exit()
if c>d:
  for i in range(b-2,d-1):
    if s[i]==s[i+1]==s[i+2]=='.':
      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(n-1):
  if s[i]==s[i+1]=='#':
    print('No')
    exit()
if c>d:
  for i in range(b-2,d-2):
    if s[i]==s[i+1]==s[i+2]=='.':
      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(n-1):
  if s[i]==s[i+1]=='#':
    print('No')
    exit()
if c>d:
  for i in range(b-1,d-1):
    if s[i]==s[i+1]==s[i+2]=='.':
      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()

def f(x, y, s):
  tmp=[0]*(N+1)
  tmp[x]=1
  if s[x+1]=='.':
    tmp[x+1]=1
  i=x+2
  while i<=y:
    if tmp[i-2]==1 or tmp[i-1]==1:
      tmp[i]=1
    i+=1
  if tmp[y]>0:
    out=True
  else:
    out=False
    
  return out

if C<D:
  if f(A, C, S)==True and f(B, D, S)==True:
    print('Yes')
  else:
    print('No')
  exit()

def g(x, y, s):
  out=False
  for i in range(x, y+1):
    if s[i-1:i+2]=='...':
      out=True
  return out
  
if f(A, C, S)==True and f(B, D, S)==True and g(B, D, S)==True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

def f(x, y, s):
  tmp=[0]*(N+1)
  tmp[x]=1
  if s[x+1]=='.':
    tmp[x+1]=1
  i=x+2
  while i<=y:
    if tmp[i-2]==1 or tmp[i-1]==1:
      tmp[i]=1
    i+=1
  if tmp[y]>0:
    out=True
  else:
    out=False
    
  return out

if C<D:
  if f(A, C, S)==True and f(B, D, S)==True:
    print('Yes')
  else:
    print('No')
  exit()

def g(x, y, s):
  out=False
  for i in range(x, y-1):
    if s[i-1:i+2]=='...':
      out=True
  return out
  
if f(A, C, S)==True and f(B, D, S)==True and g(B, D, S)==True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

def f(x, y, s):
  tmp=[0]*(N+1)
  tmp[x]=1
  if s[x+1]=='.':
    tmp[x+1]=1
  i=x+2
  while i<=y:
    if tmp[i-2]==1 or tmp[i-1]==1:
      tmp[i]=1
    i+=1
  if tmp[y]>0:
    out=True
  else:
    out=False
    
  return out

if C<D:
  if f(A, C, S)==True and f(B, D, S)==True:
    print('Yes')
  else:
    print('No')
  exit()

def g(x, y, s):
  out=False
  for i in range(x, y-2):
    if s[i:i+3]=='...':
      out=True
  return out
  
if f(A, C, S)==True and f(B, D, S)==True and g(B-1, D+1, S)==True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

def f(x, y, s):
  tmp=[0]*(N+1)
  tmp[x]=1
  if s[x+1]=='.':
    tmp[x+1]=1
  i=x+2
  while i<=y:
    if tmp[i-2]==1 or tmp[i-1]==1:
      tmp[i]=1
    i+=1
  if tmp[y]>0:
    out=True
  else:
    out=False
    
  return out

if C<D:
  if f(A, C, S)==True and f(B, D, S)==True:
    print('Yes')
  else:
    print('No')
  exit()

def g(x, y, s):
  out=False
  for i in range(x, y-1):
    if s[i:i+3]=='...':
      out=True
  return out
  
if f(A, C, S)==True and f(B, D, S)==True and g(B, D, S)==True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

def f(x, y, s):
  tmp=[0]*(N+1)
  tmp[x]=1
  if s[x+1]=='.':
    tmp[x+1]=1
  i=x+2
  while i<=y:
    if tmp[i-2]==1 or tmp[i-1]==1:
      tmp[i]=1
    i+=1
  if tmp[y]>0:
    out=True
  else:
    out=False
    
  return out

if C<D:
  if f(A, C, S)==True and f(B, D, S)==True:
    print('Yes')
  else:
    print('No')
  exit()

def g(x, y, s):
  out=False
  for i in range(x, y-2):
    if s[i:i+3]=='...':
      out=True
  return out
  
if f(A, C, S)==True and f(B, D, S)==True and g(B, D, S)==True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    
    if A<C<B<D:
        for i in range(A-1,C-1):
            if S[i] == S[i+1] == "#":
                print(NO)
                return
        for i in range(B-1,D-1):
            if S[i] == S[i+1] == "#":
                print(NO)
                return     
        print(YES)
        return
    
    if A<B<C<D:
        for i in range(0,N-1):
            if S[i] == S[i+1] == "#":
                print(NO)
                return   
        print(YES)
        return

    if A<B<D<C:
        for i in range(B-1,D):
            if S[i-1] == S[i] == S[i+1] == ".":
                print(YES)
                return   
        print(NO)
        return     

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    
    if A<C<B<D:
        for i in range(A-1,C-1):
            if S[i] == S[i+1] == "#":
                print(NO)
                return
        for i in range(B-1,D-1):
            if S[i] == S[i+1] == "#":
                print(NO)
                return     
        print(YES)
        return
    
    if A<B<C<D:
        for i in range(0,N-1):
            if S[i] == S[i+1] == "#":
                print(NO)
                return   
        print(YES)
        return

    if A<B<D<C:
        for i in range(B-1,D-1):
            if S[i-1] == S[i] == S[i+1] == ".":
                print(YES)
                return   
        print(NO)
        return     

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

def main():
    N,A,B,C,D = map(int,input().split())
    S = list(input())
    # check 1
    check = S[B:D-1]
    flg=False
    for i in check:
        if i=="#":
            if flg:
                print("No")
                exit()
            else:
                flg=True
        else:
            if flg:
                flg=False
            else:
                pass
            
    check = S[A:C-1]
    flg = False
    for i in check:
        if i == "#":
            if flg:
                print("No")
                exit()
            else:
                flg=True
        else:
            if flg:
                flg=False
            else:
                pass

    # check 2
    if D>C:
        print("Yes")
        exit()
    else:
        pass
    # check 3
    check = S[A:C-1]
    cnt = 0
    for i in check:
        if i == ".":
            cnt += 1
        else:
            cnt = 0

        if cnt == 3:
            print("Yes")
            exit()
    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())
    # check 1
    check = S[B:D-1]
    flg=False
    for i in check:
        if i=="#":
            if flg:
                print("No")
                exit()
            else:
                flg=True
        else:
            if flg:
                flg=False
            else:
                pass
    # check 2
    if D>C:
        print("Yes")
        exit()
    else:
        pass
    # check 3
    check = S[A:C-1]
    cnt = 0
    for i in check:
        if i == ".":
            cnt += 1
        else:
            cnt = 0

        if cnt == 3:
            print("Yes")
            exit()
    print("No")
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
li=[0]+list(input())
for i in range(1,N-1):
  if li[i]=="#" and li[i+1]=="#":
    li[i-1]="_"
for i in range(2,N-1):
  if li[i-1]=="." and li[i]=="." and li[i+1]==".":
    li[i]="|"
if "_" in li[A:C] or "_" in li[B:D]:
  print("No")
  exit()
if D>C:
  print("Yes")
else:
  if "|" in li[B:D]:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
li=[0]+list(input())
for i in range(1,N-1):
  if li[i]=="#" and li[i+1]=="#":
    li[i-1]="_"
for i in range(1,N-2):
  if li[i]=="." and li[i+1]=="." and li[i+2]==".":
    li[i]="|"
if "_" in li[A:C] or "_" in li[B:D]:
  print("No")
  exit()
if D>C:
  print("Yes")
else:
  if "|" in li[B:D+1]:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
li=[0]+list(input())
for i in range(1,N-1):
  if li[i]=="#" and li[i+1]=="#":
    li[i-1]="_"
if "_" in li[A:C] or "_" in li[B:D]:
  print("No")
  exit()
if D>C:
  print("Yes")
else:
  for i in range(B,D-2):
    if li[i]=="." and li[i+1]=="." and li[i+2]==".":
      print("Yes")
      exit()
  print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
li=[0]+list(input())
for i in range(1,N-1):
  if li[i]=="#" and li[i+1]=="#":
    li[i-1]="_"
if "_" in li[A:C] or "_" in li[B:D]:
  print("No")
  exit()
if D>C:
  print("Yes")
else:
  for i in range(B,D-2):
    if li[i]=="." and li[i+1]=="." and li[i+2]==".":
      print("Yes")
      exit()
    else:
      print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
li=[0]+list(input())
for i in range(1,N-1):
  if li[i]=="#" and li[i+1]=="#":
    li[i-1]="_"
for i in range(1,N-2):
  if li[i]=="." and li[i+1]=="." and li[i+2]==".":
    li[i]="|"
if "_" in li[A:C] or "_" in li[B:D]:
  print("No")
  exit()
if D>C:
  print("Yes")
else:
  if "|" in li[B:D]:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
li=[0]+list(input())
for i in range(1,N-1):
  if li[i]=="#" and li[i+1]=="#":
    li[i-1]="_"
  if li[i-1]=="." and li[i]=="." and li[i+1]==".":
    li[i-1]="|"
if "_" in li[A:C] or "_" in li[B:D]:
  print("No")
  exit()
if D>C:
  print("Yes")
else:
  if "|" in li[B:D]:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
li=[0]+list(input())
for i in range(1,N-1):
  if li[i]=="#" and li[i+1]=="#":
    li[i-1]="_"
  if li[i-1]=="." and li[i]=="." and li[i+1]==".":
    li[i]="|"
if "_" in li[A:C] or "_" in li[B:D]:
  print("No")
  exit()
if D>C:
  print("Yes")
else:
  if "|" in li[B:D]:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
from sys import exit, stdin
N, A, B, C, D = [int(_) for _ in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
if C < D:
    if '##' in S[A:D]:
        print('No')
    else:
        print('Yes')
else:
    if '##' in S[A:C] or '...' not in S[B-1:D+2]:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
from sys import exit, stdin
N, A, B, C, D = [int(_) for _ in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
if C < D:
    if '##' in S[A:D]:
        print('No')
    else:
        print('Yes')
else:
    if '##' in S[A:D] or '...' not in S[B-1:D+2]:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
from sys import exit, stdin
N, A, B, C, D = [int(_) for _ in stdin.readline().rstrip().split()]
S = list(stdin.readline().rstrip())
ia, ib = A-1, B-1
while ib < D:
    if ib+2 > N-1:
        ib += 1
        break
    if S[ib+2] == '.':
        ib += 2
    elif S[ib+1] == '.':
        ib += 1
    else:
        print('No')
        exit()
    if ib + 1 >= D:
        S[ib] = 'B'
        break
if C > D and '...' in ''.join(S[B-1:D+2]):
    print('Yes')
    exit()
while ia < C:
    if ia+2 > N-1:
        ia += 1
        break
    if S[ia+2] == '.' and ia+2 < N:
        ia += 2
    elif S[ia+1] == '.':
        ia += 1
    else:
        print('No')
        exit()
    if ia + 1 >= C:
        break
print('Yes')

Submission status: Wrong Answer

Solution code:
from sys import exit, stdin
N, A, B, C, D = [int(_) for _ in stdin.readline().rstrip().split()]
S = list(stdin.readline().rstrip())
ia, ib = A-1, B-1
while ib < D:
    if ib+2 > N-1:
        ib += 1
        break
    if S[ib+2] == '.':
        ib += 2
    elif S[ib+1] == '.':
        ib += 1
    else:
        print('No')
        exit()
    if ib + 1 >= D:
        S[ib] = 'B'
        break
if C > D and '...' in ''.join(S):
    print('Yes')
    exit()
while ia < C:
    if ia+2 > N-1:
        ia += 1
        break
    if S[ia+2] == '.' and ia+2 < N:
        ia += 2
    elif S[ia+1] == '.':
        ia += 1
    else:
        print('No')
        exit()
    if ia + 1 >= C:
        break
print('Yes')

Submission status: Wrong Answer

Solution code:
import itertools
n,a,b,c,d = map(int,input().split())
s = ["#"] + list(input())
streak = False
for k, g in itertools.groupby(s):
  #print(type(k))
  if k == "." and len(list(g)) >=3:
    streak = True
    break

#まず、Bを動かす。
index_B = b
while True:
  if index_B < d:
    if s[index_B + 1] == ".":
      index_B += 1
      
    elif s[index_B + 1] != "." and s[index_B + 2] == ".":
      index_B += 2

    else:
      print("No")
      exit()
      
  elif index_B > d:
    print("No")
    exit()
    
  else:
    if streak == False:
      s[index_B] = "B"
    
    break
     
index_A = a    
while True:
  if index_A < c:
    if s[index_A + 1] == ".":
      index_A += 1
    
    elif s[index_A + 1] != "." and s[index_A + 2] == ".":
      index_A += 2
    
    else:
      print("No")
      exit()

  elif index_A > c:
    print("No")
    exit()
    
  else:
    break 
    
print("Yes")

Submission status: Wrong Answer

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

if c < d:
    if "##" in s[a:d]:
        print("No")
    else:
        print("Yes")
else:
    if "##" in s[a:c] or "..." not in s[b - 1:d + 1]:
        print("No")
    else:
        print("Yes")