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:
n,a,b,c,d = map(int,input().split())
s = input()
cant = 0
sanrenzoku = 0
for i in range(a,d):
    if s[i] == "#":
        if s[i+1] == "#":
            cant = 1
    if c > d:
        if s[i] == ".":
            if s[i+1] == ".":
                if s[i+2] == ".":
                    if i > b-2:
                        if i < d:
                            sanrenzoku = 1

if cant == 1:
    print("No")
elif c > d:
    if sanrenzoku == 0:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")

Submission status: Runtime Error

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

def check_serial(mark, number, start, end):
    ans = False
    i = start
    while i < end:
        for j in range(number):
            if s[i+j] != mark:
                i += j 
                break
            elif j == number-1:
                ans = True
        if ans:
            break
        i += 1
    return ans

ans = False
ans = not check_serial('#', 2, a, c)
if c > d:
    ans = check_serial('.', 3, b, c)
if ans:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
n,a,b,c,d=map(int, input().split())
s=input()
v=0
x=0
for i in range(n-2):
    if c<d:
        if i>b and i<d and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break

    
    elif c>d:
        if  i>=b-1 and i<d+1 and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.' :
            x=1
            break
if c>d and x==0:
    print('No')
            
if x==1:
    for i in range(n-2):
        if i>b and i<c and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break
    if v==0:

Submission status: Runtime Error

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

for s in S:


'''
7 1 2 4 3
....

7 1 3 5 7
.#.#.#.#.#.#

7 1 3 7 5
.#.#.#.#.#.#
'''

#print(S)
iwa_cnt = 0
kusa_cnt = 0
result ='No'
for i,s in enumerate(S[A-1:max(C,D)-1]):
    #print(s)
    #print(i)
    #print(iwa_cnt)
    #print(kusa_cnt)
    if s =='#':
        iwa_cnt +=1
        kusa_cnt = 0
    else:
        #print(s)
        #print(i + A - 1)
        if i + A - 1 > B -1:
            kusa_cnt +=1
        iwa_cnt = 0
    if iwa_cnt == 2 and C > B:
        break
    if kusa_cnt == 1 and C < D:
        result = 'Yes'
    #if kusa_cnt == 2:
    #    result = 'Yes'
    if kusa_cnt == 3 and D <C:
        result = 'Yes'
    if D <C and S[B-2] =='.'and S[B] =='.' and kusa_cnt ==1:
        result = 'Yes'
    if D <C and S[B] =='.'and S[B+1] =='.' and kusa_cnt ==1:
        result = 'Yes'


print(result)



'''
Aの現在地からCまでに...が三つ続いていれば、
そこにCをおける
Cは##がない限り、さきに動かせばいいので、問題ない


'''
#print(N,M)
#print(target)
#print(P)

Submission status: Runtime Error

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

for s in S:


'''
7 1 2 4 3
....

7 1 3 5 7
.#.#.#.#.#.#

7 1 3 7 5
.#.#.#.#.#.#
'''

#print(S)
iwa_cnt = 0
kusa_cnt = 0
result ='No'
for i,s in enumerate(S[A-1:max(C,D)-1]):
    #print(s)
    #print(i)
    #print(iwa_cnt)
    #print(kusa_cnt)
    if s =='#':
        iwa_cnt +=1
        kusa_cnt = 0
    else:
        #print(s)
        #print(i + A - 1)
        if i + A - 1 > B -1:
            kusa_cnt +=1
        iwa_cnt = 0
    if iwa_cnt == 2 and not (C < B):
        break
    if kusa_cnt == 1 and C < D:
        result = 'Yes'
    #if kusa_cnt == 2:
    #    result = 'Yes'
    if kusa_cnt == 3 and D <C:
        result = 'Yes'
    if D <C and S[B-2] =='.'and S[B] =='.' and kusa_cnt ==1:
        result = 'Yes'
    if D <C and S[B] =='.'and S[B+1] =='.' and kusa_cnt ==1:
        result = 'Yes'


print(result)



'''
Aの現在地からCまでに...が三つ続いていれば、
そこにCをおける
Cは##がない限り、さきに動かせばいいので、問題ない


'''
#print(N,M)
#print(target)
#print(P)

Submission status: Runtime Error

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

def main():
    if "##" in s[b:d-2]:
        return "No"
    if "##" in s[c:c-2]:
        return "No"

    if c < d:
        return "Yes"
    
    else:

        if "..." in s[b-2:d-1]:
            return "Yes"
                
        return "No"

print(main())

Submission status: Runtime Error

Solution code:
#include<iostream>
#include<string>
#include<list>
#include<map>
#include<vector>
#include<cmath>
#include<unordered_map>
using namespace std;

using lli = long long int;


int main(void){
	lli N,A,B,C,D;
	cin >> N >> A >> B >> C >> D;
	--A,--B,--C,--D;
	string S;
	cin >> S;
	for (int i = A; i < max(C,D); ++i) {
		if (S.substr(i, 2) == "##") {
			cout << "No" << endl;
			return 0;
		}
	}
	if (D > C) {
		cout << "Yes" << endl;
		return 0;
	}
	auto X=vector<lli>(S.size());
	X[0] = S[0] == '#' ? 0 : 1;
	for (size_t i = 1; i < N; ++i) {
		X[i] = (S[i] == '#') ? 0 : (X[i-1] + 1);
	}
	for (auto i = A; i < D; ++i) {
		if (X[i] >= 3) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Submission status: Runtime Error

Solution code:
out1 = '##'
good1 = '...'
if c<d:
    if out1 in s:
        print("No")
    else:
        print("Yes")

else:
    if out1 in s:
        print("No")
    else:
        if good1 in s:
            if good1 in s[b-1:d-1]:
              print('Yes')
            else:
              print('No')
              
            
        else:
            print("No")

Submission status: Runtime Error

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

flag = 1

def main():
    for i in range(len(s[b:d-2])):
        if s[i:i+2] == "##":
            return "No"
    for i in range(len(s[a:c-2])):
        if s[i:i+2] == "##":
            return "No"

    if c < d:
        return "Yes"
    
    else:

        if s[b-2] == "." and s[b] == ".":
            return "Yes"
        else:
            for i in range(len(s[b:d-3])):
                if s[i:i+3] == "...":
                    return "Yes"
                    
            return "No"

print(main())

Submission status: Runtime Error

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
s_flag = False
can_flag = True
count = 0
max_count = 0
m = max(c, d)
for i in range(d+1):
  if s[i] == '#':
    count = 0
    if s_flag == True:
      can_flag = False
      break

if c > d:
  if s[b-2:d+1].count("...") <= 0:
    can_flag = False
if can_flag == True:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

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

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

if S[A:C] in '##' or S[B:D] in '##':
    print("No")
    exit()
if C > D:
    if S[B:D] in '...':
        print("Yes")
        exit()
    else:
        print("No")
        exit()
print("Yes")

Submission status: Runtime Error

Solution code:
# 2019/06/02
# AtCoder Grand Contest 034 - A

# For the answer:
# 1-1. Search min(ac) and max(abcd)
# 1-2. Search ## between min and max
# 2. Case:B<C, Left of B is . and (. or C), or exist .. -> Yes

# Def 1 : True is "Case No"
def searchRock(in_l, in_r, in_str, in_tg):
    rcflg = False
    for i in range(in_l - 1, in_r - 1): # Change -2 -> -1
        if in_str[i] == in_tg and in_str[i+1] == in_tg:
            rcflg = True
            break
    return rcflg

def searchPlain(in_l, in_r, in_str, in_tg):
    rcflg = False
    for i in range(in_l - 1, in_r - 2): # Change -2 -> -1
        if in_str[i] == in_tg and in_str[i+1] == in_tg and in_str[i+2] == in_tg:
            rcflg = True
            break
    return rcflg

# Input
n, a, b, c, d = map(int, input().split())
s = input()
ans = ""

# 1. Search ##
if c < b:
    # Search between a and c, b and d
    rflg = searchRock(a, c+1, s, "#")
    if rflg == True:
        ans = "No"
    else:
        rflg = searchRock(b, d+1, s, "#")
        if rflg == True:
            ans = "No"

else:
    # Search between a and max(c, d)
    rflg = searchRock(a, max(c, d)+1, s, "#")
    if rflg == True:
        ans = "No"
    
# 2. Check around b
if ans != "No":
    if (b < c and d < c):
        # Case: B < D < C 
        pflg = searchPlain(b-1, d, s, ".")
#        if pflg == False:
#            if s[b-2] == "." and s[b] == ".":
#                ans = "Yes"
#            else:
#                ans = "No"
        else:
            ans = "Yes"
    else:
        ans = "Yes"

# Output
print(ans)

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np

N, A, B , C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = input().strip().translate(str.maketrans({'#': '1', '.': '0'}))
ss = [int(c) for c in S ]

ans = 'Yes'

# 連続して岩があるとき（＝解けない）
for i in range(N - 1):       
    if ss[i] == 1  and ss[i+1] == 1 :
        ans = 'No'

if D > C:
    # 処理内

elif D < C:
    for i in range(D - B):
        i = i + B

        if ss[i-1] == 0 and ss[i] == 0 and ss[i+1] == 0 :
            #　処理なし    
        else :
            ans = 'No'



print(ans)

Submission status: Runtime Error

Solution code:
n,a,b,c,d=map(int, input().split())
s=input()
v=0
for i in range(n-2):
    if c<d:
        if i>a and i<d and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break

    
    elif c>d:
        if i>b and i<c and s[i]=='#' and s[i+1]=='#':
            v+=1
            print('No')
            break
        
        
if c<d and v==0:
    print('Yes')
    
if v==0 and c>d and i>=b-1 and i<d+1 and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.':
    print('Yes')
        break
if V==0:
    print('No')

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np

N, A, B , C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = input().strip().translate(str.maketrans({'#': '1', '.': '0'}))
ss = [int(c) for c in S ]

ans = 'No'

# 3つ以上の空間があれば順序を入れ替えられる
if D > C:
    ans = 'YES'   

elif D < C
    for i in range(D - 2):
        
        if i < B - 1:
            continue
        
        if ss[i] == 0 and ss[i+1] == 0 and ss[i+2] == 0 :
            ans = 'YES'

# 連続して岩があるとき（＝解けない）
for i in range(N - 1):
        
    if ss[i] == 1  and ss[i+1] == 1 :
        ans = 'No'

print(ans)

Submission status: Runtime Error

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

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

if S[C] == '#' or S[D] == '#':
    print("No")
    exit()

if C < B:
    stone = 0
    road = 0
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                print("No")
                exit()
        else:
            road += 1
            stone = 0
    stone = 0
    road = 0
    for i in range(B + 1, D):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                print("No")
                exit()
        else:
            road += 1
            stone = 0
    print("Yes")
    exit()

stone = 0
road = 0
c = False
l = [-1]
ans = False

for i in range(B - 1, D + 2):
    if S[i] == '#':
        stone += 1
        road = 0
        if c:
            l.append(i - 1)
            c = False
        if stone > 1:
            print("No")
            exit()
    else:
        road += 1
        stone = 0
        if road > 2:
            c = True
if C < D:
    S = S[:B] + ['.'] + S[B + 1:]
    stone = 0
    road = 0
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                print("No")
                exit()
        else:
            road += 1
            stone = 0
    ans = True
else:
    stone = 0
    road = 0
    check = True
    # B放置でゴールできるか
    S = S[:B] + ['#'] + S[B + 1:]
    stone = 0
    road = 0
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                check = False
        else:
            road += 1
            stone = 0
    S = S[:B] + ['.'] + S[B + 1:]
    if check:
        ans = True
    # Bがゴールしているとゴールできるか
    stone = 0
    road = 0
    check = True
    S = S[:D] + ['#'] + S[D + 1:]
    stone = 0
    road = 0
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                check = False
        else:
            road += 1
            stone = 0
    if check:
        ans = True
    S = S[:D] + ['.'] + S[D + 1:]

if not ans:
    stone = 0
    road = 0
    if l[-1] >= 0:
        for i in range(A + 1, C):
            if S[i] == '#':
                stone += 1
                road = 0
                if stone > 1:
                    print("No")
                    exit()
            else:
                road += 1
                stone = 0
        ans = True

if ans:
    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 range(B-1:D):
            if s[i-1]=="." and s[i]=="." and s[i+1]==".":
                print("Yes")
                exit()
        print("No")
    else:
        print("No")

Submission status: Runtime Error

Solution code:

if C < D:
    if st[A:C].find('##') >= 0 or st[B:D].find('##') >= 0:
        print('No')
    else:
        print('Yes')
else:
    # Cの方がおおきいケース 入れ替わる
    if st[A:C].find('##') >= 0:
        print('No')
    else:
        fnd = st.find('...', B-1, D+1)
        if fnd >= 0:
            print('Yes')
        else:
            print('No')

Submission status: Runtime Error

Solution code:

def solve(n, a, b, c, d, s):
    def check(sub):
        if '##' in sub:
            return False
        return True

    # check for a
    s_a = s[a - 1:c]
    s_a_1 = s[a-1:c+1]
    state_a = check(s_a)
    if not state_a:
        return 'No'
    s_b = s[b - 1:d]
    s_b_1 = s[b-1:d+1]
    state_b = check(s_b)
    if not state_b:
        return 'No'

    if c < d:
        return 'Yes'
    if c > d:  # can swap?
        if '...' in s_a or '...' in s_a_1:
            if '...' in s_b or '...' in s_b_1:
                return 'Yes'
        else:
            return 'No'

    return 'Yes'


def main():
    n, a, b, c, d, s = input_from_console()
    print(solve(n, a, b, c, d, s))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Runtime Error

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
print("No" if "##" in S else "No" if "..." not in S[B-1.D-1] and C>D else "Yes")

Submission status: Runtime Error

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

Submission status: Runtime Error

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


if a > b:
    a, b, c, d = b, a, d, c

def search(start, goal):
    for i in range(start+1, goal - 2):
        if s[i] + s[i + 1] == '##': return False
    return True


def search3(start, goal):
    for i in range(start, goal -3):
        if s[i] + s[i + 1]+[i+2] == '...': return True
    return False
if c < b:
    if search(a,c) and search(b,d):print('Yes')
    else:print('No')

else:
    if search3(b-1,d+1):print('Yes')
    else:print('No')

Submission status: Runtime Error

Solution code:

def solve(n, a, b, c, d, s):
    def check(sub):
        if '##' in sub:
            return False
        return True

    # check for a
    s_a = s[a - 1:c]
    s_a_1 = s[a - 1:c + 1]
    state_a = check(s_a)
    if not state_a:
        return 'No'
    s_b = s[b - 1:d]
    s_b_1 = s[b - 1:d + 1]
    state_b = check(s_b)
    if not state_b:
        return 'No'

    if c < b:
        return 'Yes'
    if c > d:  # can swap?
        s_b_d = s[b - 1:d + 1]
        if '...' in s_b_d:
            return 'Yes'
        else:
            return 'No'

    return 'Yes'


def main():
    n, a, b, c, d, s = input_from_console()
    print(solve(n, a, b, c, d, s))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Runtime Error

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


if a > b:
    a, b, c, d = b, a, d, c

def search(start, goal):
    for i in range(start+1, goal - 2):
        if s[i] + s[i + 1] == '##': return False
    return True


def search3(start, goal):
    for i in range(start, goal -2):
        if s[i] + s[i + 1]+[i+2] == '...': return True
    return False
if c < b:
    if search(a,c) and search(b,d):print('Yes')
    else:print('No')

else:
    if search3(b-1,d+1):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
 
a_s = s[a:c]
b_s = s[b:d]
 
if c < d:
  santen_flag = True
if d < c:
  if '...' in s[b-1:d]:
    santen_flag = True
  
if not '##' in a_s and 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')
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
 
a_s = s[a-1:c]
b_s = s[b-1:d]

if c < d:
  santen_flag = True
if d < c:
  if '...' in s[b-1:d]:
    santen_flag = True
  
if not '##' in a_s and 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:
from sys import stdin
import numpy as np

N, A, B , C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = input().strip().translate(str.maketrans({'#': '1', '.': '0'}))
ss = [int(c) for c in S ]

ans = 'No'

# 連続して岩があるとき（＝解けない）
for i in range(N - 1):
        
        if ss[i] == 1  and ss[i+1] == 1 :
                ans = 'No'
    print(ans)
    exit

# 岩が連続してないとき
if D > C:
    ans == 'YES'   

else:
    for i in range(N - 2):
        i
        if i <= A:
            continue
        if i <= B:
            continue
        
        if ss[i] == 0 and ss[i+1] == 0 and ss[i+2] == 0 :
                ans = 'YES'

print(ans)
exit

Submission status: Runtime Error

Solution code:
class Kenken():
	def __init__(self,n,a,b,c,d,s):
		self.n = n
		self.a = a-1
		self.b = b-1
		self.c = c-1
		self.d = d-1
		self.s = s
		self.s = self.s[:a-1] + "A" + self.s[a:]
		self.s = self.s[:b-1] + "B" + self.s[b:]

	def str_replace(self,i,k,S):
		if k == 1:
			self.s = self.s[:i] + "." + S + self.s[i+2:]
		else:
			self.s = self.s[:i] + "." + self.s[i+1] + S + self.s[i+3:]

	def check_stone(self,i):
		if i < self.n:
			if self.s[i] == ".":
				return True
		return False

	def check_goal(self):
		if self.a == self.c and self.b == self.d:
			return False
		else:
			return True

	def left(self,target,i):
		if target == "a":
			self.str_replace(self.a,i,"A")
			self.a += i
		else:
			self.str_replace(self.b,i,"B")
			self.b += i
	
	def get_space(self,S):
		if S == "a":
			return self.a
		elif S == "b":
			return self.b
		elif S == "c":
			return self.c
		elif S == "d":
			return self.d

	def print_all(self):
		print(self.s)

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

ken = Kenken(n,a,b,c,d,s)
flag=0
ken.print_all()
while ken.check_goal():
	if (ken.check_stone(ken.get_space("b")+1) and ken.check_stone(ken.get_space("b")-1)) or (ken.get_space("a")+1 == ken.get_space("b") and ken.check_stone(ken.get_space("b")+1)): 
		if ken.check_stone(ken.get_space("a")+1) and ken.get_space("a") != ken.get_space("c"):
			ken.left("a",1)
		elif ken.check_stone(ken.get_space("a")+2) and ken.get_space("a") != ken.get_space("c"):
			ken.left("a",2)
		elif ken.check_stone(ken.get_space("b")+1) and ken.get_space("b") != ken.get_space("d"):
			ken.left("b",1)
		elif ken.check_stone(ken.get_space("b")+2) and ken.get_space("b") != ken.get_space("d"):
			ken.left("b",2)
		else:
			flag=1
			break
	else:
		if ken.check_stone(ken.get_space("b")+1) and ken.get_space("b") != ken.get_space("d"):
			ken.left("b",1)
		elif ken.check_stone(ken.get_space("b")+2) and ken.get_space("b") != ken.get_space("d"):
			ken.left("b",2)
		elif ken.check_stone(ken.get_space("a")+1) and ken.get_space("a") != ken.get_space("c"):
			ken.left("a",1)
		elif ken.check_stone(ken.get_space("a")+2) and ken.get_space("a") != ken.get_space("c"):
			ken.left("a",2)
		else:
			flag=1
			break
	ken.print_all()

if flag == 0:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
7 1class Kenken():
	def __init__(self,n,a,b,c,d,s):
		self.n = n
		self.a = a-1
		self.b = b-1
		self.c = c-1
		self.d = d-1
		self.s = s
		self.s = self.s[:a-1] + "A" + self.s[a:]
		self.s = self.s[:b-1] + "B" + self.s[b:]

	def str_replace(self,i,k,S):
		if k == 1:
			self.s = self.s[:i] + "." + S + self.s[i+2:]
		else:
			self.s = self.s[:i] + "." + self.s[i+1] + S + self.s[i+3:]

	def check_stone(self,i):
		if i < self.n:
			if self.s[i] == ".":
				return True
		return False

	def check_goal(self):
		if self.a == self.c and self.b == self.d:
			return False
		else:
			return True

	def left(self,target,i):
		if target == "a":
			self.str_replace(self.a,i,"A")
			self.a += i
		else:
			self.str_replace(self.b,i,"B")
			self.b += i
	
	def get_space(self,S):
		if S == "a":
			return self.a
		elif S == "b":
			return self.b
		elif S == "c":
			return self.c
		elif S == "d":
			return self.d

	def print_all(self):
		print(self.s)

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

ken = Kenken(n,a,b,c,d,s)
flag=0
while ken.check_goal():
	if (ken.check_stone(ken.get_space("b")+1) and ken.check_stone(ken.get_space("b")-1)) or (ken.get_space("a")+1 == ken.get_space("b") and ken.check_stone(ken.get_space("b")+1)): 
		if ken.check_stone(ken.get_space("a")+1) and ken.get_space("a") != ken.get_space("c"):
			ken.left("a",1)
		elif ken.check_stone(ken.get_space("a")+2) and ken.get_space("a") != ken.get_space("c"):
			ken.left("a",2)
		elif ken.check_stone(ken.get_space("b")+1) and ken.get_space("b") != ken.get_space("d"):
			ken.left("b",1)
		elif ken.check_stone(ken.get_space("b")+2) and ken.get_space("b") != ken.get_space("d"):
			ken.left("b",2)
		else:
			flag=1
			break
	else:
		if ken.check_stone(ken.get_space("b")+1) and ken.get_space("b") != ken.get_space("d"):
			ken.left("b",1)
		elif ken.check_stone(ken.get_space("b")+2) and ken.get_space("b") != ken.get_space("d"):
			ken.left("b",2)
		elif ken.check_stone(ken.get_space("a")+1) and ken.get_space("a") != ken.get_space("c"):
			ken.left("a",1)
		elif ken.check_stone(ken.get_space("a")+2) and ken.get_space("a") != ken.get_space("c"):
			ken.left("a",2)
		else:
			flag=1
			break

if flag == 0:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
n,a,b,c,d = map(int,input().split())
s = input()
a -= 1
b -= 1
c -= 1
d -= 1
truth = [[0 for i in range(n)],[0 for j in range(n)]]

def solve(now,dest):
    for i in  range(now,dest):
        if s[i] == '#' and s[i+1] == '#':
            return False
    return True
if c < d:
    if solve(a,c,0) and solve(b,d,1):
        print('Yes')
    else:
        print('No')

else:
    q = False
    for i in range(b,d):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            q = True
            break
        if s[i-1] == '#' and s[i] == '#':
            print('No')
            exit()
    if q and solve(a,c,0) and solve(b,d,1):
        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)
minim=min(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"

mac=max(c,d)
ans=1

for i in range(minim,mac):
    if s[i]==s[i+1]=="#":
        ans=0


elif c<d and ans==1:
    ans=1
elif c>d and ans==1:
    if flag==1:
        ans=1
    elif d<=len(s)-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:
7 1class Kenken():
	def __init__(self,n,a,b,c,d,s):
		self.n = n
		self.a = a-1
		self.b = b-1
		self.c = c-1
		self.d = d-1
		self.s = s
		self.s = self.s[:a-1] + "A" + self.s[a:]
		self.s = self.s[:b-1] + "B" + self.s[b:]

	def str_replace(self,i,k,S):
		if k == 1:
			self.s = self.s[:i] + "." + S + self.s[i+2:]
		else:
			self.s = self.s[:i] + "." + self.s[i+1] + S + self.s[i+3:]

	def check_stone(self,i):
		if i < self.n:
			if self.s[i] == ".":
				return True
		return False

	def check_goal(self):
		if self.a == self.c and self.b == self.d:
			return False
		else:
			return True

	def left(self,target,i):
		if target == "a":
			self.str_replace(self.a,i,"A")
			self.a += i
		else:
			self.str_replace(self.b,i,"B")
			self.b += i
	
	def get_space(self,S):
		if S == "a":
			return self.a
		elif S == "b":
			return self.b
		elif S == "c":
			return self.c
		elif S == "d":
			return self.d

	def print_all(self):
		print(self.s)

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

ken = Kenken(n,a,b,c,d,s)
flag=0
ken.print_all()
while ken.check_goal():
	if (ken.check_stone(ken.get_space("b")+1) and ken.check_stone(ken.get_space("b")-1)) or (ken.get_space("a")+1 == ken.get_space("b") and ken.check_stone(ken.get_space("b")+1)): 
		if ken.check_stone(ken.get_space("a")+1) and ken.get_space("a") != ken.get_space("c"):
			ken.left("a",1)
		elif ken.check_stone(ken.get_space("a")+2) and ken.get_space("a") != ken.get_space("c"):
			ken.left("a",2)
		elif ken.check_stone(ken.get_space("b")+1) and ken.get_space("b") != ken.get_space("d"):
			ken.left("b",1)
		elif ken.check_stone(ken.get_space("b")+2) and ken.get_space("b") != ken.get_space("d"):
			ken.left("b",2)
		else:
			flag=1
			break
	else:
		if ken.check_stone(ken.get_space("b")+1) and ken.get_space("b") != ken.get_space("d"):
			ken.left("b",1)
		elif ken.check_stone(ken.get_space("b")+2) and ken.get_space("b") != ken.get_space("d"):
			ken.left("b",2)
		elif ken.check_stone(ken.get_space("a")+1) and ken.get_space("a") != ken.get_space("c"):
			ken.left("a",1)
		elif ken.check_stone(ken.get_space("a")+2) and ken.get_space("a") != ken.get_space("c"):
			ken.left("a",2)
		else:
			flag=1
			break

if flag == 0:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
if "##" in:
    print("No")
elif (S[C-2])=="#" and C>D:
    print("No")
elif (S[C])=="#" and C>D:
    print("No")
else:
    print("Yes")

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)
minim=min(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"

mac=max(c,d)
ans=1

for i in range(minim,mac):
    if s[i]==s[i+1]=="#":
        ans=0


elif c<d and ans==1:
    ans=1
elif c>d and ans==1:
    if flag==1:
        ans=1
    elif d==len(s)-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:
# -*- coding: utf-8 -*-

def move(S, before_a, before_b, a_index, b_index, g_a, g_b):
    try:
        if len(S)<=a_index or len(S) <= b_index:
            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
    except:
        return -1


    rr1 = 0
    rr2 = 0
    rr3 = 0
    rr4 = 0
    try:
        S[before_a] = '.'
        S[before_b] = '.'
        S[a_index] = 'A'
        S[b_index] = 'B'
    except:
        return 0
    try:
        rr1 = move(S, a_index, b_index, a_index+1, b_index, g_a, g_b)
    except:
        pass
    try:
        rr2 = move(S, a_index, b_index, a_index+2, b_index, g_a, g_b)
    except:
        pass
    try:
        rr3 = move(S, a_index, b_index, a_index, b_index+1, g_a, g_b)
    except:
        pass
    try:
        rr4 = move(S, a_index, b_index, a_index, b_index+2, g_a, g_b)
    except:
        pass
    return max([rr1,rr2,rr3,rr4])

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 = 0
r2 = 0
r3 = 0
r4 = 0

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


print('No')

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np

N, A, B , C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = input().strip().translate(str.maketrans({'#': '1', '.': '0'}))
ss = [int(c) for c in S ]

ans = 'No'

#より遠いほうを先に処理する。
if D > C:
    ans == 'YES'   
else:

    for i in range(N - 2)
        i
        if i <= A:
            continue
        if i <= B:
            continue
        
        if ss[i] == 0 and ss[i+1] == 0 and ss[i+2] == 0 :
                ans = 'YES'

print(ans)