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:
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 < max_ - 1) and (S[i + 1] == "#"):
            return True
    return False

def is_change(A, B, C, D):
    if (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):
        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(B - 1, D + 2):
                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 = map(int, input().split())
S = input()
cou1 = 0
ans1 = 0
cou2 = 0
ans2 = 0
S2 = S[A:]
if C < D:
    S1 = S[A: D-1]
    for i in S1:
        if i == "#":
            cou1 += 1
        else:
            ans1 = max(ans1, cou1)
            cou1 = 0
    if ans1 < 2:
        print("Yes")
    else:
        print("No")
else:
    for i in S2:
        if i == "#":
            cou1 += 1
            ans2 = max(ans2, cou2)
            cou2 = 0
        else:
            cou2 += 1
            ans1 = max(ans1, cou1)
            cou1 = 0
        if ans2 == 3 and ans1 < 2:
            print("Yes")
            break
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys

n, a, b, c, d = map(int, input().split())
s = [ s for s in input()]
a = a-1
b = b-1
s[a] = "a"
s[b] = "b"

result = True
cnt = 0

if c > d and a < b:
    while True:
        if b+1 < n and (s[b+1] != "a" and s[b+1] != "#"):
            s[b+1] = "b"
            s[b] = "."
            b += 1
        elif b+2 < n and (s[b+2] != "a" and s[b+2] != "#"):
            s[b+2] = "b"
            s[b] = "."
            b += 2
        else:
            cnt = 1
        if b+1 >= n:
            resut = False
            break
        elif s[b-1] == "." and s[b+1] == ".":
            break
        if cnt == 1:
            result = False
            break
    while a < b:
        if a+2 < n and (s[a+2] != "b" and s[a+2] != "#"):
            s[a+2] = "a"
            s[a] = "."
            a += 2
        elif a+1 < n and (s[a+1] != "b" and s[a+1] != "#"):
            s[a+1] = "a"
            s[a] = "."
            a += 1
        else:
            reult = False
            break
if not result:
    print("NO\n")
    sys.exit(0)

while True:
    if a != c-1:
        if a+2 < n and (s[a+2] != "b" and s[a+2] != "#"):
            s[a+2] = "a"
            s[a] = "."
            a += 2
        elif a+1 < n and (s[a+1] != "b" and s[a+1] != "#"):
            s[a+1] = "a"
            s[a] = "."
            a += 1
        else:
            cnt += 1
    if b != d-1:
        if b+2 < n and (s[b+2] != "a" and s[b+2] != "#"):
            s[b+2] = "b"
            s[b] = "."
            b += 2
        elif b+1 < n and (s[b+1] != "a" and s[b+1] != "#"):
            s[b+1] = "b"
            s[b] = "."
            b += 1
        else:
            cnt += 1
    if cnt == 2:
        result = False
        break
    if a == c-1 and b == d-1:
        break
if result:
    print("YES\n")
else:
    print("NO\n")

Submission status: Wrong Answer

Solution code:
s = str(input())
flag=1
ans = 0
while(flag==1):
    flag=0
    if s.count("ABC") > 0:
        flag=1
        ans = ans+s.count("ABC")
        s.replace("ABC","BCA")

print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
obs = [S[i] is "#" and S[i+1] is "#" for i in range(max(C,D)-1)]
space = [S[i] is "." and S[i+1] is "." and S[i+2] is "." for i in range(max(C,D)-2)]
if C < D:
  if True in obs[B:D] or True in obs[A:C]:
    print("No")
  else:
    print("Yes")
else:
  if True not in space[B-1:D]:
    print("No")
  elif True in obs[B:D-1] or True in obs[A:C-1]:
    print("No")
  else:
    print("Yes")
    
    
print(space)

Submission status: Wrong Answer

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

lis = list(input())

lis.append(".")
lis.append(".")

dbl = -1
middle = -1

for i in range(n):
  if lis[i] == "#" and lis[i+1] == "#":
    dbl = i
    
for k in range(b-1,c):
  if lis[k] == "." and lis[k+1] == "." and lis[k+2] == ".":
    middle = k+1
    break
    

if dbl != -1 and not (c-1 < dbl and d-1 < dbl):
  print("No")
elif c > d:
  if middle != -1 and middle < c:
    print("Yes")
  else:
    print("No")
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,a,b,c,d=LI()
  s=S()

  if '##' in s[a-1:c]:
    return 'No'
  if '##' in s[b-1:d]:
    return 'No'
  
  if d<c:
    # print(s[b-2:c])
    if '...' not in s[b-2:c]:
      return 'No'

    if s[d-2:d+1]=='#.#':
      return 'No'

  return 'Yes'

print(main())

Submission status: Wrong Answer

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

if C < D:
    for i in range(B - 1, D - 2, 1):
        if S[i] == "#" and S[i + 1] == "#":
            print("No")
            exit()

else:
    S[D - 1] = str("#")
    S[B - 1] = str("#")
    for i in range(A, C - 2, 1):
        if S[i - 1] == "." and S[i] == "." and S[i + 1] == ".":
            t = 1

    for i in range(A - 1, C - 2, 1):

        if S[i] == "#" and S[i + 1] == "#":
            if (i == B - 1 or i + 1 == B - 1) or t:
                f = 1
                continue
            if ((i == D - 1 or i + 1 == D - 1) and f == 0) or t:
                continue
            print("No")
            exit()

print("Yes")

Submission status: Wrong Answer

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

m = max([c, d])
if n>m:
    n = m
    s = s[:n]
    
if '##' in s:
    print('No')
else:
    if c>d:
        if '...' in s:
            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

"""
Sa = "."
for i in range(a+1,len(S)) :
    Sa += S[i]
    if S[-2:] == "##" :
        break
for i in range(a-1,-1,-1) :
    Sa += S[i]
    if S[:2] == "##" :
        break

Sb = ""
for i in range(b+1,len(S)) :
    Sb += S[i]
    if S[-2:] == "##" :
        break
for i in range(b-1,-1,-1) :
    Sb += S[i]
    if S[:2] == "##" :
        break
"""
if S[a:(c+1)].count("##") == 0 :
    flg1 = 1
else :
    flg1 = 0

if S[b:(d+1)].count("##") == 0 :
    flg2 = 1
else :
    flg2 = 0

if c < d :
    flg3 = 1
else :
    if S.count("...") >= 1 :
        flg3 = 1
    else :
        flg3 = 0

    
if flg1*flg2*flg3 :
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

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

flag3 = 0
flagno = 0

if c > d:

    for i in range(a,c-2):

        if s[i:i+2] == "##":
            flagno += 1
            break

    if flagno == 0:

        for i in range(b,c-2):
        
            if s[i-2:i+1] == "...":
                flag3 += 1
                break
    
    if flagno == 0 and flag3 > 0:
        print("Yes")

    else:
        print("No")

else:

    for i in range(a,d-2):

        if s[i:i+2] == "##":
            flagno += 1
            break
    
    if flagno == 0:
        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
#石が二つ連続していないかどうが
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
#石と石の間が３以上空いているかどうが
enp = False
for i in range(max(a,b)-2,min(c,d)):
    if i >= n - 2:continue
    if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
        enp = True

if min(c,d) < max(a,b):
    syo = dai = True
    for i in range(min(a,b)-1,min(c,d)):
        if min(c,d) - 1 <= i:pass
        elif s[i] == '#' and s[i+1] == '#':
            syo = False
    for i in range(max(a,b)-1,max(c,d)):
        if max(c,d) -1 <= i:pass
        elif s[i] == '#' and s[i+1] == '#':
            dai = False
    if syo and dai:
        rev = enp = ren = True
    else:
        rev = enp = ren = False

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=input().strip()
for i in s:
  if i=='.':
    i=0
  else:
    i=1
cst=0
ans=0
for j in range(n):
    i=s[j]
    if i==0:
        if s[j-2]*s[j-1]==1:
            cst=1
    else:
        if s[j-1]==1:
            if (j>a and j<c) or (j>b and j<d):
                ans=1
if ans==1:
    print('No')
elif c>d and cst==0:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

#N,A,B,C,D = 15,1,3,15,13
#S = "...#.#...#.#..."

#N,A,B,C,D = 4,1,2,4,3
#S = "...."

S = "#" + S + "#"
N = N+2

M = max(C,D)

if "##" in S[A:M+1]:
	print('No')
	exit()
if C < D:
	print('Yes')
	exit()

pos = B
while(True):
	if pos == D:
		if S[pos+1] == "#" or S[pos-1] == "#":
			print("No")
			exit()
		else:
			print("Yes")
			exit()
	if pos == D-1:
		if S[pos+2] == "#" and S[pos-1] == "#":
			print("No")
			exit()
		else:
			print("Yes")
			exit()
	loc = S[pos+1:pos+3]
	if loc == "..":
		print('Yes')
		exit()
	if loc == "#.":
		pos += 2
	if loc == ".#":
		pos += 3

Submission status: Wrong Answer

Solution code:
from sys import stdin, exit

N, A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
for k in range(A - 1, max(D, C)):
    if S[k] == '#' and S[k + 1] == '#':
        print('No')
        exit()

if C < D:
    print('Yes')
else:
    cnt = 0
    for k in range(B - 1, D):
        if S[k] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt > 2:
            print('Yes')
            exit()
    print('No')

Submission status: Wrong Answer

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

S = input()

def AA(mojiretu):
    if '##' in mojiretu:
     print("No")
    else:
     print("Yes")

Scp = S
if C < D:
      Scp = Scp[:D-1]+"#" + Scp[D:]
      AA(Scp[:D])
      
else:
    if "..." in Scp[B-1:D]:
      AA(Scp[:C])
    else:
      Scp = Scp[:D-1]+"#" + Scp[D:]
      AA(Scp[:C])

Submission status: Wrong Answer

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

str_ac = str[A:C-1]
str_bd = str[B:D-1]
#print(str_ac)
#print(str_bd)

if C<D:
  if str_bd.find("##") != -1 or str_ac.find("##") != -1:
    print("No")
  else:
    print("Yes")
else:
  if str_bd.find("##") != -1:
    print("No")
  elif str_bd.find("...") != -1 and str_ac.find("##") == -1:
    print("Yes")
  else:
    str_b = str[:B-1] + "#" + str[B:]
    str_d = str[:D-1] + "#" + str[D:]
    str_b_ac = str_b[A:C-1]
    str_d_ac = str_d[A:C-1]
    #print(str)
    #print(str_ac)
    if str_b_ac.find("##") == -1 or str_d_ac.find("##") == -1:
      print("Yes")
    else:
      print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
j = 0
flag = False
fflag = False

if '#' not in s:
  flag = True

for i, k in enumerate(s):
  if k == '.':
    j += 1
  else:
    if j >= 3 and i - j + 1 < d and b < i:
      flag = True
    if s[i-1] == '#' and i < max(c, d):
      fflag = True
    j = 0

if fflag:
  print('No')
else:
  if c > d and flag:
    print('Yes')
  elif c < d:
    print('Yes')
  else:
    print('No')

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

switch = 0

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
        
change_counter =0
changer = S[max(A,B):min(C,D)-1]
for i in range(len(changer)-2):
    if ''.join(changer[i:i+3])=='...':
        change_counter+=1
        
if count == 0 or count2 ==0:
    print('Yes')
elif (count == 1 and change_counter>0 ) or (count2 == 1 and change_counter>0 ):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

    else:
        print("Yes")

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 f(A, B, C, D, S):
    T = list(S)
    T[A] = "A"
    T[B] = "B"
    T[C] = "C"
    T[D] = "D"
    print("".join(T))


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
    # f(A, B, C, D, S)

    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
        if reachable(A, B-1+oikoshi, S) and reachable(B, B-1+oikoshi+1, S):
            A = B-1+oikoshi + 2
            B = B-1+oikoshi + 1
            # f(A, B, C, D, S)
        else:
            no()
            return

    # ２連岩なければ通れる
    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 = 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-1:C]:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
# A問題
N, A, B, C, D = map(int, input().split())
S = input()
flag = False
S = S[A-1:]

if C < D:   # AがBを飛び越えない時
    if S.count("##") > 0:
        if S[A-1:C-1].count("##") > 0 or S[B-1:D-1].count("##") > 0:
            flag = False
        else:
            flag = True
    else:
        flag = True
else:   # AがBを飛び越えるとき
    if S.count("##") > 0:   
        flag = False
    else:
        if S.count("...") > 0:
            if S[B] == ".":
                flag = True
            if S[B] == "#":
                if S[B:].count("...") > 0:
                    flag = True
                else:
                    flag = False
            else:
                flag = True
        else:
            if S[D] == "#" or S[D-2] == "#":
                flag = False
            else:
                flag = True
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

def syori1(sunuke,hunuke):
    while hunuke<D:
        if hunuke+1 == N:
            return "Yes"
        if S[hunuke+1] == ".":
            hunuke += 2
        elif S[hunuke] == ".":
            hunuke += 1
        else:
            return "No"
    
    while sunuke<C:
        if sunuke + 1 == N:
            return "Yes"
        if S[sunuke+1] == ".":
            sunuke += 2
        elif S[sunuke] == ".":
            sunuke += 1
        else:
            return "No"
    
    return "Yes"

def canover():
    for i in range(B-1,D-2):
        if S[i] == "." and S[i+1] == "." and S[i+2]==".":
            return True
        else:
            pass
    return False
    
def tonari():
    if S[B]==".":
        return True
    else:
        return False

if C > D:
    if A+1 == B:
        if tonari():
            print(syori1(sunuke,hunuke))
            exit()
            
    if canover():
        print(syori1(sunuke,hunuke))
    else:
        print("No")
else:
    print(syori1(sunuke,hunuke))

Submission status: Wrong Answer

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

if c<d:
    m=d
else:
    m=c

for i in range(a, m-2):
        if s[i] == '#' and s[i+1] == '#':
            ans=0

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

Submission status: Wrong Answer

Solution code:
import re

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

pat1 = '##'
pat2 = r'\.\.\.'

sm = int(c) if int(c) < int(d) else int(d)
lg = int(c) if int(c) > int(d) else int(d)

sh = li[:sm]
sh = li[int(b) - 2:]
lo = li[:lg]
lo = li[int(a):]
ret = ''
# print(sh)
if re.match(pat1, lo):
    ret = 'No'
else:
    if c > d:
        if re.match(pat2, sh):
            ret = 'Yes'
        else:
            ret = 'No'
    else:
        ret = 'Yes'
    

print(ret)

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 and S[B-1:D].count('...') == 0):
            print(NO)
        # elif()
        else:
            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=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 b-1<=i and i<=d-1:
      if s[i-1]!="#" and s[i+1]!="#":
        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=input()

if c<d:
    if '##' in s:
        print('No')
    else:
        print('Yes')
elif d<c:
    if '##' in s:
        print('No')
    else:
        if '...' in 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 = 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[a: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:
import sys
import copy

def solve(n, a, b, c, d, s):
    if c < d:
        if b < c:
            width = [(a-1, d-1)]
        else:
            width = [(a-1, c-1), (b-1, d-1)]

        for left, right in width:
            for i in range(left, right):
                if s[i] == "#" and s[i+1] == "#":
                    return "No"
                else:
                    return "Yes"
    else:
        for i in range(a-1, c-1):
            if s[i] == "#" and s[i+1] == "#":
                return "No"
            elif b - 1 < i < d - 1 and s[i] == "." and s[i+1] == "." and  s[i+2] == "." :
                return "Yes"
        return "No"


if __name__ == '__main__':

    n, a, b, c, d = map(int, sys.stdin.readline().strip().split(" "))
    s = sys.stdin.readline().strip()
    print solve(n, a, b, c, d, s)

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
ans = False
if C < B:
    # A ~ C に行けるか
    # B ~ D に行けるか
    count_x = 0
    ans = True
    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:
    # B ~ D に行けるか
    # A ~ C に行けるか
    count_x = 0
    ans = True
    for i in range(A, D):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
else:
    # A ~ Cに行けるか
    # AがBを超えれるか
    # (B~Dに3つ以上の連続空きがある)
    count_x = 0
    ans = True
    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:
n, a, b, c, d = map(int, input().split())
s = input().rstrip()

a, b, c, d = a - 1, b - 1, c - 1, d - 1

if s.find('##', b, d + 1) != -1 or s.find('##', a, c + 1) != -1:
    ans = 'No'
elif c < d:
    ans = 'Yes'
elif s[d - 1] == '.' and s[d + 1] != '#':
    ans = 'Yes'
elif s.find('..', b + 1, d - 1) != -1:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, input().split())
A -= 1
B -= 1
C -= 1
D -= 1
s = str(input())
if C < D:
    if "##" in s[A:C] or "##" in s[B:D]:
        print("No")
    else:
        print("Yes")
else:
    if "##" in s[A:C] or "##" in s[B:D]:
        print("No")
    else:
        if D-B >= 2:
            if "..." in s[B:D+1]:
                print("Yes")
            elif s[D-1] == ".":
                print("Yes")
            else:
                print("No")
        else:
            if s[B+2] == "." or s[B-1] == ".":
                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):
     if S[i]=="#" and flag == 1:
         obs.append(i)
         flag = 0
     elif S[i] == "#":
         flag = 1
     else: flag = 0

 # obsに通れない位置を入力
flag = 0
for i in range(low,high):
      if S[i]=="." and flag == 2:
          esc.append(i)
          flag = 0
      elif S[i] == ".":
          flag += 1
      else:
          flag = 0

if len(obs)!=0:
    ans = 0

if D<C :
    flag = 0
    for i in range(len(esc)):
        if mid1<esc[i] <= mid2:
            flag = 1
    if flag == 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 = input()

if C < D:
    print('Yes')
    exit()

if S[B-2:D].find('...') >= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    split = input().split(' ')
    n = int(split[0]) - 1
    a = int(split[1]) - 1
    b = int(split[2]) - 1
    c = int(split[3]) - 1
    d = int(split[4]) - 1
    s = input()
    isOK = False
    if c < d:
        isOK = not ('##' in s[a:c] or '##' in s[b:d])
    else:
        if d - b == 1:
            isOK = ('##' not in s[a:c]) and (not s[b:d+2] == '#..#')
        else:
            isOK = (not ('##' in s[a:c] or '##' in s[b:d])) and ('...' in s[b:d+2])
    print('Yes' if isOK else 'No')

Submission status: Wrong Answer

Solution code:
#coding:utf-8
N,A,B,C,D = map(int,input().split())
S = input()
def isContinuous(S):
    for i in range(len(S)-1):
        if S[i:i+2] == "##":
            return True
    return False
def paint(S):
    P = [0] * len(S)
    for i in range(len(S)):
        if S[i] == "#":
            P[i] = 1
            if i != 0:
                P[i-1] = 1
            if i != (len(S)-1):
                P[i+1] = 1
    return P
if C < D:
    if not isContinuous(S[B:D]):
        print ("Yes")
    else:
        print ("No")
else:
    P = paint(S)
    #print (P)
    #print (P[B:D])
    for i in P[B:D]:
        if i == 0:
            print ("Yes")
            exit()
    print ("No")

Submission status: Wrong Answer

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from copy import copy
import numpy as np
from numpy.fft import fft, ifft
from fractions import gcd


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

n, a, b, c, d = MAP()
s = list(input())

ct3 = 0
ct_iwa=0

tmp3 = []
tmp_iwa=[]
for i in range(n):
    #print(s[i])
    if s[i] =='.':
        tmp3.append(1)
        if len(tmp_iwa) > 1:
            ct_iwa += 1
            
        tmp_iwa.clear()
    else:
        tmp_iwa.append(1)
        if len(tmp3) == 3:
            ct3 += 1
               
        tmp3.clear()


if len(tmp3) == 3:
    ct3 += 1
if len(tmp_iwa) > 1:
    ct_iwa += 1

#print(ct3, ct_iwa)

if c < d:
    if ct_iwa == 0:
        print('Yes')
    else:
        print('No')
else:
    if ct3 > 0 and ct_iwa == 0:
        print('Yes')
    else:
        print('No')