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 math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,A,B,C,D = imn()
S = list(input())

def can_reach(a, b):
    reachable = True
    for i in range(a-1, b-1):
        if S[i] != '#' or S[i+1] != '#': continue
        reachable = False
    return reachable

def takeoverable(a, b):
    cantakeover = False
    for i in range(a-1, b-2):
        if S[i] == '#' or S[i+1] == '#' or S[i+2] == '#': continue
        cantakeover = True
    return cantakeover

ans = True
if not can_reach(A, B) or not can_reach(C, D):
    ans = False
if D < C:
   if not takeoverable(B,D):
       ans = False
print('Yes' if ans else 'No')

Submission status: Wrong Answer

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,A,B,C,D = imn()
S = list(input())

if C < D:
    rock_count = 0
    for i in range(B-1, D):
        if S[i] == '#':
            rock_count += 1
            if rock_count == 2:
                break
        else:
            rock_count = 0
    if rock_count == 2:
        No()
        exit()
    rock_count = 0
    for i in range(A-1, C):
        if S[i] == '#':
            rock_count += 1
            if rock_count == 2:
                break
        else:
            rock_count = 0
    if rock_count == 2:
        No()
    else:
        Yes()
else:
    space_count = 0
    enough_space = False
    rock_count = 0
    reachable = True
    for i in range(B-1, D):
        if S[i] == '.':
            space_count += 1
            rock_count = 0
            if space_count >= 3:
                enough_space = True
        else:
            space_count = 0
            rock_count += 1
            if rock_count == 2:
                break
    if rock_count == 2 or not enough_space:
        No()
        exit()
    rock_count = 0
    for i in range(A-1, C):
        if S[i] == '#' or i == D-1:
            rock_count += 1
            if rock_count == 2:
                break
        else:
            rock_count = 0
    if rock_count == 2:
        No()
    else:
        Yes()

Submission status: Wrong Answer

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N,A,B,C,D = imn()
S = list(input())

if C < D:
    rock_count = 0
    for i in range(B-1, D):
        if S[i] == '#':
            rock_count += 1
            if rock_count == 2:
                break
        else:
            rock_count = 0
    if rock_count == 2:
        No()
        exit()
    rock_count = 0
    for i in range(A-1, C):
        if S[i] == '#':
            rock_count += 1
            if rock_count == 2:
                break
        else:
            rock_count = 0
    if rock_count == 2:
        No()
    else:
        Yes()
else:
    space_count = 0
    enough_space = False
    rock_count = 0
    reachable = True
    for i in range(B-1, D):
        if S[i] == '.':
            space_count += 1
            rock_count = 0
            if space_count >= 3:
                enough_space = True
        else:
            space_count = 0
            rock_count += 1
            if rock_count == 2:
                break
    if rock_count == 2 or not enough_space:
        No()
        exit()
    rock_count = 0
    for i in range(A-1, C):
        if S[i] == '#':
            rock_count += 1
            if rock_count == 2:
                break
        else:
            rock_count = 0
    if rock_count == 2:
        No()
    else:
        Yes()

Submission status: Wrong Answer

Solution code:
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n, a, b, c, d = input_list()
  s = input()
  dp = []
  has_space = False
  if s[c-1] == '#':
    print('No')
    exit(0)
  if s[d-1] == '#':
    print('No')
    exit(0)
  for p in range(n):
    if s[p] == '#' and s[p+1] == '#':
      print('No')
      exit(0)
    if c > d:
      if p+2 > d-1:
        continue
      if b-1 < p < d-1:
        if s[p] == '.' and s[p+1] == '.' and s[p+2] == '.':
          has_space = True
  
  if c > d and has_space is False:
    print('No')
  else:
    print('Yes')
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Submission status: Wrong Answer

Solution code:
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n, a, b, c, d = input_list()
  s = input()
  dp = []
  has_space = False
  if s[c-1] == '#':
    print('No')
    exit(0)
  if s[d-1] == '#':
    print('No')
    exit(0)
  for p in range(n):
    if s[p] == '#' and s[p+1] == '#':
      print('No')
      exit(0)
    if c > d:
      if p < b-1 or p > d-1:
        continue
      if p+2 > d:
        continue
      if s[p] == '.' and s[p+1] == '.' and s[p+2] == '.':
        has_space = True
  
  if c > d and has_space is False:
    print('No')
  else:
    print('Yes')
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Submission status: Wrong Answer

Solution code:
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n, a, b, c, d = input_list()
  s = input()
  dp = []
  has_space = False
  if s[c-1] == '#':
    print('No')
    exit(0)
  if s[d-1] == '#':
    print('No')
    exit(0)
  for p in range(n):
    if s[p] == '#' and s[p+1] == '#':
      print('No')
      exit(0)
    if c > d:
      if p < b or p > d:
        continue
      if p+2 > d:
        continue
      if s[p] == '.' and s[p+1] == '.' and s[p+2] == '.':
        has_space = True
  
  if c > d and has_space is False:
    print('No')
  else:
    print('Yes')
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Submission status: Wrong Answer

Solution code:
def count_section_by_zero(data):
  count = 0
  flg = False
  start = 0
  for i, d in enumerate(data):
    if flg is False and d != 0:
      count += 1
      flg = True
      
    if d == 0:
      flg = False
  return count

def input_list():
  return list(map(int, input().split()))

def input_list_str():
  return list(map(str, input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# 2で割り切れる回数
def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c

# 素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def main():
  n, a, b, c, d = input_list()
  s = input()
  dp = []
  has_space = False
  for p in range(n):
    if s[p] == '#' and s[p+1] == '#':
      print('No')
      exit(0)
    if c > d:
      if p < b or p > d:
        continue
      if p+2 > d:
        continue
      if s[p] == '.' and s[p+1] == '.' and s[p+2] == '.':
        has_space = True
  
  if c > d and has_space is False:
    print('No')
  else:
    print('Yes')
  
import math
import fractions
import collections
import itertools
from functools import reduce
main()

Submission status: Wrong Answer

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

A -= 1
B -= 1
C -= 1
D -= 1


def can_reach(start, end):
    for i in range(start, end + 2):
        if S[i] == '#' and S[i + 1] == '#':
            return False
    return True


if not can_reach(A, C) or not can_reach(B, D):
    print("No")
    exit()

if C > D:
    cover = False
    for i in range(B, D + 1):
        if S[i - 1] == '.' and S[i] == '.' and S[i + 1] == '.':
            cover = True
    if not cover:
        print("No")
        exit()


print("Yes")

Submission status: Wrong Answer

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



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

elif c == d:
    print("No")

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

Submission status: Wrong Answer

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



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

elif c == d:
    print("No")

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

Submission status: Wrong Answer

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


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

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

Submission status: Wrong Answer

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


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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(str(input()))
a -= 1
b -= 1
c -= 1
d -= 1
flag = False

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

else:
    for i in range(b, c-1):
        if s[i] == "#" and s[i + 1] == "#":
            print("No")
            exit()
        else:
            if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
                flag = True
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(str(input()))
a -= 1
b -= 1
c -= 1
d -= 1
flag = False

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

else:
    for i in range(a, c-1):
        if s[i] == "#" and s[i + 1] == "#":
            print("No")
            exit()
        else:
            if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
                flag = True
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(str(input()))
a -= 1
b -= 1
c -= 1
d -= 1
flag = False

if c < d:
    for i in range(b, d-1):
        if s[i] == "#" and s[i+1] == "#":
            print("No")
            exit()
    print("Yes")
    exit()

else:
    for i in range(a, c-1):
        if s[i] == "#" and s[i + 1] == "#":
            print("No")
            exit()
        else:
            if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
                flag = True
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# Problem A - Kenken Race

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

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

Submission status: Wrong Answer

Solution code:
# Problem A - Kenken Race

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

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

Submission status: Wrong Answer

Solution code:
# Problem A - Kenken Race

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

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

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, sys.stdin.readline().split())
s = sys.stdin.readline().rstrip()

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

if can_reach(a, c) and can_reach(b, d):
    if c < d:
        print('Yes')
    else:
        flag = False
        for i in range(b, d):
            if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
                flag = True
        print('Yes' if flag else 'No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, sys.stdin.readline().split())
s = sys.stdin.readline().rstrip()

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

if can_reach(a, c) and can_reach(b, d):
    if c < d:
        print('Yes')
    else:
        flag = False
        for i in range(b, d):
            if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
                flag = True
        print('Yes' if flag else 'No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, sys.stdin.readline().split())
s = sys.stdin.readline().rstrip()

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

if can_reach(a, c) and can_reach(b, d):
    if c < d:
        print('Yes')
    else:
        flag = False
        for i in range(b, d-1):
            if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
                flag = True
        print('Yes' if flag else 'No')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, sys.stdin.readline().split())
s = sys.stdin.readline().rstrip()

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

if can_reach(a, c) and can_reach(b, d):
    if c < d:
        print('Yes')
    else:
        flag = False
        for i in range(b, d):
            if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
                flag = True
        print('Yes' if flag else 'No')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if "##" in s[a:c] or "##" in s[b:d]:
    print("No")
    exit()
f = False
if c < d:
    print("Yes")
else:
    if "..." in s[b:c]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, A, B, C, D = map(int, input().split(' '))
A -= 1
B -= 1
C -= 1
D -= 1


S = input()
if S[A:C+1].count('##') or S[B:D+1].count('##'):
    print('No')
    exit(0)

if C > D:
    if not S[B: D+2].count('...'):
        print('No')
        exit(0)

print('Yes')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, A, B, C, D = map(int, input().split(' '))
A -= 1
B -= 1
C -= 1
D -= 1


S = input()
if S.count('##'):
    print('No')
    exit(0)


if A < B and C > D:
    if S[B: D].count('...'):
        print('Yes')

    else:
        print('No')

    exit(0)


print('Yes')

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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