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:
def main():
    N, A, B, C, D = map(int, input().split())
    S = input()

    if S.find('##') > 0:
        print('No')
        return
    
    if S[B-1] == '#' or S[B+1] == '#':
        if D != N and S[B:D].find('...') == -1:
            print('No')
            return
    
    print('Yes')
    
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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 :
    print("Yes")
  elif s[a:c+1].count("##")==0 and s[b:d+1].count("##")==0 and s[d-1:d+2].count("...")>0 :
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

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

a_to_c = s[a-1:c-1]
b_to_d = s[b-1:d-1]

possibility = True

if a_to_c.find("##")!=-1 or b_to_d.find("##")!=-1:
    possibility = False
if c>d:
    if not(a_to_c.find('...')!=-1 and b_to_d.find('...')!=-1):
        possibility = False

if possibility:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input().rstrip()
renzoku_iwa = [0 for i in range(n)]
renzoku_blank = [0 for i in range(n)]
old1 = ""
old2 = ""
for i,tmp in enumerate(s):
	if old1 == tmp:
		if old1 == "." and old2 == ".":
			renzoku_blank[i] = 1
		elif old1 == "#":
			renzoku_iwa[i] = 1
	old2 = old1
	old1 = tmp

if sum(renzoku_iwa[a-1:c]) == 0 and sum(renzoku_iwa[b-1:d]) == 0:
	if c < d:
		print("Yes")
	else:
		if sum(renzoku_blank[b:d])>=1:
			print("Yes")
		else:
			print("No")
else:
	print("No")

Submission status: Wrong Answer

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[b:]

if '...' in b_s:
  santen_flag = True
if not '##' in b_s:
  kome_flag = True
    
   
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: Wrong Answer

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

if A < C < B < D:
    if not (S.find("##") < C - 1 and S.find("##") != -1) and not (
            S.find("##", B - 1) < D - 1 and S.find("##", B - 1) != -1):
        print("Yes")
    else:
        print("No")
elif C < D:
    if S.find("##") > D - 1 or S.find("##") == -1:
        print("Yes")
    else:
        print("No")
else:
    if S.find("...") < D - 1 and S.find("...") != -1:
        if S.find("##") > C - 1 or S.find("##") == -1:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = (int(i) for i in input().split())  
s = str(input())
n = len(s)

m = max([c, d])
if n>m:
    n = m
    s = s[:n]
    
if '##' in s[a-1:]:
    print('No')
elif b>c:
    print('Yes')
else:
    if c>d:
        if '...' in s[b-1:d]:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

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: Wrong Answer

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,i):
    if truth[i][now] == 1:
        return True
    if truth[i][now] == -1:
        return False
    if now == dest:
        truth[i][now] = 1
        return True
    if now + 2 < n:
        if s[now + 2] == '.' and solve(now + 2, dest,i):
            truth[i][now] = 1
            return True
    if now + 1 < n:
        if s[now + 1] == '.' and solve(now + 1, dest,i):
            truth[i][now] = 1
            return True
    else:
        truth[i][now] = -1
        return False

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] == '.':
            if s[i] != c:
                q = True
                break
    if q and solve(a,c,0) and solve(b,d,1):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = [int(i) for i in input().split()]
s = input()

if d >= c:
    flag1 = False
    block = 0
    for i in range(b, len(s)):
        if block == 2:
            flag1 = False
            break
        elif i == d-1:
            flag1 = True
            break
        elif s[i] == ".":
            block = 0
        elif s[i] == "#":
            block += 1

    if flag1 == True:
        s2 = s[:d-1]+'#'+s[d:]
        flag1 = False
        block = 0
        for i in range(a, len(s)):
            if block == 2:
                flag1 = False
                break
            elif i == c-1:
                flag1 = True
                break
            elif s2[i] == ".":
                block = 0
            elif s2[i] == "#":
                block += 1

    if flag1:
        print("Yes")
    else:
        print("No")



else:
    flag2 = False
    flag3 = False
    if s[b-2]=="#" or b-1==a:
        temp = 0
    else:
        temp = 1
    block = 0
    for i in range(b-1,c-1):
        if temp == 3:
            flag2 = True
            temp = i-1
            break
        elif s[i] == "#":
            temp = 0
        elif s[i] == ".":
            temp += 1

    if flag2 == True:
        flag3 = False
        block = 0
        s1 = s[:temp - 1] + '#' + s[temp:]
        for i in range(a, len(s)):
            if block == 2:
                flag3 = False
                break
            elif i == c-1:
                flag3 = True
                break
            elif s1[i] == ".":
                block = 0
            elif s1[i] == "#":
                block += 1

        if flag3 == True:
            s3 = s1[:c - 1] + '#' + s1[c:]
            flag3 = False
            block = 0
            for i in range(temp + 1, len(s)):
                if block == 2:
                    flag3 = False
                    break
                elif i == c-1:
                    flag3 = True
                    break
                elif s3[i] == ".":
                    block = 0
                elif s3[i] == "#":
                    block += 1

    if flag3:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

stoneflag = 0
clearflag = 0
if b < c:
    for i in range(n - 1):
        if i >= min(a - 1,b - 1) and i <= max(c - 1,d - 1):
            if s[i] == '#' and s[i + 1] == '#':
                stoneflag = 1
            elif i > b - 1 and i < d - 3:
                if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
                    clearflag = 1
else:
    for i in range(n - 1):
        if i > a - 1 and i < c - 1:
            if s[i] == '#' and s[i + 1] == '#':
                stoneflag = 1
        if i > b - 1 and i < d - 1:
            if s[i] == '#' and s[i + 1] == '#':
                stoneflag = 1

if stoneflag == 1:
    print('No')
elif c < d:
    print('Yes')
elif c > d and clearflag == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

elif C < D:
  print("Yes")

else:
  if "..." in S[B-2:D+1]:
    print(S[B-2:D+1])
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

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

curval = "x"
cnt = 0
initidx = 0
ngarea = [-1]
triarea = [-1]

for idx,val in enumerate(S):
    if val == curval:
        cnt += 1
    else:
        if cnt >= 2 and curval == '#':
            ngarea.append(initidx + 1)
        elif cnt >= 3 and curval == '.':
            triarea.append(initidx + 1)
        initidx = idx
        cnt = 1
    curval = val
else:
    if cnt >= 2 and curval == '#':
        ngarea.append(initidx + 1)
    elif cnt >= 3 and curval == '.':
        triarea.append(initidx + 1)

if C < D:
    isBflg = True
    isABflg = True
    for ngp in ngarea:
        if ngp > B and ngp < D:
            isBflg = False
        if ngp > A and ngp < B:
            isABflg = False
    if isBflg and isABflg:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
else:
    isChangeFlg = False
    # Changepoint = -1
    for trp in triarea:
        if trp >= A and trp + 1 >= B:
            Changepoint = trp + 1
            isChangeFlg = True
            break
    if isChangeFlg == False:
        print('No')
        exit()
    else:
        isBflg = True
        isABflg = True
        isChange2DFlg = True
        for ngp in ngarea:
            if ngp > B and ngp < Changepoint:
                isBflg = False
            if ngp > A and ngp < B:
                isABflg = False
            if ngp > Changepoint and ngp < D:
                isChange2DFlg = False
        if isBflg and isABflg and isChange2DFlg:
            print('Yes')
            exit()
        else:
            print('No')
            exit()

Submission status: Wrong Answer

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

S = list(input().split()[0])

result = "Yes"
flag = False

if C < D:
    for i in range(B, D - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
                print(result)
                flag = True
                break
else:
    for i in range(B, C - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
                print(result)
                flag = True
                break
    if not flag:
        for i in range(B - 1, C - 2):
            if S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
                result = "Yes"
                print(result)
                flag = True
                break
if not flag:
    print(result)

Submission status: Wrong Answer

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

a_to_c = s[a-1:c-1]
b_to_d = s[b-1:d-1]

possibility = True

if a_to_c.find("##")!=-1 or b_to_d.find("##")!=-1:
    possibility = False
if a<b and c>d:
    if not(a_to_c.find('...')!=-1 and b_to_d.find('...')!=-1):
        possibility = False

if possibility:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

rock = "#"
S = list()
three_empty = []
two_rocks = []
rock_cnt, empty_cnt = 0, 0

# 通れない２連続岩の場所とABが交差できる３emptyの場所取得
for i, s in enumerate(input().strip(), start=1):
  is_rock = s == rock
  if is_rock:
    if empty_cnt >= 3:
      three_empty.append(i - 1)
    rock_cnt += 1
    empty_cnt = 0
  else:
    if rock_cnt >= 2:
      two_rocks.append(i - 1)
    rock_cnt = 0
    empty_cnt += 1
if rock_cnt >= 2:
  two_rocks.append(i)
if empty_cnt >= 3:
  three_empty.append(i)

flag = True
left = A if A < B else B
right = B if A > B else A
left_rock = 0
right_rock = 200001


for i in two_rocks:
  # 目標の間に岩があるか確認
  if A > i > C or B > i > D or A < i < C or B < i < D:
    flag = False
    break
  # 左と右にいる人から一番近い岩の位置
  if i < left:
    left_rock = i
  elif right_rock == 200001 and right < i:
    right_rock = i

# print("Rock:", two_rocks, "Empty:", three_empty)
# print(left_rock, right_rock)
# print(flag)
# print(A, "->", C)
# print(B, "->", D)

if not flag:
  # 目標との間に2岩があるとき
  print("No")
elif (A > B and C > D) or (A < B and C < D):
  # 木彫との間に2岩がなく、交差が発生しない場合。
  print("Yes")
elif not three_empty:
  # 交差点となる3emptyがない場合
  print("No")
else:
  # 双方の一番近い岩との間に3emptyがあるかどうか 
  flag = False
  for i in three_empty:
    if left_rock < i < right_rock:
      flag = True
      break
  if flag:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
length, a, b, c, d = [int(i) for i in input().split()]
road = input()

if '##' in road:
    print('No')
elif '...' in road:
    print('Yes')
elif a < b:
    a, b = b, a
    if c > d:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = [int(x) for x in input().split(' ')]

S = []
S.append(-1)
p2 = -1
p = -1
err = False
pathway = []
for idx, s in enumerate(input()):
  if s == '.':
    S.append(0)
    if p2 == 0 and p == 0:
      pathway.append(idx-2)
    p2 = p
    p = 0
  else:
    S.append(1)
    if p == 1:
      err = True
    p2 = p
    p = 1
    
res = err
if err == False:
  if (S[A] == 0) and (S[B] == 0) and (S[C] == 0) or (S[D] == 0):
    if C > D:
      if len(pathway) > 0:
        if D in pathway:
          res = False
        else:
          res = True
      else:
        res = False
    else:
      res = True
    
if res == True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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:
                print("Yes")
                exit()
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
flag = 0
for i in range(A, max(C, D)):
    if S[i-1] == "#" and S[i] == '#' and flag == 0:
        print("No")
        flag = 1
    #print(S[i-1], S[i])

if flag == 0:

    if A > B:
        ab = 1
    else:
        ab = 0
    if C > D:
        cd = 1
    else:
        cd = 0

    if ab != cd:
        for i in range(B - 1, min(C, D) - 1):
            if S[i-1] == "." and S[i+1] == "." and S[i] == "." and flag == 0:
                print("Yes")
                flag = 1
            #print(S[i-1],S[i] , S[i+1])
        if flag == 0:
            print("No")

    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: int, B: int, C: int, D: int, S: str): 
    if(S[A-1] == '#' or S[B-1] == '#' or  S[C-1] == '#' or S[D-1] == '#'):
        print(NO)
        sys.exit()

    if(S[A-1:C].count('##') == 0 and S[B-1:D].count('##') == 0):
        if(D < C):
            if(S[B-1:D].count('...') == 0):
                print(NO)
            else:
                tS = list(S)
                tS[B-1] = 'b'
                tS = ''.join(tS)
                if(tS[A-1:D].count('...') == 0 and tS[A-1:D].count('..b#') == 1):
                    print(NO)
                else:
                    print(YES)
        else: # D > Cの場合
            print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=str(input())
arr=[]
for i in range(len(s)):
	if(s[i]=='#'):
		arr.append(-1)
	elif(s[i]=='.'):
		arr.append(0)

a-=1
b-=1
c-=1
d-=1
flag=0
arr[a]=1
arr[b]=2
arr[c]=3
arr[d]=4

for i in range(n-1):
	if(s[i]=='#' and s[i+1]=='#'):
		flag=1
		break
if(flag==0):
	if(c<d):
		print("Yes")
	else:
		pos1=a
		pos2=b
		temp=0
		while(pos2>pos1):
			if(pos1+1<n and arr[pos1+1]==0):
				arr[pos1]=0
				arr[pos1+1]=1
				pos1+=1
			else:
				if(pos1+2<n and arr[pos1+2]==0):
					pos1+=2
					arr[pos1-2]=0
					arr[pos1]=1
				else:
					if(pos2+1<n and arr[pos2+1]==0):
						pos2+=1
						arr[pos2-1]=0
						arr[pos2]=2
					else:
						if(pos2+2<n and arr[pos2+2]==0):
							pos2+=2
							arr[pos2-2]=0
							arr[pos2]=2
						else:
							flag=1
							break
			if(pos2==d):
				temp=1
				break
			#print(arr)
		if(flag==1):
			print("No")
		else:
			if(temp==0):
				print("Yes")
			else:
				while(pos2>pos1):
					if(pos1+1<n and arr[pos1+1]==0):
							pos1+=1
							arr[pos1-1]=0
							arr[pos1]=1
					
					else:
						if(pos1+2<n and arr[pos1+2]==0):
							pos1+=2
							arr[pos1-2]=0
							arr[pos1]=1
						else:
							flag=1
							break
				if(flag==1):
					print("No")
				else:
					print("Yes")
else:
	print("No")

Submission status: Wrong Answer

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

pres = 'x'          # S[i-1]
cntx, cnty = 0, 0   # x:'.'の連続数, y:'#'の連続数
mxx, mxy = 1, 1     # mxx:'.'の連続数max, mxy:'#'の連続数max

for i in range(A-1, max(C, D)): # base=0
    if S[i] == pres:
        if S[i] == '.':
            cntx += 1
            if i >= B-1 and i < D+1:  # .のチェックは B-D+1だけ
                mxx = max(cntx, mxx)
        elif S[i] == '#':
            cnty += 1
            if C > B or (i < C and i >= B-1):   # C < B の場合は、C-Bでは#の数は不問
                mxy = max(cnty, mxy)
    else:
        pres = S[i]
        if S[i] == '.':
            cntx = 1
        elif S[i] == '#':
            cnty = 1

if C < D:
    if mxy < 2:
        print("Yes")
    else:
        print("No")
else:
    if mxy < 2 and mxx >= 3:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
# coding:utf-8


def main():
    N, A, B, C, D = map(int, input().split())
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    iwa = "#"
    S = input()
    ans = True
    canexchange = False

    exchagable_list = []
    for i in range(N-2):
        temps = S[i:i+3]
        if temps == "...":
            exchagable_list.append(i)

    if len(exchagable_list) > 0:
        for i in exchagable_list:
            if i >= A and i+1 <= min(C, D):
                canexchange = True

    # print(canexchange)
    for i in range(N-1):
        if S[i] == iwa and S[i+1] == iwa:
            if not (i+1 < A or i > max(C, D)):
                if C < B and not(C < i and i+1 < B):
                    ans = False

    if ans:
        if C < D:
            ans = True
        elif C > D and canexchange:
            ans = True
        elif C > D and not canexchange:
            if S[D-1] == iwa or S[D+1] == iwa:
                ans = False
            else:
                ans = True

    if ans:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = (int(i) for i in input().split())  
s = str(input())
n = len(s)

m = max([c, d])
if n>m:
    n = m
    s = s[:n]
    
if '##' in s[a-1:]:
    print('No')
elif b>c:
    print('Yes')
else:
    if c>d:
        if '...' in s[b:d]:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
A -= 1
B -= 1
C -= 1
D -= 1
if A < B and B < D and A < C:
    ans = True
else:
    ans = False

if C < B:
    count_x = 0
    for i in range(A, C):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_x = 0
        for i in range(B, D):
            if S[i] == "#":
                count_x += 1
            else:
                count_x = 0
            if count_x > 1:
                ans = False
                break
elif C < D:
    count_x = 0
    for i in range(A, D):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
else:
    count_x = 0
    for i in range(A, C):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_o = 0
        ans = False
        for i in range(B, D+2):
            if S[i] == "#":
                count_o = 0
            else:
                count_o += 1
            if count_o > 2:
                ans = True
                break
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import re
from sys import exit
compiled=re.compile('##')
cmp2=re.compile(r"\.\.\.")

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

s=input()

result=compiled.finditer(s)

while(True):
    try:
        sp=result.__next__().span()
        if (a<sp[0] and sp[1]<c) or (b<sp[0] and sp[1]<d):
            print("No")
            exit()
    except StopIteration:
        break

dot3=cmp2.match(s)
if dot3 is None and c>d:
    print("No")
    exit()


print("Yes")

Submission status: Wrong Answer

Solution code:
def aaa():
    nTmp = input().split()
    nabcd = list(map(int, nTmp))
    n = nabcd[0]
    a = nabcd[1]  # すぬけ君の初期位置
    b = nabcd[2]  # 腑抜け君の初期位置
    c = nabcd[3]
    d = nabcd[4]

    s = list(input().strip())

    ichi = {}
    ichi["A"] = a
    ichi["B"] = b

    s[a-1] = "A"
    s[b-1] = "B"

    dest = {}
    dest["A"] = c
    dest["B"] = d
    # print(s)

    # みぎにいる方とそうでない方
    if (a > b):
        migini_iru_hito = "A"
        hidari_no_hito = "B"
    elif (a < b):
        migini_iru_hito = "B"
        hidari_no_hito = "A"

    while(1):
        # for i in range(2):
        # す抜けか腑抜けを選ぶ
        # 1マス右か，2マス右に移動できる
        # 岩や人がいたらだめ

        if s[ichi[migini_iru_hito]] == ".":
            s[ichi[migini_iru_hito] - 1] = "."
            s[ichi[migini_iru_hito]] = migini_iru_hito
            ichi[migini_iru_hito] = ichi[migini_iru_hito]+1

        elif s[ichi[migini_iru_hito]+1] == ".":
            s[ichi[migini_iru_hito] - 1] = "."
            s[ichi[migini_iru_hito]+1] = migini_iru_hito
            ichi[migini_iru_hito] = ichi[migini_iru_hito]+2

        else:
            print("No")
            return

        # print(ichi)
        # print(dest)
        # print(s)

        # 最終的にCにす抜け，Dに腑抜けが，いるようにしたい
        if ichi[migini_iru_hito] == dest[migini_iru_hito]:
            # 一個めクリア
            break

    # TODO==================================================================================

    while(1):
        # for i in range(2):
        # す抜けか腑抜けを選ぶ
        # 1マス右か，2マス右に移動できる
        # 岩や人がいたらだめ

        if s[ichi[hidari_no_hito]] == ".":
            s[ichi[hidari_no_hito] - 1] = "."
            s[ichi[hidari_no_hito]] = hidari_no_hito
            ichi[hidari_no_hito] = ichi[hidari_no_hito]+1

        elif s[ichi[hidari_no_hito]+1] == ".":
            s[ichi[hidari_no_hito] - 1] = "."
            s[ichi[hidari_no_hito]+1] = hidari_no_hito
            ichi[hidari_no_hito] = ichi[hidari_no_hito]+2

        else:
            print("No")
            return

        # print(ichi)
        # print(dest)
        # print(s)

        # 最終的にCにす抜け，Dに腑抜けが，いるようにしたい
        if ichi[hidari_no_hito] == dest[hidari_no_hito]:
            print("Yes")
            break
    return


aaa()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a=input().split()
b=input()

ans = 0
re = 0
if int(a[3])>int(a[4]):
	re = 1

p = 0
rock = 0
dot = 0
rock_ver = 0
re_ok = 0
for i in range(int(a[0])):
	if i + 1 == int(a[2]):
		p = 1
	b_i = b[int(i)]
	if b_i == "#":
		if rock == 1:
			ans = 1
			break
		if p == 1:
			if rock_ver == 0:
				rock_ver = 1
		rock = 1
		dot = 0
	else:
		rock = 0
		if p == 1:
			dot += 1
			if rock_ver == 0:
				if dot >=2 and b[int(i)-2] == ".":
					re_ok = 1
					break
			elif dot >= 3:
				re_ok = 1
				break

if re == 1:
	if re_ok == 0:
		ans = 1

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

Submission status: Wrong Answer

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

S = input()

if C < D:
    s = []
    for i in range(N):
        s.append(S[i])

    for i in range(1,C):
        if s[i] == '#' and s[i-1] == '#':
            print('No')
            exit()
    print('Yes')

else:
    s1 = []
    for i in range(N):
        s1.append(S[i])
    for i in range(1,C):
        if s1[i] == '#' and s1[i-1] == '#':
            print('No')
            exit()
    flag = False
    for i in range(B+1,D):
        if s1[i] == '.' and s1[i-1] == '.' and s1[i-2] == '.':
            flag = True
        
    if flag == True:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

ans = True

if '##' in s[a:max(c,d)]:
    ans = False
else:
    if d < c:
        if '...' not in s[a:]:
            ans = False

if ans is True:
    print ('Yes')
else:
    print ('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, input().split())
S = input()
S =S+"#"
S =S+"#"
S =S+"#"
answer = 1
a = 1
distance = []
distance_2 = []
for n in range(A-1,max(C+1,D+1)):
  a += 1
  if S[n] == "#":
    distance.append(a)
    a = 0
if 1 in distance:
  answer = 0
if D < C and answer == 1:
  a = 1
  for n in range(B-2,D+2):
    a += 1
    if S[n] == "#":
      distance_2.append(a)
      a = 0
  if max(distance_2) < 4:
    answer = 0
if answer == 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
length, a, b, c, d = [int(i) for i in input().split()]
road = input()

if '##' in road:
    print('No')

if '...' in road:
    print('Yes')

if a < b:
    a, b = b, a

if c > d:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
dot = []
sharp = []
A_clear = True
B_clear = True

if C<D:
    # print(S[B-1:D])
    tmp_s = 0
    for s in S[B-1:D]:
        if s == '#' and tmp_s>0 :
            B_clear = False
            break
        elif s == '#':
            tmp_s += 1
        else:
            tmp_s = 0

    tmp_s = 0
    for s in S[A-1:C]:
        if s == '#' and tmp_s>0 :
            A_clear = False
            break
        elif s == '#':
            tmp_s += 1
        else: 
            tmp_s = 0
    if A_clear == True and B_clear == True:
        print('Yes')
    else:
        print('No')
    
elif D<C:
    # A
    tmp_s = 0
    for s in S[A-1:C]:
        if s == '#' and tmp_s>0 :
            A_clear = False
            break
        elif s == '#':
            tmp_s += 1
        else:
            tmp_s = 0
    # B
    tmp_s = 0
    tmp_d = 0
    A_clear = False
    for s in S[B-1:D]:
        if s == '.' and tmp_d>=2:
            tmp_s += 1
            A_clear = True
        elif s == '.' and tmp_s>=0:
            tmp_d += 1
            tmp_s = 0
        elif s == '#' and tmp_d>=0:
            tmp_s += 1
            tmp_d = 0
        elif s == '#' and tmp_s>0 :
            B_clear = False
            break
    if A_clear == True and B_clear == True:
        print('Yes')
    else:  
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,j=map(int,input().split())
s=input()
d=s[int(a-1):int(b)]
e=s[int(c-1):int(j)]
f=''.join(d)
g=''.join(e)
h= '##' in f
i= '##' in g
if (h==False) and (i==False):
	print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n, a_, b_, c_, d_ = map(int, input().split())
s_ = input()

def unchi(a,b,c,d,s):
  ss, s = s, s[:b] + '#' + s[b+1:]
    
  if (("##" in s[b:d].split(".")) == False):
    b = d
    s = s[:b] + '#' + s[b+1:]
  
  s = ss
  if(("##" in s[a:c].split(".")) == False):
    a = c
    s = s[:a] + '#' + s[a+1:]
  
  if(a==c and b==d):
    print("Yes")
  else:
    print("No")
    
if (c_ < d_):
  unchi(a_-1,b_-1,c_-1,d_-1,s_)
else:
  unchi(b_-1,a_-1,d_-1,c_-1,s_)

Submission status: Wrong Answer

Solution code:
def g(i, y, S):
    while i != y:
        if S[i + 2] == '.':
            i += 2
        elif S[i + 1] == '.':
            i += 1
        else:
            break
    return i
def dc(n, a, b, c, d, S):
    S = list(S)
    S[b] = 'B'
    while a < b:
        a = g(a, c, S)
        if S[b + 1] == '.':
            S[b] = '.'
            b += 1
            S[b] = 'B'
        elif S[b + 2] == '.':
            S[b] = '.'
            b += 2
            S[b] = 'B'
        else:
            return a == c and b == d
    return True
def solve():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    S = input() + "##"
    if c < d:
        if "##" in S[a + 1:c] or "##" in S[b + 1:d]:
            return False
    else:
        if "##" in S[a + 1:c]:
            return False
        return dc(n, a, b, c, d, S)
    return True
print("Yes" if solve() else "No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = [int(c) for c in input().split()]
S = input() + '##'

r2 = set()
r1 = {B-1}

for i, c in enumerate(S):
    if c=='.' and (i-2 in r1 or i-1 in r1):
        r1 |= {i}

for x in range(A-1, C):
    if S[x]=='#' : r0 = set()
    else:
        r0=r1|r2
        r0.discard(x)
        if S[x-1]=='.' and (x-2 in r0 or x-3 in r0):
            r0 |= {x-1}
        if S[x-2]=='.' and (x-3 in r0 or x-4 in r0):
            r0 |= {x-2}
                
    r2=r1
    r1=r0

out = 'YES' if D-1 in r0 else 'NO'
print(out)