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:
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, a, b, c, d = MAP()
s = input()

flag = 0
for i in range(min(a,b)+1,max(c,d)):
        if (a < i < c or b < i < d) and s[i] == s[i-1] == '#':
                print("No")
                exit()       
        elif max(a,b) < i < min(c,d)-1 and s[i-1] == s[i] == s[i+1] == '.':
                flag = 1

if c > d and flag == 0:
        print("No")
else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, a, b, c, d = MAP()
s = input()

flag = 0
for i in range(min(a,b)+1,max(c,d)):
        if (a < i < c or b < i < d) and s[i] == s[i-1] == '#':
                print("No")
                exit()       
        elif max(a,b) < i < min(c,d) and s[i-1] == s[i] == s[i+1] == '.':
                flag = 1

if c > d and flag == 0:
        print("No")
else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, a, b, c, d = MAP()
s = input()

flag = 0
for i in range(min(a,b)+1,max(c,d)):
        if s[i] == s[i-1] == '#':
                print("No")
                exit()       
        elif max(a,b) < i < min(c,d) and s[i-1] == s[i] == s[i+1] == '.':
                flag = 1

if c > d and flag == 0:
        print("No")
else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
def iwa_check(start,end):
    for i in range(start,end):
        if s[i] == '#' and s[i+1] == '#':
            return False
    return True

n, a, b, c, d = map(int, input().split())
s = list(input())
s = ['#'] + s + ['#']


# 岩が2個並ぶ
if not iwa_check(a,c) or not iwa_check(b,d):
    print('No')
    exit()

# 追い越す場合
if c > d:
    ok = False
    for i in range(b, d):
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            ok = True
            break
    if not ok:
        print('No')
        exit()

# 追い越さない
print('Yes')

Submission status: Wrong Answer

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

# 岩が2個並ぶ
before = s[0]
for ss in s[1:]:
    if ss == before and ss == '#':
        print('No')
        exit()
    before = ss

# 追い越す場合
if c > d:
    ok = False
    for i in range(b, d):
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            ok = True
            break
    if not ok:
        print('No')
        exit()

# 追い越さない
print('Yes')

Submission status: Wrong Answer

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

# 岩が2個並ぶ
before = s[0]
for ss in s[1:]:
    if ss == before and ss == '#':
        print('No')
        exit()
    before = ss

# 追い越す場合
if c > d:
    new_s = s[:d+1]
    for i in range(b - 1, len(new_s) - 2):
        ss = new_s[i:i + 3]
        # print(ss)
        if len(set(ss)) == 1 and ss[0] == '.':
            print('Yes')
            exit()
    print('No')
# 追い越さない
else:
    print('Yes')

Submission status: Wrong Answer

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

# 岩が2個並ぶ
before = s[0]
for ss in s[1:]:
    if ss == before and ss == '#':
        print('No')
        exit()
    before = ss

# 追い越す場合
if c > d:
    new_s = s[:d]
    for i in range(b,len(new_s) - 2):
        ss = new_s[i:i + 3]
        # print(ss)
        if len(set(ss)) == 1 and ss[0] == '.':
            print('Yes')
            exit()
    print('No')
# 追い越さない
else:
    print('Yes')

Submission status: Wrong Answer

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

# 岩が2個並ぶ
before = s[0]
for ss in s[1:]:
    if ss == before and ss == '#':
        print('No')
        exit()
    before = ss

# 追い越す場合
if c > d:
    new_s = s[:d]
    for i in range(len(new_s) - 2):
        ss = new_s[i:i + 3]
        if len(set(ss)) == 1 and ss[0] == '.':
            print('Yes')
            exit()
    print('No')
# 追い越さない
else:
    print('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()
    for i in range(min(A,B),max(C,D)+1):
        if S[i] == '#' and S[i+1] == '#':
            print('No')
            exit()
    
    if C < D:
        print('Yes')
        exit()
    
    for i in range(B-2,D+2):
        if i + 2 < N:
            if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
                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())
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = input()
    for i in range(min(A,B),max(C,D)):
        if S[i] == '#' and S[i+1] == '#':
            print('No')
            exit()
    
    if C < D:
        print('Yes')
        exit()
    
    for i in range(max(A,B)-1,min(C,D)+1):
        if i + 2 < N:
            if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
                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 = input()
    for i in range(min(A,B),max(C,D)):
        if S[i] == '#' and S[i+1] == '#':
            print('No')
            exit()
    
    if C < D:
        print('Yes')
        exit()
    
    for i in range(max(A,B)-1,min(C,D)+1):
        if i + 2 < N:
            if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
                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 = input()
    for i in range(min(A,B),max(C,D)):
        if S[i] == '#' and S[i+1] == '#':
            print('No')
            exit()
    
    if A > B and C < D:
        print('Yes')
        exit()
    
    for i in range(max(A,B)-1,min(C,D)+1):
        if i + 2 < N:
            if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
                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 = input()

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

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

    if C < D:
        print('Yes')
        exit()

    for i in range(B, D+1):
        if i + 1 < N:
            if S[i-1] == '.' and S[i] == '.' and S[i+1] == '.':
                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 = input()
    for i in range(A,max(C,D)):
        if S[i] == '#' and S[i+1] == '#':
            print('No')
            exit()

    if C < D:
        print('Yes')
        exit()

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

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

    if B > A and D > C:
        print('Yes')
        exit()
    
    for i in range(max(A,B),min(C,D)):
        if i + 2 < N:
            if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
                print('Yes')
                exit()

    print('No')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

if a > b and c > d or a < b and c < d:
  if s[a - 1:c].count('##') + s[b - 1:d].count('##') == 0:
    print('Yes')
  else:
    print('No')
else:
  i, j = (b, d) if a < b else (a, c)
  if s[i - 1:j].count('...'):
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

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

    if("##" in s[a-1:c] or "##" in s[b-1:d]):return 0
    if(d>c):
        return 1
    else:
        if("..." in s[b-1:d+2]):
            return 1
        else:
            return 0

if __name__ == '__main__':
    k=main()
    if(k):
        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:
  tmp=list(s)
  tmp[B-1]="B"
  tmp="".join(tmp)
  c1="##" in tmp[A-1:C] 
  c2="#B" in tmp[A-1:C]
  c3="B#" in tmp[A-1:C]
  if c1:
    print("No")
  elif c2 or c3:
    if "..." in tmp[B-2:D+1]:
      if "##" in tmp[B-1:D]:
        print("No")
      else:
        print("Yes")
    else:
      print("No")
  else:
    if "##" in tmp[B-1:D]:
      print("No")
    else:
      print("Yes")
else:
  c1="##" in s[A-1:C]
  c2="##" in s[B-1:D]
  if c1 or c2:
    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:
  tmp=list(s)
  tmp[B-1]="B"
  tmp="".join(tmp)
  c1="##" in tmp[A-1:C] 
  c2="#B" in tmp[A-1:C]
  c3="B#" in tmp[A-1:C]
  if c1:
    print("No")
  elif c2 or c3:
    if ".." in tmp[B-1:D]:
      if "##" in tmp[B-1:D]:
        print("No")
      else:
        print("Yes")
    else:
      print("No")
  else:
    if "##" in tmp[B-1:D]:
      print("No")
    else:
      print("Yes")
else:
  c1="##" in s[A-1:C]
  c2="##" in s[B-1:D]
  if c1 or c2:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

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

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	n,a,b,c,d = linput()
	S = "_" + input().rstrip()
	
	res = 1
	#if c<d:
	X = S[a:c].count("##")
	X += S[b:d].count("##")
	if X!=0: res=0
	
	if c>d:
		Y = S[b-1:d+1].count("...")
		if Y==0: res=0
	
	sT = "No Yes".split()
	print(sT[res])

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

def linput(ty=int, cvt=list):
	return cvt(map(ty,input().split()))

def gcd(a: int, b: int):
	while b: a, b = b, a%b
	return a

def lcm(a: int, b: int):
	return a * b // gcd(a, b)

def main():
	n,a,b,c,d = linput()
	S = "_" + input().rstrip()
	
	res = 1
	#if c<d:
	X = S[a:c].count("##")
	X += S[b:d].count("##")
	if X!=0: res=0
	
	if c>d:
		Y = S[b:d+1].count("...")
		if Y==0: res=0
	
	sT = "No Yes".split()
	print(sT[res])

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

if '##' in s[a-1:c] or '##' in s[b-1:d]:
    print('No')
else:
    if d<c and '...' not in s[b-1:d]:
        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 '##' in s[a-1:c] or '##' in s[b-1:d]:
        print('No')
    else:
        print('Yes')
else:
    if (('##' in s[a-1:c]) or ('##' in s[b-1:d])) or ('...' not in s[b-1:d]):
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

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

g = groupby(s[a:c])
h = groupby(s[b:d])

for i, j in g:
    if i == "#" and len(list(j)) > 1:
        print("No")
        exit()

for i, j in h:
    if i == "#" and len(list(j)) > 1:
        print("No")
        exit()

if c < d:
    print("Yes")
    exit()

e = groupby(s[b-2:d+2])
for i, j in e:
    if i == "." and len(list(j)) > 2:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

g = groupby(s[a:c])
h = groupby(s[b:d])

for i, j in g:
    if i == "#" and len(list(j)) > 1:
        print("No")
        exit()

for i, j in h:
    if i == "#" and len(list(j)) > 1:
        print("No")
        exit()

if c < d:
    print("Yes")
    exit()

e = groupby(s[b-1:d+1])
for i, j in e:
    if i == "." and len(list(j)) > 2:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

g = groupby(s[a:c])
h = groupby(s[b:d])

for i, j in g:
    if i == "#" and len(list(j)) > 1:
        print("No")
        exit()

for i, j in h:
    if i == "#" and len(list(j)) > 1:
        print("No")
        exit()

if c < d:
    print("Yes")
    exit()

e = groupby(s[b-1:d-1])
for i, j in e:
    if i == "." and len(list(j)) > 2:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

g = groupby(s[a:c])
h = groupby(s[b:d])

for i, j in g:
    if i == "#" and len(list(j)) > 1:
        print("No")
        exit()

for i, j in h:
    if i == "#" and len(list(j)) > 1:
        print("No")
        exit()

if c < d:
    print("Yes")
    exit()

e = groupby(s[b:d])
for i, j in e:
    if i == "." and len(list(j)) > 2:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

g = groupby(s[a+1:c])
h = groupby(s[b+1:d])

for i, j in g:
    if i == "#" and len(list(j)) > 1:
        print("No")
        exit()

for i, j in h:
    if i == "#" and len(list(j)) > 1:
        print("No")
        exit()

if c < d:
    print("Yes")
    exit()

for i, j in h:
    if i == "." and len(list(j)) > 2:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

g = groupby(s[a+1:c])
h = groupby(s[b+1:d])

for i, j in g:
    if i == "#" and len(list(j)) > 1:
        print("No")
        exit()

for i, j in h:
    if i == "#" and len(list(j)) > 1:
        print("No")
        exit()

if c < d:
    print("Yes")
    exit()

e = groupby(s[b+1:c])
for i, j in e:
    if i == "." and len(list(j)) > 2:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

g = groupby(s[a+1:c])
h = groupby(s[b+1:d])

for i, j in g:
    if i == "#" and len(list(j)) > 1:
        print("No")
        exit()

for i, j in h:
    if i == "#" and len(list(j)) > 1:
        print("No")
        exit()

if c < d:
    print("Yes")
    exit()

e = groupby(s[b+1:d])
for i, j in e:
    if i == "." and len(list(j)) > 2:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D=map(int, input().split())
s=input()
if D<C:
  tmp=list(s)
  tmp[B-1]="B"
  tmp="".join(tmp)
  c1="##" in tmp[A-1:C] 
  c2="#B" in tmp[A-1:C]
  c3="B#" in tmp[A-1:C]
  if c1:
    print("No")
  elif c2 or c3:
    if "..." in tmp[B-1:D]:
      if "##" in tmp[B-1:D]:
        print("No")
      else:
        print("Yes")
    else:
      print("No")
  else:
    if "##" in tmp[B-1:D]:
      print("No")
    else:
      print("Yes")
else:
  c1="##" in s[A-1:C]
  c2="##" in s[B-1:D]
  if c1 or c2:
    print("No")
  else:
    print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    if not((A - C < 0) ^ (B - D < 0)):
        sameDire = True

    l = min(A,C)
    r = max(A,C)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < D and D < r:
        cross = True
    if sameDire and  l < D and D < r and  l < B and B < r:
        cross = True

    l = min(B,D)
    r = max(B,D)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < C and C < r:
        cross = True
    if sameDire and  l < C and C < r and  l < A and A < r:
        cross = True

    if cross:
        # ...のチェック範囲
        for i in range(A,N+1):
            if(S[i]=='#' and S[i+1]=='#'):
                r = i
                break
        else:
            #最後が#かは細かく見る必要はない
            r = N
        for i in reversed(range(1,A)):
            if(S[i]=='#' and S[i-1]=='#'):
                l = i
                break
        else:
            #最初が#かは細かく見る必要はない
            l = 0
        if '...' in S[l:r+1]:
            print('Yes')
            return
        print('No')
    else:
        print('Yes')



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    if not((A - C < 0) ^ (B - D < 0)):
        sameDire = True

    l = min(A,C)
    r = max(A,C)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < D and D < r:
        cross = True
    if sameDire and  l < D and D < r and  l < B and B < r:
        cross = True

    l = min(B,D)
    r = max(B,D)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < C and C < r:
        cross = True
    if sameDire and  l < C and C < r and  l < A and A < r:
        cross = True

    if cross:
        # ...のチェック範囲
        for i in range(A,N+1):
            if(S[i]=='#' and S[i+1]=='#'):
                r = i
                break
        else:
            #最後が#かは細かく見る必要はない
            r = N
        for i in reversed(range(1,A)):
            if(S[i]=='#' and S[i-1]=='#'):
                l = i+1
                break
        else:
            #最初が#かは細かく見る必要はない
            l = 0
        if '...' in S[l:r+1]:
            print('Yes')
            return
        print('No')
    else:
        print('Yes')



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    if not((A - C < 0) ^ (B - D < 0)):
        sameDire = True

    l = min(A,C)
    r = max(A,C)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < D and D < r:
        cross = True
    if sameDire and  l < D and D < r and  l < B and B < r:
        cross = True

    l = min(B,D)
    r = max(B,D)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < C and C < r:
        cross = True
    if sameDire and  l < C and C < r and  l < A and A < r:
        cross = True

    if cross:
        # ...のチェック範囲
        for i in range(A,N):
            if(S[i]=='#' and S[i+1]=='#'):
                r = i
                break
        else:
            #最後が#かは細かく見る必要はない
            r = N
        for i in reversed(range(1,N)):
            if(S[i]=='#' and S[i-1]=='#'):
                l = i+1
                break
        else:
            #最初が#かは細かく見る必要はない
            l = 0
        if '...' in S[l:r+1]:
            print('Yes')
            return
        print('No')
    else:
        print('Yes')



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    if not((A - C < 0) ^ (B - D < 0)):
        sameDire = True

    l = min(A,C)
    r = max(A,C)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < D and D < r:
        cross = True
    if sameDire and  l < D and D < r and  l < B and B < r:
        cross = True

    l = min(B,D)
    r = max(B,D)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < C and C < r:
        cross = True
    if sameDire and  l < C and C < r and  l < A and A < r:
        cross = True

    if cross:
        # ...のチェック範囲
        for i in range(A,N):
            if(S[i]=='#' and S[i+1]=='#'):
                r = i-1
                break
        else:
            #最後が#かは細かく見る必要はない
            r = N
        for i in reversed(range(1,N)):
            if(S[i]=='#' and S[i-1]=='#'):
                l = i+1
                break
        else:
            #最初が#かは細かく見る必要はない
            l = 0
        for i in range(l,r-1):
            if(S[i:i+3]=='...'):
                print('Yes')
                return
        print('No')
    else:
        print('Yes')



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    if not((A - C < 0) ^ (B - D < 0)):
        sameDire = True

    l = min(A,C)
    r = max(A,C)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < D and D < r:
        cross = True
    if sameDire and  l < D and D < r and  l < B and B < r:
        cross = True

    l = min(B,D)
    r = max(B,D)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < C and C < r:
        cross = True
    if sameDire and  l < C and C < r and  l < A and A < r:
        cross = True

    if cross:
        # ...のチェック範囲
        for i in range(A,N):
            if(S[i]=='#' and S[i+1]=='#'):
                r = i-1
                break
        else:
            #最後が#かは細かく見る必要はない
            r = N
        for i in reversed(range(1,A)):
            if(S[i]=='#' and S[i-1]=='#'):
                r = i+1
                break
        else:
            #最初が#かは細かく見る必要はない
            l = 0
        for i in range(l,r-1):
            if(S[i:i+3]=='...'):
                print('Yes')
                return
        print('No')
    else:
        print('Yes')



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    if not((A - C < 0) ^ (B - D < 0)):
        sameDire = True

    l = min(A,C)
    r = max(A,C)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < D and D < r:
        cross = True
    if sameDire and  l < D and D < r and  l < B and B < r:
        cross = True

    l = min(B,D)
    r = max(B,D)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < C and C < r:
        cross = True
    if sameDire and  l < C and C < r and  l < A and A < r:
        cross = True

    if cross:
        # ...のチェック範囲
        for i in range(A,N):
            if(S[i]=='#' and S[i+1]=='#'):
                r = i-1
                break
        else:
            #最後が#かは細かく見る必要はない
            r = N
        for i in reversed(range(1,N)):
            if(S[i]=='#' and S[i-1]=='#'):
                r = i+1
                break
        else:
            #最初が#かは細かく見る必要はない
            l = 0
        for i in range(l,r-1):
            if(S[i:i+3]=='...'):
                print('Yes')
                return
        print('No')
    else:
        print('Yes')



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    if not((A - C < 0) ^ (B - D < 0)):
        sameDire = True

    l = min(A,C)
    r = max(A,C)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < D and D < r:
        cross = True
    if sameDire and  l < D and D < r and  l < B and B < r:
        cross = True

    l = min(B,D)
    r = max(B,D)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < C and C < r:
        cross = True
    if sameDire and  l < C and C < r and  l < A and A < r:
        cross = True

    if cross:
        # ...のチェック範囲
        for i in range(A,N):
            if(S[i]=='#' and S[i+1]=='#'):
                r = i-1
                break
        else:
            #最後が#かは細かく見る必要はない
            r = N
        for i in reversed(range(1,N)):
            if(S[i]=='#' and S[i-1]=='#'):
                r = i+1
                break
        else:
            #最初が#かは細かく見る必要はない
            l = 1
        for i in range(l,r-1):
            if(S[i:i+3]=='...'):
                print('Yes')
                return
        print('No')
    else:
        print('Yes')



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    if not((A - C < 0) ^ (B - D < 0)):
        sameDire = True

    l = min(A,C)
    r = max(A,C)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < D and D < r:
        cross = True
    if sameDire and  l < D and D < r and  l < B and B < r:
        cross = True

    l = min(B,D)
    r = max(B,D)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('No')
            return
    if sameDire == False and l < C and C < r:
        cross = True
    if sameDire and  l < C and C < r and  l < A and A < r:
        cross = True

    if cross:
        # ...のチェック範囲
        for i in range(A,N):
            if(S[i]=='#' and S[i+1]=='#'):
                r = i-1
                break
        else:
            #最後が#かは細かく見る必要はない
            r = N
        for i in reversed(range(1,N)):
            if(S[i]=='#' and S[i-1]=='#'):
                r = i+1
                break
        else:
            #最初が#かは細かく見る必要はない
            l = 1
        for i in range(l,r-2):
            if(S[i:i+3]=='...'):
                print('Yes')
                return
        print('No')
    else:
        print('Yes')



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

    if not((A - C < 0) ^ (B - D < 0)):
        sameDire = True

    l = min(A,C)
    r = max(A,C)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('NO')
            return
    if sameDire == False and l < D and D < r:
        cross = True
    if sameDire and  l < D and D < r and  l < B and B < r:
        cross = True

    l = min(B,D)
    r = max(B,D)
    for i in range(l,r):
        if(S[i]=='#' and S[i+1]=='#'):
            print('NO')
            return
    if sameDire == False and l < C and C < r:
        cross = True
    if sameDire and  l < C and C < r and  l < A and A < r:
        cross = True

    if cross:
        # ...のチェック範囲
        for i in range(A,N):
            if(S[i]=='#' and S[i+1]=='#'):
                r = i-1
                break
        else:
            #最後が#かは細かく見る必要はない
            r = N
        for i in reversed(range(1,N)):
            if(S[i]=='#' and S[i-1]=='#'):
                r = i+1
                break
        else:
            #最初が#かは細かく見る必要はない
            l = 1
        for i in range(l,r-2):
            if(S[i:i+3]=='...'):
                print('YES')
                return
        print('NO')
    else:
        print('YES')



if __name__ == '__main__':
    main()