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())
A -= 1
B -= 1
C -= 1
D -= 1
S = list(input())

ans = 'Yes'
if C < D:
    for i in range(A, C):
        if S[i] == '#' and S[i + 1] == '#':
            ans = 'No'
            break
    for i in range(B, D):
        if S[i] == '#' and S[i + 1] == '#':
            ans = 'No'
            break
else:
    for i in range(A, C - 1):
        if S[i] == '.' and S[i + 1] == '.' and S[i + 2] == '.':
            break
    else:
        S[D] = '#'
        for i in range(A, C):
            if S[i] == '#' and S[i + 1] == '#':
                ans = 'No'
                break
    for i in range(B, D):
        if S[i] == '#' and S[i + 1] == '#':
            ans = 'No'
            break
            
print(ans)

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
def f():
    for i in range(n):
        if s[i] == '#' and s[i+1] == '#':
            return "No"
        else:
            if c < d:
                return "Yes"
            else:
                for i in range(b-1, d):
                    if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
                        return "Yes"
                    else:
                        return "No"
f()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    
ans="Yes"
for i in range(a,max(c,d)-1):
  if s[i-1]=="#" and s[i]=="#":
    ans="No"

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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
flag2 = True
flag3 = False
if C < D:
    AS = S[A:C-1]
    BS = S[B:D-1]
    for i in range(len(S)-1):
        if BS[i:i+2] == '##':
            flag2 = False
    for i in range(len(S)-1):
        if AS[i:i+2] == '##':
            flag2 = False
    if flag2:
        print('Yes')
    else:
        print('No')
else:
    AS = S[A:C-1]
    BS = S[B:D-1]
    AD = S[A-1:D+1]
    print(AD)
    for i in range(len(S)-2):
        if AD[i:i+3] == '...':
            flag3 = True
    if flag2 and flag3:
        print('Yes')
    else:
        print('No')
    for i in range(len(S)-1):
        if BS[i:i+2] == '##':
            flag2 = False
    for i in range(len(S)-1):
        if AS[i:i+2] == '##':
            flag2 = False

Submission status: Wrong Answer

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

S_before_a = S.copy()
S_before_a[B-1] ='#'
A_list = S_before_a[A:C-1]
count = 0
for i in range (len(A_list)-1):
    if ''.join(A_list[i:i+2])=='##':
        count+=1

S_after_a = S.copy()
S_after_a[C-1]='#'

B_list = S_after_a[B:D-1]
for i in range (len(B_list)-1):
    if ''.join(B_list[i:i+2])=='##':
        count+=1
    
#count逆
S_before_b = S.copy()
S_before_b[A-1] ='#'
B_list = S_before_b[B:D-1]
count2 = 0
for i in range (len(B_list)-1):
    if ''.join(B_list[i:i+2])=='##':
        count2+=1

S_after_b = S.copy()
S_after_b[D-1]='#'

A_list = S_after_b[A:C-1]
for i in range (len(A_list)-1):
    if ''.join(A_list[i:i+2])=='##':
        count2+=1
        
if count == 0 or count2 ==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if(max([len(item) for item in s.split('.')])>1):
	print('No')
elif(c<b):
	print('No')
elif(c<d):
	print('Yes')
else:
	if(max([len(item) for item in s.split('#')])>2):
		print('Yes')
	else:
		print('No')

Submission status: Wrong Answer

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

S = input()

s1 = []
s2 = []
for i in range(N):
    if i == C-1:
        s1.append('#')
        s2.append(S[i])
        continue
    if i == D-1:
        s2.append('#')
        s1.append(S[i])
        continue
    s1.append(S[i])
    s2.append(S[i])

flag1 = False
flag2 = False

for i in range(1,N):
    if s1[i] == '#' and s1[i-1] == '#':
        flag1 = True
    if s2[i] == '#' and s2[i-1] == '#':
        flag2 = True

if flag1 == True and flag2 == True:
    print('No')
else:
    flag3 = True
    for i in range(2,N):
        if s2[i] == '.' and s2[i-1] == '.' and s2[i-2] == '.':
            flag3 = False
    if flag3 == True:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# agc034/agc034_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, A, B, C, D = i2nn()
    S = i2s()
    if '##' not in S[B-1:D] and '##' not in S[A-1:C] and C < D or '...' in S[A:D]:
        print('Yes')
    else:
        print('No')
    return

main()

Submission status: Wrong Answer

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

S = S[min(A, B)-1:max(C, D)]
if "##" in S:
    print("No")
else:
    if "..." in S:
        print("Yes")
    else:
        if C < D:
            print("Yes")
        else:
            print("No")

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


def f():
    can_over = False

    prev_1 = ""
    for i in range(A, max(D, C) + 1):
        now = S[i]
        if prev_1 == "#" and now == "#":
            return False

    if C < D:
        return True

    prev_2 = ""
    prev_1 = ""
    for i in range(B, min(D + 2, N)):
        now = S[i]
        if prev_1 == prev_2 == now == ".":
            can_over = True

        prev_2, prev_1 = prev_1, now

    return can_over

print("Yes" if f() else "No")

Submission status: Wrong Answer

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

if "##" in s:
    print("No")
    exit()

if a < b and c > d:
    if "..." not in s[b:d]:
        print("No")
        exit()

if a > b and c < d:
    if "..." not in s[a:c]:
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

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

if '##' in S[A-1:C-1] or '##' in S[B-1:D-1]:
  print('No')
else:
  if C < D:
  	print('Yes')
  else:
    if '...' in S[B-1:right]:
      print('Yes')
    else:
      if len(S[A-1:right])<=6:
        print('Yes')
      print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=list(input())
s[c-1]="c"
s[d-1]="d"
flag=False
lim=max(c,d)
for i in range(a+1,lim-1):
  if s[i]!="#" and s[i]!="d":
    if s[i-1]!="#"and s[i-1]!="d" and s[i+1]!="#"and s[i+1]!="d":
      flag=True
    continue
  if s[i+1]=="#":
    print("No")
    exit()
if flag==False and d<c and (s[d-2]=="#" or s[d]=="#"):
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

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

flag = True

# c < dならbを先にゴールさせれば良い
s_bd = s[b:d-1]
for i in range(len(s_bd)-1):
    if s_bd[i:i+2] == "##":
        flag = False
        break
s_ac = s[a:c-1]
for i in range(len(s_ac)-1):
    if s_ac[i:i+2] == "##":
        flag = False
        break

if c > d:
    s_bd = s[b-1:d]
    has_ddd = False
    for i in range(len(s_bd)-2):
        if s_bd[i:i+3] == "...":
            has_ddd = True
    if has_ddd == False:
        flag = False

if flag:
    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:
if "##" in S[:max([D, C])]:
	print("No")
	exit()

if D < C:
	if not "..." in S[:D]:
#	if not "..." in S:
		print("No")
		exit()

print("Yes")
"""
10 1 2 4 5
..#..#...##
"""

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    A = A-1
    B = B-1
    C = C-1
    D = D-1
    # T = list(S)
    # T[A] = "A"
    # T[B] = "B"
    # T[C] = "C"
    # T[D] = "D"
    # print("".join(T))

    def reachable(A, C, S):     # O(N)
        # AからCへ到達可能ですか
        if S[A:C+1].find("##") == -1:
            return True
        else:
            return False

    if C > D:
        # できるだけ早く追い越す
        # 追い越すためには、"..."という領域が必要。
        oikoshi = S[B-1:].find("...")
        if oikoshi == -1:
            no()
            return
        A = B-1+oikoshi + 2
        B = B-1+oikoshi + 1

    # ２連岩なければ通れる
    if reachable(A, C, S) and reachable(B, D, S):
        yes()
    else:
        no()
    return


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=list(map(int,input().split()))
S=input()
bS=S[B-1:D]
a=True
if C<D:
    if "##" in bS:
        a=False
    else:
        aS=S[A-1:C]
        if "##" in aS:
            a=False

else:
    if "##" in bS:
        a=False
    else:
        aS=S[A-1:C]
        if "##" in aS:
            a=False
        else:
            tmp=S[:B-1]+"#"+S[B:]
            aS=tmp[A-1:C]
            j1= ("##" in aS)
            tmp=S[:D-1]+"#"+S[D:]
            aS=tmp[A-1:C]
            j2= ("##" in aS)
            if  not("..." in bS or (j1 or j2)):
                a=False
            
        
        
if a:
    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 :
    print("No")
    quit()

print(S[B-1:C-1])
if C > D:
    if '...' not in S[B:C-2]:
        print("No")
        quit()


print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
flag=0
span=0
buf=-5
if(c<d):
    for i in range(a-1,d):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
else:
    for i in range(a-1,c):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
        elif s[i]=='#':
            buf=max([span,buf])
            span=0
        elif i<d+1:
            span+=1
    if buf<=2:
        flag=1
        #print(buf)
print('No' if flag==1 else 'Yes')

Submission status: Wrong Answer

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

if "##" in S[A-1:C]:
	print("No")
elif "##" in S[B-1:D]:
	print("No")
elif D < C:	# need to reverse
	if not "..." in S[A-1:C]:
		print("No")
	elif S[D-2:D+1] == "#..":
		print("No")
	else:
		print("Yes")
else:
	print("Yes")

Submission status: Wrong Answer

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

if '##' in S[A:C+1] or '##' in S[B:D+1]:
    print("No")
else:
    if C < D:
        print("Yes")
    elif B-A == 1 and S[A-1:A+2] == '...':
        print("Yes")
    elif '...' in S[B-1:D+1]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys

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

lst = [0] * (n+1)
for i in range(1, n+1):
    if s[i-1] == '#':
        lst[i] = 1

if c < d:
    stone = 0
    for i in range(b+1, d+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    stone = 0
    for i in range(a+1, c+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    print('Yes')
else:
    brank = 0
    three = 0
    for i in range(b-1, c):
        if lst[i] == 0:
            brank += 1
            if brank == 3:
                three = 1
                break
        else:
            brank = 0
    if three == 0:
        print('No')
        sys.exit()
    stone = 0
    for i in range(b+1, d+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    stone = 0
    for i in range(a+1, c+1):
        if lst[i] == 1:
            stone += 1
            if stone == 2:
                print('No')
                sys.exit()
        else:
            stone = 0
    print('Yes')

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

    if "..." in S:
        canexchange = True

    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)):
                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 = map(int,input().split())
A -= 1
B -= 1
C -= 1
D -= 1
S = list(input())
if (A < B < D < C):
    cnt = 0
    cntl = []
    for i in range(A+1,C-1):
        if (S[i] == '.') & (S[i+1] == '.'):
            cnt += 1
        elif (S[i] == '.') & (S[i+1] == '#'):
            cntl.append(cnt)
            cnt = 0
    if max(cntl) < 2:
        print('NO')
    else:
        cnt = 0
        cntL = []
        for i in range(B+1,D-1):
            if (S[i] == '#') & (S[i+1] == '#'):
                cnt += 1
            elif (S[i] == '#') & (S[i+1] == '.'):
                cntL.append(cnt)
                cnt = 0
        if max(cntL) >= 1:
            print('NO')
        else:
            if (S[D+1] == '.')&(S[D-1] == '.'):
                print('YES')
            elif S[D-1] == '#':
                x = 0
                xl = []
                for i in range(B-1,D-2):
                    if (S[i] == '.') & (S[i+1] == '.'):
                        x += 1
                    elif (S[i] == '.') & (S[i+1] == '#'):
                        xl.append(x)
                if max(xl) >= 2:
                    print('YES')
                else:
                    print('NO')
            else:
                x = 0
                xl = []
                for i in range(B-1,D-1):
                    if (S[i] == '.') & (S[i+1] == '.'):
                        x += 1
                    elif (S[i] == '.') & (S[i+1] == '#'):
                        xl.append(x)
                if max(xl) >= 2:
                    print('YES')
                else:
                    print('NO')
else:
    cnt = 0
    cntl = []
    for i in range(A+1,C-1):
        if (S[i] == '#') & (S[i+1] == '#'):
            cnt += 1
        elif (S[i] == '#') & (S[i+1] == '.'):
            cntl.append(cnt)
            cnt = 0
    if max(cntl) >= 1:
        print('NO')
    else:
        print('YES')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int,input().split())
s = input()
judgesharp = False
judgepass = False
threepoint = 0
count = 0
a -= 1
b -= 1
c -= 1
d -= 1
if c < d:
  for i in s:
    if count < a or count > d:
      pass
    elif i == "#":
      if judgesharp == True:
        print("No")
        sys.exit()
      else:
        judgesharp = True
    else:
      judgesharp = False
    count += 1
  print("Yes")
else:
  for i in s:
    if count < a or count > d:
      pass
    elif i == "#":
      threepoint = 0
      if judgesharp == True:
        print("No")
        sys.exit()
      else:
        judgesharp = True
    else:
      if b-1 <= count and count <= d+1:
        threepoint += 1
      judgesharp = False
    if threepoint == 3:
      judgepass = True
    count += 1
  if judgepass:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=list(input())
s[c-1]="c"
s[d-1]="d"
flag=False
lim=max(c,d)
for i in range(a+1,lim-1):
  if s[i]!="#" and s[i]!="d":
    if s[i-1]!="#"and s[i]!="d" and s[i+1]!="#"and s[i+1]!="d":
      flag=True
    continue
  if s[i+1]=="#":
    print("No")
    exit()
if flag==False and d<c and (s[d-2]=="#" or s[d]=="#"):
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(input())
ans = 0
A = c
B = d
cntS = [0 for i in range(len(s))]
if s[0] == "#":
    cntS[0] = 1
for i in range(len(s)):
    if s[i] == "#":
        cntS[i] = cntS[i - 1] + 1

cnt = 0
ans = "Yes"
for i in range(b - 1, B):
    if cntS[i] >= 2:
        ans = "No"
        break

for i in range(a - 1, A):
    if cntS[i] >= 2:
        ans = "No"
        break

if s[A - 1] == "#" or s[B - 1] == "#":
    ans = "No"

if b < a < A < B:
    key = 1
    if (s[a - 2] == "#" or s[a] == "#") and ans == "Yes":
        for i in range(a, A):
            if s[i - 1] == "." and s [i + 1] == "." and s[i] == ".":
                s[i] = "#"
                cntS[i] = 1
                key = 0
        if key:
            ans = "No"

    if ans == "Yes":
        for i in range(b - 1, B):
            if cntS[i] >= 2:
                ans = "No"

elif a < b < B < A:
    key = 1
    if (s[a - 2] == "#" or s[a] == "#") and ans == "Yes":
        for i in range(b, B):
            if s[i - 1] == "." and s[i + 1] == "." and s[i] == ".":
                print(i)
                s[i] = "#"
                cntS[i] = 1
                key = 0
        if key:
            ans = "No"

    if ans == "Yes":
        for i in range(a - 1, A):
            if cntS[i] >= 2:
                ans = "No"

print(ans)

Submission status: Wrong Answer

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

# 間に＃が連続していなければ通るはず



if not "##" in S[B-1:D-1]:
    S = list(S)
    S[D-1] = "#"
    S = ''.join(S)
    if not "##" in S[A-1:C-1] or "..." in S[B-2:C]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=(int(x) for x in input().split())
S=input()
def Solve():
    if '##' in S[B:D-1] or '##' in S[A:C-1]:#道中に石が2つ並んでたらその時点でアウト
        return 'No'
    if C<D:
        return 'Yes'
    if '...' in S[B:D-1]:
        return 'Yes'
    else:
        return 'No'
    

print(Solve())

Submission status: Wrong Answer

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

S=input()

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

Submission status: Wrong Answer

Solution code:
def solve():
    N, A, B, C, D = [int(_) for _ in raw_input().split()]
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = raw_input()
    R3 = False
    E2 = False
    for i in range (A+1, max(C,D)-1):
        if S[i:(i+3)] == '###':
            R3 = True
            break
    if C == D or R3:
        return False
    elif C < D:
        return True
    elif C > D:
        for i in range (B+1, D-1):
            if S[i:(i+2)] == '..':
                E2 = True
        ret = not R3 and E2
        return ret

if __name__ == '__main__':
    ret = solve()
    if ret:
        print 'Yes'
    else:
        print 'No'

Submission status: Wrong Answer

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

i=0
j=0
gg=0
nnt=0
if c<d:
    i=a-1
    while i!=d:
        if s[i]=="#":
            j=j+1
        else:
            j=0
        if j==2:
            nnt=1
            break
        i=i+1

else:
    i=a-1
    nnt=1
    while i!=d:

        if s[i]==".":
            gg=gg+1
        else:
            gg=0
        if gg==3:
            if i>b:
                if i<c:
                    nnt=0



        if s[i]=="#":
            j=j+1
        else:
            j=0
        if j==2:
            nnt=1
            break

        i=i+1
if nnt==0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import math

n, a, b, c, d = [int(i) for i in input().split()]
#table = [[int(i) for i in input().split()] for m in range(m)]
#light = [int(i) for i in input().split()]
s = input()
list = list(s)

#print(n, m)
#print(table)
#print(light)

flag = 1



#A-C B-Dまでの間に岩が2個並んでいたらアウト

for i in range(a-1, c-1) :
    if ( list[i] == '#') :
        if ( list[i+1] == "#") :
            flag = 0

for i in range(b-1, d-1) :
    if ( list[i] == "#") :
        if ( list[i+1] == "#") :
            flag = 0

# D < C　のとき、A-Cまでの間に、3個以上空白がなければアウト

if (d < c) :
    flag = 0
    for i in range(a-1, d-1) :
        if (list[i] == '.' and list[i+1] == '.' and list[i+2] == '.') :
            flag = 1

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

Submission status: Wrong Answer

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

if ('##' in S[a:c-1]) or ('##' in S[b:d-1]): print('No')
else:
    if d < c:
        if ('...' in S[b:d-1]) or ((S[b-2] == '.' or a == b-1) and S[b] == '.'): 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()
right = max(C,D)-1
r = min(C,D)-1

if '##' in S[A-1:C-1] and '##' in S[B-1:D-1]:
  print('No')
else:
  if C < D:
  	print('Yes')
  else:
    if '...' in S[B-1:right]:
      print('Yes')
    else:
      if len(S[A-1:right])<=6:
        print('Yes')
      print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import sys

def is_dubble_wall(min_, max_, S):
    for i in range(min_, max_):
        if (S[i] == "#") and (i < len(S) - 1) and (S[i + 1] == "#"):
            return True
    return False

def is_change(A, B, C, D):
    if (A < B) and (C > D):
        return True
    elif (A > B) and (C > D):
        return True
    else:
        return False

def main():
    N, A, B, C, D = map(int, input().split())
    S = "#"
    S += input()
    assert(len(S) == N + 1)
    if (B < C) and (A < D):
        if is_dubble_wall(min(A, B), max(C, D), S):
            print("No")
            sys.exit()
        if (is_change(A, B, C, D)):
            #二人が入れ替わる時
            num = 0
            array = []
            for i in range(max(A, B), min(C, D)):
                if S[i] == ".":
                    num += 1
                else:
                    array.append(num)
                    num = 0
            if max(array) >= 3:
                print("Yes")
            else:
                print("No")
        else:
            #入れ替わらない時
            print("Yes")
    else:
        if (~is_dubble_wall(A, C, S) and ~is_dubble_wall(B, D, S)):
            print("Yes")
        else:
            print("No")

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=list(map(int,input().split()))
s=input().rstrip()
vis=[False]*(n)
vis2=[False]*(n)
flag=1
vis[b-1]=True
for i in range(b-1,n):
    if vis[i]==True:
        if i+1<n:
            if s[i+1]=='.':
                vis[i+1]=True
        if i+2<n:
            if s[i+2]=='.':
                vis[i+2]=True
vis2[a-1]=True
for i in range(a-1,n):
    if vis2[i]==True:
        if i+1<n:
            if s[i+1]=='.':
                vis2[i+1]=True
        if i+2<n:
            if s[i+2]=='.':
                vis2[i+2]=True

if vis[d-1]==True and vis2[c-1]==True and c!=d and (vis2[d-1]==False or vis2[d-2]==True):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
#aとbが反転してるかどうが
if (a > b and c > d) or (a < b and c < d):rev = False
else:rev = True
#石と石の間が３以上空いているかどうが
enp = False
#石が二つ連続していないかどうが
ren = True
for i in range(min(a,b)-1,max(c,d)):
    if max(c,d) - 1 <= i:pass
    elif s[i] == '#' and s[i+1] == '#':
        ren = False
    if i >= max(c,d) - 2:continue
    if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
        enp = True
if rev:
    if enp and ren:
        print('Yes')
    else:
        print('No')
else:
    if ren:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = list(input())
n = n-(a-1)
b = b-(a-1)-1
c = c-(a-1)-1
d = d-(a-1)-1
a = a-(a-1)-1
for i in range(a):
    s.pop(0)
for i in range(n-(max(c,d)+1)):
    s.pop(-1)
n -= n-(max(c,d)+1)

check = True
for i in range(n-1):
    if s[i] == "#" and s[i+1] == "#":
        check = False

temp = False
for i in range(b,d+1):
    if i+1 < n:
        if s[i] == "." and s[i-1] == "." and s[i+1] == ".":
            temp = True
            break
    else:
        temp = True


if check == False:
    print("No")
else:
    if temp:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

S_before_a = S.copy()
S_before_a[B-1] ='#'
A_list = S_before_a[A:C-1]
count = 0
for i in range (len(A_list)-1):
    if ''.join(A_list[i:i+2])=='##':
        count+=1

S_after_a = S.copy()
S_after_a[C-1]='#'

B_list = S_after_a[B:D-1]
for i in range (len(B_list)-1):
    if ''.join(B_list[i:i+2])=='##':
        count+=1
    
#count逆
S_before_b = S.copy()
S_before_b[A-1] ='#'
B_list = S_before_b[B:D-1]
count2 = 0
for i in range (len(B_list)-1):
    if ''.join(B_list[i:i+2])=='##':
        count2+=1

S_after_b = S.copy()
S_after_b[D-1]='#'

A_list = S_after_b[A:C-1]
for i in range (len(A_list)-1):
    if ''.join(A_list[i:i+2])=='##':
        count2+=1
        
if count == 0 and count2 ==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

listA=list(map(int,input().split()))

kenken_map = input()

A_init = listA[1]-1
B_init = listA[2]-1
A_goal = listA[3]-1
B_goal = listA[4]-1


kenken_temp = kenken_map[B_init:]
kenken_temp_b = kenken_map[:B_goal] + '#' + kenken_temp[B_goal+1:]

if '##' in kenken_temp or '##' in kenken_temp_b:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

if ('##' in s[b:d]) or ('##' in s[a:c]):
    print('No')
elif c > d:
    if '...' in s[b - 1:d + 1]:
        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()

def judge(start,goal):
    for i in range(start,goal-1):
        if s[i] == "#" and s[i+1] == "#":
            return 0
    return 1

def full_judge (start,obst,obfin,goal):
    if s[obst-2] == "." and s[obst] == "." :
        return 1
    for i in range(obst-1,obfin-2):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            return 1
    return 0


if c<b:
    if (judge(a,c) and judge(b,d)):
        print("Yes")
    else:
        print("No")
elif c<d:
    if (judge(a,c) and judge(b,d)):
        print("Yes")
    else:
        print("No")
else:
    if judge(b,d) and full_judge(a,b,d,c) and judge(a,c):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

if "##" in S:
    print("No")
else:
    S = S[min(A, B)-1:max(C, D)]
    if "..." in S:
        print("Yes")
    else:
        if C < D:
            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
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 - 1 and i <= n - 3:
            if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
                clearflag = 1

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