Problem:


Score : 400 points

Problem Statement

There are N squares arranged in a row, numbered 1, 2, ..., N from left to right.
You are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.

In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.

You can repeat the following operation any number of times:

Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.

You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.

Determine whether this is possible.

Constraints

4 \leq N \leq 200\ 000

S is a string of length N consisting of . and #.

1 \leq A, B, C, D \leq N

Square A, B, C and D do not contain a rock.

A, B, C and D are all different.

A < B

A < C

B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

Print Yes if the objective is achievable, and No if it is not.

Sample Input 1

7 1 3 6 7
.#..#..

Sample Output 1

Yes

The objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)

A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB

Sample Input 2

7 1 3 7 6
.#..#..

Sample Output 2

No

Sample Input 3

15 1 3 15 13
...#.#...#.#...

Sample Output 3

Yes



Sample input:
7 1 3 6 7
.#..#..


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
ans=True
#ゴールの手前の岩が二個以上連続で並ぶとき
#手前のゴールが岩に挟まれているとき
#ぬかせない状況(.が連続する箇所が2つ以下)のとき、Bのゴールの隣に岩がある
#ぬかせないときD<C　

#ぬかせるかどうかのフラグ
trace=False
count=0
flag=False
for i in range(min(C,D)):
    if S[i]==".":
        if flag:
            count+=1
            if count>=3:
                trace=True
                break
        else:
            flag=True
            count=1
    else:
        flag=False
        count=0
#ゴールの手前の岩が二個以上並ぶかどうか
rock1=False
count=0
flag=False
for i in range(max(C,D)):
    if S[i]=="#":
        if flag:
            count+=1
            if count>=2:
                rock1=True
                break
        else:
            flag=True
            count=1
    else:
        flag=False
        count=0
#手前のゴールが岩に挟まれているかどうか
rock2=False
m=min(C,D)
if S[m-2]=="#" and S[m]=="#":
    rock2=True

if not trace:
    if D<C:
        ans=False
if rock1:
    ans=False
if rock2:
    ans=False
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
ans=True
#ゴールの手前の岩が二個以上連続で並ぶとき
#手前のゴールが岩に挟まれているとき
#ぬかせない状況(.が連続する箇所が2つ以下)のとき、Bのゴールの隣に岩がある
#ぬかせないときD<C　

#ぬかせるかどうかのフラグ
trace=False
count=0
flag=False
for i in range(max(C,D)):
    if S[i]==".":
        if flag:
            count+=1
            if count>=3:
                trace=True
                break
        else:
            flag=True
            count=1
    else:
        flag=False
        count=0
#ゴールの手前の岩が二個以上並ぶかどうか
rock1=False
count=0
flag=False
for i in range(max(C,D)):
    if S[i]=="#":
        if flag:
            count+=1
            if count>=2:
                rock1=True
                break
        else:
            flag=True
            count=1
    else:
        flag=False
        count=0
#手前のゴールが岩に挟まれているかどうか
rock2=False
m=min(C,D)
if S[m-2]=="#" and S[m]=="#":
    rock2=True

if not trace:
    if D<C:
        ans=False
if rock1:
    ans=False
if rock2:
    ans=False
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
ans=True
#ゴールの手前の岩が二個以上連続で並ぶとき
#手前のゴールが岩に挟まれているとき
#ぬかせない状況(.が連続する箇所が2つ以下)のとき、Bのゴールの隣に岩がある
#ぬかせないときD<C　

#ぬかせるかどうかのフラグ
trace=False
count=0
flag=False
for i in range(N):
    if S[i]==".":
        if flag:
            count+=1
            if count>=3:
                trace=True
                break
        else:
            flag=True
            count=1
    else:
        flag=False
        count=0
#ゴールの手前の岩が二個以上並ぶかどうか
rock1=False
count=0
flag=False
for i in range(max(C,D)):
    if S[i]=="#":
        if flag:
            count+=1
            if count>=2:
                rock1=True
                break
        else:
            flag=True
            count=1
    else:
        flag=False
        count=0
#手前のゴールが岩に挟まれているかどうか
rock2=False
m=min(C,D)
if S[m-2]=="#" and S[m]=="#":
    rock2=True

if not trace:
    if D<C:
        ans=False
if rock1:
    ans=False
if rock2:
    ans=False
if ans:
    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 = input()

# initialization
is_ok = True

# search
if C>D:
    # b check
    if "##" in S[B-1:D] or not "..." in S[B-2:D]:
        is_ok = False

    # a check
    if "##" in S[A-1:C]:
        is_ok = False
else:
    # b check
    if "##" in S[B-1:D]:
        is_ok = False

    # a check
    if "##" in S[A-1:C]:
        is_ok = False

# 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 = input()

# initialization
is_ok = True

# search
if C>D:
    # b check
    if "##" in S[B-1:D] or not "..." in S[B-1:D]:
        is_ok = False

    # a check
    if "##" in S[A-1:C]:
        is_ok = False
else:
    # b check
    if "##" in S[B-1:D]:
        is_ok = False

    # a check
    if "##" in S[A-1:C]:
        is_ok = False

# output
if is_ok:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
x=len(s)
flag=True
for i in range(x-1):
    if s[i]=="#" and s[i+1]=="#" and i<min(c-1,d-1):
        flag=False
if d>c:
    print('Yes' if flag else 'No')
else:
    flag1=False
    for i in range(x-3):
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            flag1=True
    if flag==False:
        print('No')
    elif flag==True and flag1==True:
        print('Yes')
    else:
        if s[d-2]=="#" or s[d]=="#":
            print('No')
        else:
            print('Yes')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
x=len(s)
flag=True
for i in range(x-1):
    if s[i]=="#" and s[i+1]=="#":
        flag=False
if d>c:
    print('Yes' if flag else 'No')
else:
    flag1=False
    for i in range(x-3):
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            flag1=True
    if flag==False:
        print('No')
    elif flag==True and flag1==True:
        print('Yes')
        exit()
    else:
        if s[d-2]=="#" or s[d]=="#":
            print('No')
        else:
            print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import deque
def solve():
    n,a,b,c,d = map(int,input().split())
    s = input()
    # aからcに到達可能か
    flag1 = True
    # bからcに到達可能か
    flag2 = True
    # 反転しているとき、到達可能な範囲に...は存在するか
    flag3 = False
    cnt = 0
    for i in range(a-1,c):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag1 = False
    cnt=0
    for i in range(b-1,d):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag2 = False
    l = max(a,b)
    r = min(c,d)
    for i in range(l-1,r):
        if s[i]=='.':
            cnt+=1
        else:
            cnt=0
        if cnt>=3:
            flag3 = True

    if flag1 and flag2:
        if c<d:
            print('Yes')
        else:
            if flag3:
                print('Yes')
            else:
                print('No')
    else:
        print('No')
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
from collections import deque
def solve():
    n,a,b,c,d = map(int,input().split())
    s = input()
    # aからcに到達可能か
    flag1 = True
    # bからcに到達可能か
    flag2 = True
    # 反転しているとき、到達可能な範囲に...は存在するか
    flag3 = False
    cnt = 0
    for i in range(a-1,c):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag1 = False
    cnt=0
    for i in range(b-1,d):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag2 = False
    l = max(a,b)
    r = min(c,d)
    if r<n and s[r]!='#':
        r+=1
    for i in range(l-1,r):
        if s[i]=='.':
            cnt+=1
        else:
            cnt=0
        if cnt>=3:
            flag3 = True

    if flag1 and flag2:
        if c<d:
            print('Yes')
        else:
            if flag3:
                print('Yes')
            else:
                print('No')
    else:
        print('No')
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
from collections import deque
def solve():
    n,a,b,c,d = map(int,input().split())
    s = input()
    # aからcに到達可能か
    flag1 = True
    # bからcに到達可能か
    flag2 = True
    # 反転しているとき、到達可能な範囲に...は存在するか
    flag3 = False
    cnt = 0
    for i in range(a-1,c):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag1 = False
    cnt=0
    for i in range(b-1,d):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag2 = False
    mx = a-1
    mn = a-1
    que = deque()
    que.append((a-1,0))
    while len(que):
        p = que.pop()
        cnt = p[1]
        pos = p[0]
        mx = max(mx,pos)
        mn = min(mn,pos)
        if pos==a-1:
            if pos+1<n:
                if s[pos+1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos+1,new))
            if pos-1>=0:
                if s[pos-1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos-1,new))
        if pos<a-1:
            if pos-1>=0:
                if s[pos-1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos-1,new))
        if pos>a-1:
            if pos+1<n:
                if s[pos+1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos+1,new))
    cnt=0
    for i in range(mn,mx+1):
        if s[i]=='.':
            cnt+=1
        else:
            cnt=0
        if cnt>=3:
            flag3 = True

    if flag1 and flag2:
        if c<d:
            print('Yes')
        else:
            if flag3:
                print('Yes')
            else:
                print('No')
    else:
        print('No')
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
from collections import deque
def solve():
    n,a,b,c,d = map(int,input().split())
    s = input()
    # aからcに到達可能か
    flag1 = True
    # bからcに到達可能か
    flag2 = True
    # 反転しているとき、到達可能な範囲に...は存在するか
    flag3 = False
    cnt = 0
    for i in range(a-1,c):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag1 = False
    cnt=0
    for i in range(b-1,d):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag2 = False
    mx = a
    mn = a
    que = deque()
    que.append((a-1,0))
    while len(que):
        p = que.pop()
        cnt = p[1]
        pos = p[0]
        mx = max(mx,pos)
        mn = min(mn,pos)
        if pos==a-1:
            if pos+1<n:
                if s[pos+1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos+1,new))
            if pos-1>=0:
                if s[pos-1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos-1,new))
        if pos<a-1:
            if pos-1>=0:
                if s[pos-1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos-1,new))
        if pos>a-1:
            if pos+1<n:
                if s[pos+1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos+1,new))
    cnt=0
    for i in range(mn,mx+1):
        if s[i]=='.':
            cnt+=1
        else:
            cnt=0
        if cnt>=3:
            flag3 = True

    if flag1 and flag2:
        if c<d:
            print('Yes')
        else:
            if flag3:
                print('Yes')
            else:
                print('No')
    else:
        print('No')
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
from collections import deque
def solve():
    n,a,b,c,d = map(int,input().split())
    s = input()
    # aからcに到達可能か
    flag1 = True
    # bからcに到達可能か
    flag2 = True
    # 反転しているとき、到達可能な範囲に...は存在するか
    flag3 = False
    cnt = 0
    for i in range(a-1,c):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag1 = False
    cnt=0
    for i in range(b-1,d):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag2 = False
    mx = a
    mn = a
    que = deque()
    que.append((a-1,0))
    while len(que):
        p = que.pop()
        cnt = p[1]
        pos = p[0]
        mx = max(mx,pos)
        mn = min(mn,pos)
        if pos==a-1:
            if pos+1<n:
                if s[pos+1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos+1,new))
            if pos-1>=0:
                if s[pos-1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos-1,new))
        if pos<a-1:
            if pos-1>=0:
                if s[pos-1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos-1,new))
        if pos>a-1:
            if pos+1<n:
                if s[pos+1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos+1,new))
    cnt=0
    print(mn,mx)
    for i in range(mn,mx+1):
        if s[i]=='.':
            cnt+=1
        else:
            cnt=0
        if cnt>=3:
            flag3 = True

    if flag1 and flag2:
        if c<d:
            print('Yes')
        else:
            if flag3:
                print('Yes')
            else:
                print('No')
    else:
        print('No')
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N, A, B, C, D = map(int, input().split())
    S = str(input())
    if C < D:
        if '##' in S[min(A, B):D]:
            print('No')
        else:
            print('Yes')
    elif C > D:
        if '##' in S[min(A, B):C]:
            print('No')
        else:
            if '...' in S[B-2:D+2]:
                print('Yes')
            else:
                print('No')
                
resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    N, A, B, C, D = map(int, input().split())
    S = str(input())
    if C < D:
        if '##' in S[min(A, B):D]:
            print('No')
        else:
            print('Yes')
    elif C > D:
        if '##' in S[min(A, B):C]:
            print('No')
        else:
            if '...' in S[B-2:D+2]:
                print('Yes')
            else:
                print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def resolve():
    N, A, B, C, D = map(int, input().split())
    S = str(input())
    if C < D:
        if '##' in S[min(A,B):D]:
            print('No')
        else:
            print('Yes')
    elif C > D:
        if '##' in S[min(A, B):C]:
            print('No')
        else:
            if '...' in S[B:D]:
                print('Yes')
            else:
                print('No')


resolve()

Submission status: Wrong Answer

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

def check():
    for i in range(a, d-1):
        if s[i] == s[i+1] == '#':
            return False
    return True


def check_2():
    for i in range(b, c-2):
        if s[i] == s[i+1] == s[i+2] == ".":
            return True
    return False


if check() is True:
    if c < d:
        print('Yes')
        exit()
    else:
        if check_2() is True:
            print('Yes')
            exit()
print('No')

Submission status: Wrong Answer

Solution code:
def resolve():
    N, A, B, C, D = map(int, input().split())
    S = str(input())
    if C < D:
        if '##' in S:
            print('No')
        else:
            print('Yes')
    elif C > D:
        if '...' in S[B:D]:
            print('Yes')
        else:
            print('No')


resolve()

Submission status: Wrong Answer

Solution code:
from collections import deque
def solve():
    n,a,b,c,d = map(int,input().split())
    s = input()
    # aからcに到達可能か
    flag1 = True
    # bからcに到達可能か
    flag2 = True
    # 反転しているとき、到達可能な範囲に...は存在するか
    flag3 = False
    cnt = 0
    for i in range(a-1,c):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag1 = False
    cnt=0
    for i in range(b-1,d):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag2 = False
    mx = a
    mn = a
    que = deque()
    que.append((a-1,0))
    while len(que):
        p = que.pop()
        cnt = p[1]
        pos = p[0]
        mx = max(mx,pos)
        mn = min(mn,pos)
        if pos==a-1:
            if pos+1<n:
                if s[pos+1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos+1,new))
            if pos-1>=0:
                if s[pos-1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos-1,new))
        if pos<a-1:
            if pos-1>=0:
                if s[pos-1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos-1,new))
        if pos>a-1:
            if pos+1<n:
                if s[pos+1]=='#':
                    new = cnt+1
                else:
                    new = 0
                if new>=2:
                    continue
                else:
                    que.append((pos+1,new))
    cnt=0
    for i in range(mn,mx+1):
        if s[i]=='.':
            cnt+=1
        else:
            cnt=0
        if cnt>=3:
            flag3 = True

    if flag1 and flag2:
        if a<b and c<d:
            print('Yes')
        elif a>b and c>d:
            print('Yes')
        else:
            if flag3:
                print('Yes')
            else:
                print('No')
    else:
        print('No')
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def check_one_people_can(start, end):
    s = S[start+1: end]
    before_sharp = False
    for x in s:
        if x == "#":
            if before_sharp:
                return False
            before_sharp = True
        else:
            before_sharp = False
    return True

def check_triple_dots(start, end):
    s = S[start-1: end+1]
    continuous_dots = 0
    for x in s:
        if x == ".":
            continuous_dots += 1
            if continuous_dots == 3:
                return True
        else:
            continuous_dots = 0
    return False

if D > C:
    if check_one_people_can(A, C) and check_one_people_can(C, D):
        print("Yes")
    else:
        print("No")
else:
    if check_triple_dots(B, D) and check_one_people_can(A, C):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())
S = list(input())[: -1]
tri = 0
for i in range(min(A, B) - 1, max(C, D) - 1):
  if S[i] == "#" and (S[i + 1] == "#"):
    print("No")
    exit(0)
for i in range(min(A, B) - 1, min(C, D)):
  if S[i] == "." and (S[i - 1] == ".") and (S[i + 1] == "."): tri = 1
if C <= D:
  print("Yes")
else:
  if tri: print("Yes")
  else: print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import deque
def solve():
    n,a,b,c,d = map(int,input().split())
    s = input()
    # aからcに到達可能か
    flag1 = True
    # bからcに到達可能か
    flag2 = True
    # 反転しているとき、到達可能な範囲に...は存在するか
    flag3 = False
    cnt = 0
    for i in range(a-1,c):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag1 = False
    cnt=0
    for i in range(b-1,d):
        if s[i]=='#':
            cnt+=1
        else:
            cnt=0
        if cnt>=2:
            flag2 = False
    mx = a
    mn = a
    que = deque()
    que.append((a-1,0))
    while len(que):
        p = que.pop()
        cnt = p[1]
        pos = p[0]
        mx = max(mx,pos)
        mn = min(mn,pos)
        if pos==a-1:
            if pos+1<n:
                if s[pos+1]=='#':
                    new = cnt+1
                else:
                    new = cnt
                if new>=2:
                    continue
                else:
                    que.append((pos+1,new))
            if pos-1>=0:
                if s[pos-1]=='#':
                    new = cnt+1
                else:
                    new = cnt
                if new>=2:
                    continue
                else:
                    que.append((pos-1,new))
        if pos<a-1:
            if pos-1>=0:
                if s[pos-1]=='#':
                    new = cnt+1
                else:
                    new = cnt
                if new>=2:
                    continue
                else:
                    que.append((pos-1,new))
        if pos>a-1:
            if pos+1<n:
                if s[pos+1]=='#':
                    new = cnt+1
                else:
                    new = cnt
                if new>=2:
                    continue
                else:
                    que.append((pos+1,new))
    cnt=0
    for i in range(mn,mx+1):
        if s[i]=='.':
            cnt+=1
        else:
            cnt=0
        if cnt>=3:
            flag3 = True

    if flag1 and flag2:
        if a<b and c<d:
            print('Yes')
        elif a>b and c>d:
            print('Yes')
        else:
            if flag3:
                print('Yes')
            else:
                print('No')
    else:
        print('No')
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())
S = list(input())[: -1] + ["#"] * 2
tri = 0
for i in range(min(A, B) - 1, max(C, D) - 1):
  if S[i] == "#" and (S[i + 1] == "#"):
    print("No")
    exit(0)
for i in range(min(A, B) - 1, min(C, D)):
  if S[i] == "." and (S[i + 1] == ".") and (S[i + 2] == "."): tri = 1
if C <= D:
  print("Yes")
else:
  if tri: print("Yes")
  else: print("No")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def check_one_people_can(start, end):
    s = S[start+1: end]
    before_sharp = False
    for x in s:
        if x == "#":
            if before_sharp:
                return False
            before_sharp = True
        else:
            before_sharp = False
    return True

def check_triple_dots(start, end):
    s = S[start: end+1]
    continuous_dots = 0
    for x in s:
        if x == ".":
            continuous_dots += 1
            if continuous_dots == 3:
                return True
        else:
            continuous_dots = 0
    return False

if D > C:
    if check_one_people_can(A, C) and check_one_people_can(C, D):
        print("Yes")
    else:
        print("No")
else:
    if check_triple_dots(B, D) and check_one_people_can(A, C):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())
S = list(input())[: -1]
tri = 0
for i in range(min(A, B) - 1, N - 1):
  if S[i] == "#" and (S[i + 1] == "#"):
    print("No")
    exit(0)
for i in range(min(A, B) - 1, D - 1):
  if S[i] == "." and (S[i - 1] == ".") and (S[i + 1] == "."): tri = 1
if C <= D:
  print("Yes")
else:
  if tri: print("Yes")
  else: print("No")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())
S = list(input())[: -1]
tri = 0
for i in range(min(A, B) - 1, N - 1):
  if S[i] == "#" and (S[i + 1] == "#"):
    print("No")
    exit(0)
for i in range(min(A, B) - 1, D - 2):
  if S[i] == "." and (S[i + 1] == ".") and (S[i + 2] == "."): tri = 1
if C <= D:
  print("Yes")
else:
  if tri: print("Yes")
  else: print("No")

Submission status: Wrong Answer

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

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