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: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    if (len(S)>a_index and len(S) > b_index)==False:
        return -1
    if S[a_index]=='#' or S[a_index]=='B':
        return 0
    elif S[b_index]=='#' or S[b_index]=='A':
        return 0
    if a_index==g_a and b_index==g_b:
        return 100
    S[before_a] = '.'
    S[before_b] = '.'

    S[a_index] = 'A'
    S[b_index] = 'B'
    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    if len(S)>a_index:
        rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    if len(S)-1>a_index:
        rr2 =  move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    if len(S)>b_index:
        rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    if len(S)-1>b_index:
        rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    return max([rr1,rr2,rr3,rr4])
#    return 1

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

S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

a_index = A-1
b_index = B-1

if len(S)>a_index:
    r1 = move(S, a_index, b_index, a_index+1, b_index, C-1, D-1)
if len(S)-1>a_index:
    r2 = move(S, a_index, b_index, a_index+2, b_index, C-1, D-1)
if len(S)>b_index:
    r3 = move(S, a_index, b_index, a_index, b_index+1, C-1, D-1)
if len(S)-1>b_index:
    r4 = move(S, a_index, b_index, a_index, b_index+2, C-1, D-1)


if r1==100 or r2==100 or r3==100 or r4==100:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import sys
rr = lambda: sys.stdin.readline().strip()
rri = lambda: int(rr())
rrs = lambda: [int(_) for _ in rr().split()]

N, A_, B_, C_, D_ = rrs()
A, B, C, D = [i-1 for i in [A_, B_, C_, D_]]
S = rr()

for i in range(1, N):
	if S[i] == '#' and S[i-1] == '#':
		print('No')
		sys.exit()

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

if S[B-1] == '.' and S[B+1] == '.':
	print('Yes')
	sys.exit()

if S[B+1] == '.' and S[B+2] == '.':
	print('Yes')
	sys.exit()

if B == D - 1:
	print('Yes')
        sys.exit()

for i in range(B, D-1):
	if S[i] == '#':
		if S[i+1] == '.' and S[i+2] == '.' and S[i+3] == '.':
			print('Yes')
			sys.exit()

print('No')
sys.exit()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    if (len(S)>a_index and len(S) > b_index)==False:
        return -1
    if S[a_index]=='#' or S[a_index]=='B':
        return 0
    elif S[b_index]=='#' or S[b_index]=='A':
        return 0
    if a_index==g_a and b_index==g_b:
        return 100
    S[before_a] = '.'
    S[before_b] = '.'

    S[a_index] = 'A'
    S[b_index] = 'B'
    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    if len(S)>a_index:
        rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    if len(S)-1>a_index:
        rr2 =  move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    if len(S)>b_index:
        rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    if len(S)-1>b_index:
        rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    return max([rr1,rr2,rr3,rr4])
#    return 1

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

S = list(input())

S[A-1] = 'A'
S[B-1] = 'B'

a_index = A-1
b_index = B-1

r1 = move(S, a_index, b_index, a_index+1, b_index, C-1, D-1)
r2 = move(S, a_index, b_index, a_index+2, b_index, C-1, D-1)
r3 = move(S, a_index, b_index, a_index, b_index+1, C-1, D-1)
r4 = move(S, a_index, b_index, a_index, b_index+2, C-1, D-1)


if r1==100 or r2==100 or r3==100 or r4==100:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
N,A,B,C,D = map(int, input().split())
s = input()
index = [(n+1) for n, v in enumerate(s) if s[n:n+3] == "..."]

if s.count("##")>=1:
    print("No")
    exit()

if C < D:
    print("Yes")

elif C > D:
    if len(index)>=1:
        for i in index:
            if A <= i and B <= i+1 and i+2<=C and i+1<=D:
                print("Yes")
                exit()
        priny("No")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def solve(s, a, b, c, d):
    if s[d] == '#' or s[c] == '#' or c == d:
        return False
    else:
        def move_a():
            nonlocal a, b
            if s[a + 1] == 46 and b != a + 1:
                a += 1
            elif s[a + 2] == 46 and b != a + 2:
                a += 2
            elif a + 1 == b:
                if move_b():
                    a += 1
                else:
                    return False
            elif a + 2 == b:
                if move_b():
                    a += 2
                else:
                    return False
            else:
                return False
            return True

        def move_b():
            nonlocal a, b
            if s[b + 1] == 46:
                b += 1
                return True
            if s[b + 2] == 46:
                b += 2
                return True
            return False

        if c < d:
            while b < d:
                if not move_b():
                    return False
            if b != d:
                return False
            while a < c:
                if not move_a():
                    return False
            return True
        else:
            while a < c:
                if not move_a():
                    return False
            if b > d:
                return False
            while b < d:
                if not move_b():
                    return False
            return True


def solve_slow(s, a, b, c, d):
    if a == c and b == d:
        return True
    if a > c or b > d:
        return False
    if s[a + 1] == 46 and a + 1 != b:
        if solve_slow(s, a+1, b, c, d):
            return True
    if s[a + 2] == 46 and a + 2 != b:
        if solve_slow(s, a+2, b, c, d):
            return True
    if s[b + 1] == 46 and b + 1 != a:
        if solve_slow(s, a, b + 1, c, d):
            return True
    if s[b + 2] == 46 and b + 2 != a:
        if solve_slow(s, a, b + 2, c, d):
            return True
    return False


def main():
    n, a, b, c, d = read_int_array()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = read() + b'###'
    if solve_slow(s, a, b, c, d):
        print("YES")
    else:
        print("NO")
    # sl, fst = solve_slow(s, a, b, c, d), solve(s, a, b, c, d)
    # print(sl, fst)

def gen_str(opts, n):
    import random
    str = []
    for _ in range(n):
        str.append(opts[random.randrange(0, len(opts))])
    return ''.join(str)


def main2():
    import random
    import itertools
    for _ in range(1000000):
        while True:
            n = random.randint(4, 15)
            a = random.randint(0, n-3)
            b = random.randint(a+1, n-2)
            c = random.randint(a+1, n-1)
            d = random.randint(b+1, n-1)
            if not(a < b and a < c and b < d):
                continue
            s = gen_str('.#', n) + '###'
            if s[a] != '.' or s[b] != '.' or s[c] != '.' or s[d] != '.':
                continue
            sl, fst = solve_slow(s, a, b, c, d), solve(s, a, b, c, d)
            if sl != fst:
                print(sl, fst, s, a, b, c, d)
            else:
                print(s)
                sys.stdout.flush()
            break





# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")


def read():
    return input()


def read_array(sep=None, maxsplit=-1):
    return read().split(sep, maxsplit)


def read_int():
    return int(read())


def read_int_array(sep=None, maxsplit=-1):
    return [int(a) for a in read_array(sep, maxsplit)]

# endregion

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
x = input().split()
s = input()
n = int(x[0])
a = int(x[1])
b = int(x[2])
c = int(x[3])
d = int(x[4])
 
 
kome_flag = False
santen_flag = False
 
b_s = s[a:]
 
if '...' in b_s:
  santen_flag = True
if not '##' in b_s:
  kome_flag = True
    
if not '#' in b_s:
  print('Yes')
else:
  if c < d:
  	if kome_flag:
    	print('Yes')
  	else:
    	print('No')
 
	if d < c:
  		if kome_flag and santen_flag:
    		print('Yes')
  		else:
    		print('No')

Submission status: Runtime Error

Solution code:
import copy


def check(road, s_pos, f_pos, c, d):
    if s_pos == c and f_pos == d:
        return True

    if s_pos == f_pos or (road[s_pos] > 0 and s_pos != c) or (road[f_pos] > 0 and f_pos != d):
        return False

    if s_pos == c:
        return check(road, s_pos, f_pos + 1, c, d) or check(road, s_pos, f_pos + 2, c, d)
    elif f_pos == d:
        return check(road, s_pos + 1, f_pos, c, d) or check(road, s_pos + 2, f_pos, c, d)
    else:
        return check(road, s_pos, f_pos + 1, c, d) or check(road, s_pos, f_pos + 2, c, d) \
               or check(road, s_pos + 1, f_pos, c, d) or check(road, s_pos + 2, f_pos, c, d)


def convert(s):
    if s == '#':
        return 1
    else:
        return 0


def calc():
    n, a, b, c, d = [int(i) for i in input().split()]
    s = input()
    s_n = [convert(s[i]) for i in range(len(s))]

    if check(s_n, a - 1, b - 1, c - 1, d - 1):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    calc()

Submission status: Runtime Error

Solution code:
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum) 
 
flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if ((cumsum[i+2] - cumsum[i]) == 2) and (j+2 <= D):
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3]:
        flag_oinuki = True
 
if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
line = input().split()
object_ = input()

N = int(line[0])
A = int(line[1])-1
B = int(line[2])-1
C = int(line[3])-1
D = int(line[4])-1

placing_objects = [True if s == '#' else False for s in list(object_)]

def main():
    if (A < B and C < D) or (A > B and C > D):
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1]:
                print('No')
                return
        print('Yes')
        return
    elif (A > C) or (B > D):
        print('No')
        return
    else:
        possible_trans = False
        trans_index = -1
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1]:
                print('No')
                return
            if i < N-2 and (not placing_objects[i]) and (not placing_objects[i+1]) and (not placing_objects[i+2]):
                possible_trans = True
                trans_index = i+1
        if not possible_trans:
            if C < D:
                if placing_objects[C-1] or placing_objects[C+1]:
                    print('No')
                    return
            else:
                if placing_objects[D-1] or placing_objects[D+1]:
                    print('No')
                    return
        else:
            if A > B:
                if A > trans_index[0]:
                    print('No')
                    return
            else:
                if B > trans_index[0]:
                    print('No')
                    return
        print('Yes')
        
main()

Submission status: Runtime Error

Solution code:
def available(start, end, S, step=None):
    if step is not None:    #   追い越し処理
        S = S[:step] + "#" + S[step+1:]
    for i in range(start, end):
        if S[i] == "#" and S[i+1] == "#":
            return False
    return True, S
    
def overtake(start, end, S):
    for i in range(start, end+1):
        if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
            step = i
            return True, step
    return False, None

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

if D > C:   #   追い越しが不要な時
    judge1, S = available(A, C, S)
    judge2, S = available(B, D, S)
    if judge1 and judge2:
        print("Yes")
    else:
        print("No")
else:   #   追い越しが必要な時
    overtakable, step = overtake(B, D, S)
    if overtakable:   #   追い越しが可能な時
        judge1, S = available(B, D, S)
        judge2, S = available(A, C, S, step=step)
        if judge1 and judge2:
            print("Yes")
        else:
            print("No")
    else:   #   追い越しができない時
        print("No")

Submission status: Runtime Error

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
if '##' in s:
    flg = False
if c < d:
    #最後まで動かす
    flg = True
else:#c>d
    if '...' in s[a:]:
        flg = True
if flg:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
x = input().split()
s = input()
n = int(x[0])
a = int(x[1])
b = int(x[2])
c = int(x[3])
d = int(x[4])


kome_flag = False
santen_flag = False

b_s = s[a:]

if '...' in b_s:
  santen_flag = True
if not '##' in b_s:
  kome_flag = True
    
if not '#' in b_s:
  print('Yes')
else:
  if c < d:
  	if kome_flag:
    	print('Yes')
  	else:
    	print('No')

	if d < c:
  		if kome_flag and santen_flag:
    		print('Yes')
  		else:
    		print('No')
    
if not '#' in b_s:

Submission status: Runtime Error

Solution code:
from collections import deque

N, A, B, C, D = map(int, input().split(' '))
S = input()
blocks = [i+1 for i, s in enumerate([s for s in S]) if s == '#']
flag = False
check_set = set()

que = deque([(A, B)])
while que:
    A, B = que.pop()
    check_list.add((A, B))
    if A == C and B == D:
        flag = True
        break
    for i in range(3):
        for j in range(3):
            if i == j == 0:
                continue
            if A+i <= C and B+j <= D and A+i != B+j and (A+i) not in blocks and (B+j) not in blocks:
                if (A+i, B+j) not in check_set:
                    que.append((A+i, B+j))

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

Submission status: Runtime Error

Solution code:
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum) 
 
flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if ((cumsum[i+2] - cumsum[i]) == 2) and (j+2 <= D):
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3]:
        flag_oinuki = True
 
if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum) 
 
flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if ((cumsum[i+2] - cumsum[i]) == 2) and (j+2 <= D):
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3]:
        flag_oinuki = True
 
if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
n , a , b , c , d = map(int,input().split())
mas = input()
tmp = ""
tmp2 = ""
while True :
    if mas[b+1] == '.':
    #    mas[b+1].replace(mas[b+1], 'B')
    elif mas[b] == '.':
    #    mas[b].replace(mas[b], 'B') 
print(mas)

Submission status: Runtime Error

Solution code:
line = input().split()
object_ = input()

N = int(line[0])
A = int(line[1])-1
B = int(line[2])-1
C = int(line[3])-1
D = int(line[4])-1

placing_objects = [True if s == '#' else False for s in list(object_)]

def main():
    if (A < B and C < D) or (A > B and C > D):
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1]:
                print('No')
                return
        print('Yes')
        return
    elif A > C or B > D:
        print('No')
        return
    else:
        possible_trans = False
        trans_index = -1
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1]:
                print('No')
                return
            if i < N-2 and (not placing_objects[i]) and (not placing_objects[i+1]) and (not placing_objects[i+2]):
                possible_trans = True
                trans_index = i+1
        if not possible_trans:
            if C < D:
                if placing_objects[C-1] or placing_objects[C+1]:
                    print('No')
                    return
            else:
                if placing_objects[D-1] or placing_objects[D+1]:
                    print('No')
                    return
        else:
            if A > B:
                if A > trans_index[0]:
                    print('No')
                    return
            else:
                if B > trans_index[0]:
                    print('No')
                    return
        print('Yes')
        
main()

Submission status: Runtime Error

Solution code:

def available(start, end, S, step=None):
    if step is not None:    #   追い越し処理
        S = S[:step] + "#" + S[step+1:]
    for i in range(start, end):
        if S[i] == "#" and S[i+1] == "#":
            return False
    return True, S
    
def overtake(start, end, S):
    for i in range(start, end+1):
        if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
            step = i
            return True, step
    return False, None

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

if D > C:   #   追い越しが不要な時
    judge1, S = available(A, C, S)
    judge2, S = available(B, D, S)
    if judge1 and judge2:
        print("Yes")
    else:
        print("No")
else:   #   追い越しが必要な時
    overtakable, step = overtake(B, D, S)
    if overtakable:   #   追い越しが可能な時
        judge1, S = available(B, D, S)
        judge2, S = available(A, C, S, step=step)
        if judge1 and judge2:
            print("Yes")
        else:
            print("No")
    else:   #   追い越しができない時
        print("No")

Submission status: Runtime Error

Solution code:
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum) 
 
flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if cumsum[i+2] - cumsum[i] == 2 and j+2 <= D:
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3]:
        flag_oinuki = True
 
if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum) 

flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if ((cumsum[i+2] - cumsum[i]) == 2) and (j+2 <= D):
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3]:
        flag_oinuki = True

if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")
提出情報

Submission status: Runtime Error

Solution code:
box_num, a_start, b_start, a_end, b_end = map(int, input().split())
box = input()
a_now = a_start
b_now = b_start

def a_one(a_now, b_now):
    a_now += 1

    if(a_now > a_end or b_now > b_end):
        a_now = 999999
        b_now = 999999
        return a_now, b_now
    if(a_now == a_end and b_now == b_end):
        print("Yes")
        exit()
    if(box[a_now-1] == '#' or a_now == b_now):
        a_now = 999999
        b_now = 999999
        return a_now, b_now

    a_one(a_now, b_now)
    a_two(a_now, b_now)
    b_one(a_now, b_now)
    b_two(a_now, b_now)

def a_two(a_now, b_now):
    a_now += 2

    if(a_now > a_end or b_now > b_end):
        a_now = 999999
        b_now = 999999
        return a_now, b_now
    if(a_now == a_end and b_now == b_end):
        print("Yes")
        exit()
    if(box[a_now-1] == '#' or a_now == b_now):
        a_now = 999999
        b_now = 999999
        return a_now, b_now

    a_one(a_now, b_now)
    a_two(a_now, b_now)
    b_one(a_now, b_now)
    b_two(a_now, b_now)

def b_one(a_now, b_now):
    b_now += 1

    if(a_now > a_end or b_now > b_end):
        a_now = 999999
        b_now = 999999
        return a_now, b_now
    if(a_now == a_end and b_now == b_end):
        print("Yes")
        exit()
    if(box[b_now-1] == '#' or a_now == b_now):
        a_now = 999999
        b_now = 999999
        return a_now, b_now

    a_one(a_now, b_now)
    a_two(a_now, b_now)
    b_one(a_now, b_now)
    b_two(a_now, b_now)

def b_two(a_now, b_now):
    b_now += 2

    if(a_now > a_end or b_now > b_end):
        a_now = 999999
        b_now = 999999
        return a_now, b_now
    if(a_now == a_end and b_now == b_end):
        print("Yes")
        exit()
    if(box[b_now-1] == '#' or a_now == b_now):
        a_now = 999999
        b_now = 999999
        return a_now, b_now

    a_one(a_now, b_now)
    a_two(a_now, b_now)
    b_one(a_now, b_now)
    b_two(a_now, b_now)

a_one(a_now, b_now)
a_two(a_now, b_now)
b_one(a_now, b_now)
b_two(a_now, b_now)

print("No")

Submission status: Runtime Error

Solution code:
if "##" in S[A-1:C]:
	print("No")
elif "##" in S[B-1:D]:
	print("No")
elif D < C:	# A jumps over B
	if not "..." in S[B-2:D+1]:
		print("No")
	else:
		print("Yes")
else:
	print("Yes")

Submission status: Runtime Error

Solution code:
# coding: UTF-8
# sample code

v = list(map(int, input().split()))
n, a, b, c, d = v[0], v[1], v[2], v[3], v[4]
s = input()

ac_cnt_1, ac_max_1 = 0, 0
bd_cnt_1, bd_max_1 = 0, 0
bd_cnt_0, bd_max_0 = 0, 0

s_tmp = ''
for i in range(n):
	if i+1 == b:
		s_tmp += '#'
	else:
		s_tmp = s[i]
for i in range(c-a):
	if s_tmp[i+a-1] == '#':
		ac_cnt_1 += 1
		if ac_max_1 < ac_cnt_1:
			ac_max_1 = ac_cnt_1
	else:
		ac_cnt_1 = 0
for i in range(d-b):
	if s[i+b-1] == '#':
		bd_cnt_0 = 0
		bd_cnt_1 += 1
		if bd_max_1 < bd_cnt_1:
			bd_max_1 = bd_cnt_1
	else:
		bd_cnt_0 += 1
		bd_cnt_1 = 0
		if bd_max_0 < bd_cnt_0:
			bd_max_0 = bd_cnt_0
if c < b:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1):
		print('Yes')
	else:
		print('No')
elif c < d:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1):
		print('Yes')
	else:
		print('No')
else:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1) and (bd_max_0 >= 3):
		print('Yes')
	else:
		print('No')

Submission status: Runtime Error

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

temp=str(input())
maxim=max(a,b)
if temp[maxim:].count("...")!=0 or temp[maxim+1]==temp[maxim+2]=="." or temp[maxim+1]==temp[maxim-1]==".":
    flag=1
else:
    flag=0
    
s=list(temp)
s[a]="A"
s[b]="B"
s[c]="C"
s[d]="D"

ans=1

for i in range(n-1):
    if s[i]==s[i+1]=="#":
        ans=0
        

if c<d and ans=1:
    ans=1
elif c>d and ans=1:
    if flag==1:
        ans=1
    elif s[d-1]=="#" or s[d+1]=="#":
        ans=0
    else:
        ans=1
                
if ans==1:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

def obs(st,end):
  for i in range(st,end):
  	if S[i] is "#" and S[i+1] is "#": return True
  return False

if obs(B,D) or obs(A,C):
  print("No")
elif C > D:
  b = False
  for i in range(B-1,max(D,N-2)):
    if S[i] is "." and S[i+1] is "." and S[i+2] is ".":
      b = True
      break
  if b:
    print("Yes")
  else:
    print("No")
else:
  print("Yes")

Submission status: Runtime Error

Solution code:
import sys
N, A, B, C, D = map(int, input().split())
S = input()
skip = 0
for i in range(max(C,D-2)):
	if i >= min(A,B-1) and S[i]==S[i+1]=="#":
		print('No')
		sys.exit()
	if B-1 <= i < max(C,D)-3 and S[i]==S[i+1]==S[i+2]==".":
		skip += 1
	if i == B-1 and S[i-1]==S[i+1]==".":
		skip += 1

if C<D:
	print('Yes')

elif skip > 0:
	print("Yes")
else:
	print('No')

Submission status: Runtime Error

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
Start = max(A,B)
Start2 = min(A,B)
mas1 = max(A,B)
mas2 = min(A,B)
ans = 0
out = 0
Nocount = 0
for i in range(mas1,N):
  if out == 1:
      print("No")
      Nocount += 1
      out = 0
      break
  else:
    if mas1 == D:
        ans += 1
        break
    else:
      if S[i+1] == ".":
        if S[i+2] == ".":
            mas1 += 2
        else:
            mas1 += 1
      else:
        if S[i+2] == ".":
            mas1 += 2
        else:
            out += 1
for j in range(mas2,N):
    if out == 1:
        if Nocount == 1:
            break
        else:
            print("No")
            break
    else:
      if mas2 == C:
        ans += 1
        break
      else:
        if S[j+1] == ".":
          if S[j+2] == ".":
            mas2 += 2
          else:
            mas2 += 1
        else:
          if S[j+2] == ".":
            mas2 += 2
          else:
            out += 1
if ans == 2:
    print("Yes")

Submission status: Runtime Error

Solution code:
def main():
    n,a,b,c,d=map(int,input().split(' '))
    s=input()
    result = 'Yes'
    if a<b<d<c:
        tmp =0
        cnt=0
        for i in range(b-2,d+1):
            if s[i]=='#'and s[i+1]=='#':
                raise NameError
                break
            if s[i]=='.':
                tmp +=1
            else:
                if cnt < tmp:
                    cnt = tmp
                    tmp =0

        if max(cnt,tmp) < 3:
                raise NameError
        if result =='Yes':
            for i in range(a,c-1):
                if s[i]=='#'and s[i+1]=='#':
                    result='No'
    else:
        for i in range(b,d-1):
            if s[i] =='#' and s[i+1]=='#':
                result ='No'
                break
        if result=='Yes':
            for i in range(a,c-1):
                if s[i] =='#' and s[i+1]=='#':
                    result = 'No'
    print(result)

main()

Submission status: Runtime Error

Solution code:
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum) 

flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if cumsum[i+2] - cumsum[i] == 2 and j+2 <= D:
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3]:
        flag_oinuki = True

if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
n,a,b,c,d = (int(i) for i in input().split())  
s = input()
if c<d:
  if s[a:c+1].count("##")>0 and s[b:d+1].count("##")>0:
    print("No")
  else:
    print("Yes")
else:
  if s[a:c+1].count("##")==0 and s[b:d+1].count("##")==0 and (s[b-1:d+1].count("...")>0 or s[b-1:B+2].count("...")>0):
    print("Yes")
  else:
    print("No")

Submission status: Runtime Error

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

def obs(st,end):
  for i in range(st,end):
  	if S[i] is "#" and S[i+1] is "#": return True
  return False

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

Submission status: Runtime Error

Solution code:
import sys
N, A, B, C, D = map(int, input().split())
S = input()
skip = 0
for i in range(max(C,D-1)):
	if i >= min(A,B-1) and S[i]==S[i+1]=="#":
		print('No')
		sys.exit()
	if B-1 <= i < max(C,D)-3 and S[i]==S[i+1]==S[i+2]==".":
		skip += 1
	if i == B-1 and S[i-1]==S[i+1]==".":
		skip += 1

if C<D:
	print('Yes')

elif skip > 0:
	print("Yes")
else:
	print('No')