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()

if c<d:
    s = list(s)
    h = s[b:d]
    for i in range(1,len(h)):
        if h[i]==h[i-1] and h[i]=="#":
            print("No")
            break
    else:
        hh = s[a:c]
        for i in range(1,len(hh)):
            if hh[i]==hh[i-1] and hh[i]=="#":
                print("No")
                break
        else:
            print("Yes")
else:
    if "..." in s[b:d+1]:
        h = s[a:c]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            hh = s[b:d]
            for i in range(1,len(hh)):
                if hh[i]==hh[i-1] and hh[i]=="#":
                    print("No")
                    break
            else:
                print("Yes")
    else:
        s = list(s)
        h = s[b:d]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            s[d-1]="#"
            hh = s[a:c]
            for i in range(1,len(hh)):
                if hh[i]==hh[i-1] and hh[i]=="#":
                    print("No")
                    break
            else:
                print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = "No"
if "##" in s[a-1:c] or "##" in s[b-1:d]: pass
else:
    # Bを先にゴールさせる
    l = list(s) ; l[d-1]="#" ; s2 = "".join(l)
    if "##" in s2[0:c]:
        # Aを先にゴールさせる可能性
        if "..." in s[b:d-1]:
                l = list(s) ; l[c-1]="#" ; s3 = "".join(l)
                if "##" in s3[0:d]: pass
                else: ans = "Yes"
    else: ans = "Yes"


print(ans)

Submission status: Wrong Answer

Solution code:
def count_renzoku_char(s, char):
    max_len = 0
    current_len = 0
    for c in s:
        if c == char:
            current_len += 1
        else:
            if max_len < current_len:
                max_len = current_len
            current_len = 0
 
    return max_len
 
if __name__ == "__main__":
    N, A, B, C, D = [int(x) for x in input().split()]
    S = input()
 
    def main():
        if C < D:
            raw_sharp = count_renzoku_char(S[B+1: D], '#')
            if raw_sharp >= 2:
                print('No')
                return
 
            raw_sharp = count_renzoku_char(S[A+1: C], '#')
            if raw_sharp >= 2:
                print('No')
                return
            else:
                print('Yes')
                return
        else:
            raw_sharp = count_renzoku_char(S[A+1: C], '#')
            if raw_sharp >= 2:
                print('No')
                return
 
            raw_space = count_renzoku_char(S[B-1: D+1], '.')
            if raw_space >= 3:
                print('Yes')
                return
            else:
                print('No')
                return
 
    main()

Submission status: Wrong Answer

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

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

    if c < d:
        return "Yes"
    
    else:

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

print(main())

Submission status: Wrong Answer

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

if c<d:
    s = list(s)
    h = s[b:d]
    for i in range(1,len(h)):
        if h[i]==h[i-1] and h[i]=="#":
            print("No")
            break
    else:
        hh = s[a:c]
        for i in range(1,len(hh)):
            if hh[i]==hh[i-1] and hh[i]=="#":
                print("No")
                break
        else:
            print("Yes")
else:
    if "..." in s[b:d+1]:
        h = s[a:c]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            hh = s[b:d]
            for i in range(1,len(hh)):
                if hh[i]==hh[i-1] and hh[i]=="#":
                    print("No")
                    break
            else:
                print("Yes")
    else:
        s = list(s)
        h = s[b:d]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            if s[d-2]=="#" or s[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=list(input())
sa=A-1
sb=B-1
ag=C-1
bg=D-1

def jama(S,a,b):
    ssa=b-a
    c=0
    while c<ssa-2:
        if S[a+c+1]=='#':
            if S[a+c+2]=='#':
                return(0)
                break
        c=c+1
    return(1)
if ag<bg:
    if jama(S,sa,bg)==1:
        print('Yes')
    else:
        print('No')
else:
    if jama(S,sa,ag)==0:
        print('No')
    else:
        ccc=0
        start=sb
        while start<bg-3:
            if S[start]=='.':
                if S[start+1]=='.':
                    if S[start+2]=='.':
                        ccc=1
                        break
            start=start+1
        if ccc==1:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

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

ans = "No"
if "##" in s[a-1:c] or "##" in s[b-1:d]: pass
else:
    # Bを先にゴールさせる
    l = list(s) ; l[d-1]="#" ; s2 = "".join(l)
    if "##" in s2[0:c]:
        # Aを先にゴールさせる可能性
        if "..." in s[b:d-1]:
            s = s[0:b] + s[b:d].replace("...",".#.") + s[d:n]
            if s[c-1]=="#": pass
            else:
                l = list(s) ; l[c-1]="#" ; s3 = "".join(l)
                if "##" in s3[0:d]: pass
                else: ans = "Yes"
    else: ans = "Yes"


print(ans)

Submission status: Wrong Answer

Solution code:
def main():
	n,a,b,c,d = map(int,input().split())
	a-=1
	b-=1
	c-=1
	d-=1
	s = input()
	for i in range(b,max(c,d)):
		if s[i]==s[i+1]=='#':
			print('NO')
			return
	if c<d:
		print('YES')
		return
	else:
		if d!=0 and d!=n-1 and s[d-1] == s[d+1] == '.':
			print('YES')
		else:
			print('NO')
		return

main()

Submission status: Wrong Answer

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

if c<d:
    s = list(s)
    h = s[b:d]
    for i in range(1,len(h)):
        if h[i]==h[i-1] and h[i]=="#":
            print("No")
            break
    else:
        hh = s[a:c]
        for i in range(1,len(hh)):
            if hh[i]==hh[i-1] and hh[i]=="#":
                print("No")
                break
        else:
            print("Yes")
else:
    if "..." in s[b:d+1]:
        h = s[a:c]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            hh = s[b:d]
            for i in range(1,len(hh)):
                if hh[i]==hh[i-1] and hh[i]=="#":
                    print("No")
                    break
            else:
                print("Yes")
    else:
        s = list(s)
        h = s[b:d]
        for i in range(1,len(h)):
            if h[i]==h[i-1] and h[i]=="#":
                print("No")
                break
        else:
            print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, a, b, c, d = map(int, input().split())
s = input()

# construct rle
rle = list()
last_masu = s[b - 1]
cnt = 0
for masu in s[b - 1:max(c, d)]:
    if masu == last_masu:
        cnt += 1
    else:
        rle.append(cnt)
        last_masu = masu
        cnt = 1
rle.append(cnt)

for idx in range(1, len(rle), 2):
    if rle[idx] > 1:
        print('No')
        exit()

if c > d:
    is_reverse = True
else:
    is_reverse = False

if is_reverse:
    flag = False
    for idx in range(0, len(rle), 2):
        if rle[idx] > 2:
            flag = True
            break
    if flag:
        print('Yes')
    else:
        print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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


def get(a, b):
  s = S[:]
  s[a] = 'A'
  s[b] = 'B'

  return s


def check(s, i, dest):
  while i < dest:
    i += 1
    if i <= dest and s[i] == '.':
      continue
    i += 1
    if i <= dest and s[i] == '.':
      continue

    return False

  return i == dest


def move(s, i, dest):
  if i == dest:
    return -1

  while i < dest:
    i = i + 1
    if i + 1 < N:
      if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
        return i

  return i if i == dest else -1


def main():
  a = A
  b = B

  for _ in range(1000):
    s = get(a, b)
    is_a = check(s, a, C)
    is_b = check(s, b, D)

    if is_a and is_b:
      return True

    if C > D:
      if is_a:
        a = C
      else:
        b = move(s, b, D)
        if b < 0:
          return False
    else:
      if is_b:
        b = D
      else:
        a = move(s, a, C)
        if a < 0:
          return False


print('Yes' if main() else 'No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
## AからＣ　ＢからＤに移動させたい
## C<D なら簡単

N,A,B,C,D = map(int,input().split())
S = input()
flag = 0
obs = []
esc = []
ans = 1

#ＡとＢで小さいほうを low
if A<B:
    low = A
    mid1 = B
else:
    low = B
    mid1 = A
#ＣとＤで大きいほうをhigh
if C<D:
    high = D
    mid2 = C
else:
    high = C
    mid2 = D



for i in range(low,high-1):
     if S[i]=="#" and S[i+1]=="#":
         ans = 0


 # obsに通れない位置を入力
flag = 0
flag2 = 1
if D<C:
    flag2 = 0
    for i in range(B,D):
          if S[i]=="." and flag == 2:
              flag2 = 1
              flag = 0
          elif S[i] == ".":
              flag += 1
          else:
              flag = 0
if flag2 ==0:
    ans = 0


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

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

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

ans = 'Yes'

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

if D > C:
    ans = ans

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

        if ss[i-1] == 0 and ss[i] == 0 and ss[i+1] == 0 :
            ans = ans
        else :
            ans = 'No'

print(ans)

Submission status: Wrong Answer

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

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

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

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

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


print(result)



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


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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, a, b, c, d = map(int, input().split())
s = input()

# construct rle
rle = list()
last_masu = s[b - 1]
cnt = 0
for masu in s[b - 1: d]:
    if masu == last_masu:
        cnt += 1
    else:
        rle.append(cnt)
        last_masu = masu
        cnt = 1
rle.append(cnt)

for idx in range(1, len(rle), 2):
    if rle[idx] > 1:
        print('No')
        exit()

if c > d:
    is_reverse = True
else:
    is_reverse = False

if is_reverse:
    flag = False
    for idx in range(0, len(rle), 2):
        if rle[idx] > 2:
            flag = True
            break
    if flag:
        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 = str(input())

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

Submission status: Wrong Answer

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

s = input()

flagA = True
flagB = True

for i in range(d - b - 1):
    if s[b + i] == "#" and s[b + i + 1] == "#":
        flagB = False

for i in range(c - a - 1):
    if ((s[a + i] == "#") or (a + i == d - 1)) and ((s[a + i + 1] == "#") or (a + i + 1 == d - 1)):
        flagA = False
        for j in range(1, d - b - 1):
            if (s[b + j - 1] == "." and s[b + j] == "." and s[b + j + 1] == "."):
                flagA = True
            # if (s[b + 1] == "." and s[b + 2] == "."):
            #     flagA = True

if flagA and flagB:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

flag = 1

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

    if c < d:
        return "Yes"
    
    else:

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

print(main())

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(input())
last = ""
for i in range(a, c):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
last = ""
for i in range(b, d):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
last = ""
if c > d:
    flag = True
    s[b - 1] = "#"
    for i in range(a, c):
        if last == "#" and s[i] == "#":
            flag = False
        last = s[i]
    s[b - 1] = "."
    count = 0
    for i in range(b - 1, c):
        if s[i] == ".":
            count += 1
            if count == 3:
                flag = True
        else:
            count = 0
    if flag:
        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 max_stone(a, b):
  m = 0
  for j in range(a, b-1):
    if S[j] == S[j+1] == '#':
      return False
  
  return True
  
def reachable(b, d):
  n_sharp = 0
  n_dot = 0
  for j in range(b-1, d):
    s = S[j]
    if s=='.':
      n_dot += 1
      n_sharp = 0
    else:
      n_sharp += 1
      n_dot = 0
      
    if n_dot == 3:
      return True
    elif n_sharp == 2:
      return False
    
  return False
  
if C < B:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C < D:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C > D:
  if reachable(B-1, D-1) and max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')

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(a,d-1):
        if s[i]==s[i+1]=='#':
            print('No')
            exit()
    print('Yes')
else:
    flag = False
    for i in range(a,c-1):
        if s[i]==s[i+1]=='#':
            print('No')
            exit()
    for i in range(b-1,d-1):
        if s[i]==s[i+1]==s[i+2]=='.':
            flag = True
    if not flag:
        print('No')
        exit()
    print('Yes')

Submission status: Wrong Answer

Solution code:
## AからＣ　ＢからＤに移動させたい
## C<D なら簡単

N,A,B,C,D = map(int,input().split())
S = input()
flag = 0
obs = []
esc = []
ans = 1

#ＡとＢで小さいほうを low
if A<B:
    low = A
    mid1 = B
else:
    low = B
    mid1 = A
#ＣとＤで大きいほうをhigh
if C<D:
    high = D
    mid2 = C
else:
    high = C
    mid2 = D



for i in range(low,high-1):
     if S[i]=="#" and S[i+1]:
         ans = 0
    

 # obsに通れない位置を入力
flag = 0
flag2 = 1
if D<C:
    flag2 = 0
    for i in range(B,D):
          if S[i]=="." and flag == 2:
              flag2 = 1
              flag = 0
          elif S[i] == ".":
              flag += 1
          else:
              flag = 0
if flag2 ==0:
    ans = 0


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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
s = list(input())
s_a =s[A-1:C]
s_b = s[B-1:D]

count = 0
if C < D :

    for i in range(C-A):
        if s_a[i] == "#" and s_a[i+1] == "#" :
            count += 1
    for i in range(D-B) :
        if s_b[i] == "#" and s_b[i+1] == "#" : 
            count += 1

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


else :
    p = 0
    for i in range(C-A):
        if s_a[i] == "#" and s_a[i+1] == "#" :
            count += 1
    for i in range(D-B) :
        if s_b[i] == "#" and s_b[i+1] == "#" : 
            count += 1
    
    for i in range(D-B-1):
        if s_b[i] == "." :
            if  s_b[i+1] == "." and s_b[i+2]=="." :
                p += 1
    
    if p >= 1 and count == 0:
        print("Yes")
    else: print("No")

Submission status: Wrong Answer

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

s = input()

flagA = True
flagB = True

for i in range(d - b - 1):
    if s[b + i] == "#" and s[b + i + 1] == "#":
        flagB = False

for i in range(c - a - 1):
    if ((s[a + i] == "#") or (a + i == d - 1)) and ((s[a + i + 1] == "#") or (a + i + 1 == d - 1)):
        flagA = False
        for j in range(d - b - 2):
            if (s[b + j - 1] == "." and s[b + j] == "." and s[b + j + 1] == "."):
                flagA = True
            # if (s[b + 1] == "." and s[b + 2] == "."):
            #     flagA = True

if flagA and flagB:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#これが一番できたやつ

import sys
N, A, B, C, D = map(int, input().split())
S = str(input())

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

Submission status: Wrong Answer

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

two_sharp = False
three_point = False

short_str = S[A:max(C, D)]

n = len(short_str)
S = short_str
for j in range(n-2):
  if S[j] == '.' and S[j+1] == '.' and S[j+2] == '.':
    three_point = True

  if S[j] == '#' and S[j+1] == '#':
    two_sharp = True

if two_sharp:
  print 'No'
elif D > C:
  print 'Yes'
elif C > D:
  if three_point:
    print 'Yes'
  else:
    print 'No'

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

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

ans = 'Yes'

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

if D > C:
    ans = ans

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

        if ss[i-1] == 0 and ss[i] == 0 and ss[i+1] == 0 :
            ans = ans
        else :
            ans = 'No'

print(ans)

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 S[A:C] in '##' or S[B:D] in '##':
    print("No")
    exit()
if C > D:
    if S[B-2:D+1] in '...':
        print("Yes")
        exit()
    else:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
#これが一番できたやつ

import sys
N, A, B, C, D = map(int, input().split())
S = str(input())

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if s[a-1:max(c,d)].count("##")>0:
    print("No")
elif c<d:
    print("Yes")
else:
    if "..." in s[b-1:d+1]:
        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:
    if S[A-1:].count('##') > 0:
        print('No')
    else:
        print('Yes')
else:
    if S[A-1:].count('##') == 0 and S[B-1:D].count('...') > 0:
        print('Yes')
    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
 
a_s = s[a:c]
b_s = s[b:d]
 
 
if d < c:
  if '...' in s[b-1:d]:
    santen_flag = True
  
if not '##' in a_s and not '##' in b_s:
  kome_flag = True

else:
	if c < d:
		if kome_flag:
			print('Yes')
		else:
			print('No')
 
	if d < c:
		if kome_flag and santen_flag:
			print('Yes')
		else:
			print('No')

Submission status: Wrong Answer

Solution code:
import sys
 
N, A, B, C, D = list(map(int, input().split()))
 
S = input()
 
# ゴールまでに#の連続があるか
for i in range(A,max(C,D)-1):
    if S[i:i+2]  == '##':
        print('No')
        sys.exit()
 
# 追い越す必要がある場合
if C > D:
    for i in range(B,D):
        if S[i-1:i+2] == '...':
            print('Yes')
            sys.exit()
    else:
        print('No')
        sys.exit()
 
print('Yes')

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

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

ans = 'Yes'

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

if D > C:
    print(ans)
elif C < D:
    for i in range(D - B):
        i = i + B

        if ss[i-1] == 0 and ss[i] == 0 and ss[i+1] == 0 :
            print(ans)
        else :
            ans = 'No'
            print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = list(map(int, input().split()))
s = input()
sbd = s[b - 1:d + 1]

t2 = "##" in s
u3 = "..." in sbd

if c == d:
    print("No")
elif c < d:
    print("Yes" if not t2 else "No")
else:
    print("Yes" if (not t2) and u3 else "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
 
a_s = s[a:c]
b_s = s[b:d]
 

if d < c:
  if '...' in s[b-1:d]:
    santen_flag = True
  
if not '##' in a_s and not '##' in b_s:
  kome_flag = True
    
if not '#' in a_s and not '#' in b_s:
	print('Yes')
else:
	if c < d:
		if kome_flag:
			print('Yes')
		else:
			print('No')
 
	if d < c:
		if kome_flag and santen_flag:
			print('Yes')
		else:
			print('No')

Submission status: Wrong Answer

Solution code:
#これが一番できたやつ

import sys
N, A, B, C, D = map(int, input().split())
S = str(input())

if D > C:
    if '##' in S[B:D] or '##' in S[A:C]:
        print('No')
    else:
        print('Yes')
elif C > D:
    if '...' in S[A: C] and '##' not in S[A: C]:
        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

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

Submission status: Wrong Answer

Solution code:
import sys
 
N, A, B, C, D = list(map(int, input().split()))
 
S = input()
 
# ゴールまでに#の連続があるか
for i in range(A,max(C,D)):
    if S[i-1:i+1]  == '##':
        print('No')
        sys.exit()
 
# 追い越す必要がある場合
if C > D:
    for i in range(B,D):
        if S[i-1:i+2] == '...':
            print('Yes')
            sys.exit()
    else:
        print('No')
        sys.exit()
 
print('Yes')

Submission status: Wrong Answer

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

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

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

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

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

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

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

# Output
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np

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

ans = 'Yes'

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

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

        if ss[i-1] == 0 and ss[i] == 0 and ss[i+1] == 0 :
            ans    
        else :
            ans = 'No'

print(ans)

Submission status: Wrong Answer

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

flag = 1

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

    if c < d:
        return "Yes"
    
    else:

        if s[b] == "#":
            for i in range(len(s[b:c-3])):
                if s[i:i+3] == "...":
                    return "Yes"            
            return "No"

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

print(main())

Submission status: Wrong Answer

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