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, raw_input().split())
S = raw_input()
i = 1
flagskip = 0
flagskip2 = 0
flagerror = 0
flags = 0
flagstop = 0
flagstop2 = 0
for c in S:
	if(flagstop2 == 1):
		if(c =='#'):
			flagstop += 1
		flagstop2 = 0
	if(i <= A):
		i += 1
		continue
	elif(i == B or (i == D and D < C)):
		if c == '#':
			flagerror = 1
			break
		if(flags == 1):
			flagstop += 1
		else:
			flagstop2 = 1
	elif(i == A or i == C or i == D):
		if c == '#':
			flagerror = 1
			break
	if(c == '#'):
		if(flags == 1):
			flagerror = 1
			break
		flags = 1
		flagskip2 = 0
	else:
		if(flagskip2 == 1):
			flagskip = 1
		elif(flags == 0 and flagskip == 0 and i > B+1 and i < D-1):
			flagskip2 = 1
		flags = 0
	i += 1
if(flagstop == 2 and D < C and flagskip == 0):
	flagerror = 1
if(flagerror == 0):
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:

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

if "##" in s[a:c+1] or "##" in s[b:d+1]:
    print("No")
elif c < d:
    print("Yes")
else:
    if s[b-1] == "." and s[b+1] == ".":
        print("Yes")
    elif "..." in s[b:c+1]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
from collections import defaultdict
import math
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline
 
n,a,b,c,d = map(int,input().split())
a-=1;b-=1;c-=1;d-=1
s = input()
if (a < b and c<d) or (a>b and c > d):
        if  "##" in s[a:c]:
                print("No")
                exit()
        if  "##" in s[c:a]:
                print("No")
                exit()
        if   "##" in s[b:d]:
                print("No")
                exit()
        if   "##" in s[d:b]:
                print("No")
                exit()
        print("Yes")
else:
        if  "##" in s[a:c]:
                print("No")
                exit()
        if  "##" in s[c:a]:
                print("No")
                exit()
        if   "##" in s[b:d]:
                print("No")
                exit()
        if   "##" in s[d:b]:
                print("No")
                exit()
        sita = a
        ue = a
        while sita>0:
                if sita >=2 and s[sita-2] == ".":
                        sita -=2
                elif sita >= 1 and s[sita-1] == ".":
                        sita-=1
                else:
                        break
        while ue < n:
                if ue <n-2 and s[ue+2] == ".":
                        ue +=2
                elif ue <n-1 and s[ue+1] == ".":
                        ue+=1
                else:
                        break               
        if  "..." in s[sita:ue+1]:
                print("Yes")
                exit()
        print("No")

Submission status: Wrong Answer

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

seq=0
tri=0
if c<d:
    seq=s[a:d].count("##")
    if seq==0:
        print("Yes")
    else:
        print("No")
else:
    seq=s[a:c].count("##")
    tri=s[b-1:d+2].count("...")
    if seq==0:
        if tri!=0:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Submission status: Wrong Answer

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

if not(S[A:C-1].find('##')!=-1 or S[B:D-1].find('##')!=-1):
  if C<D:
    print('Yes')
  elif S[B:C-1].find('...')!=-1:
    print('Yes')
  else:
    print('No')
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(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, D-1):
        if S[i]=='#' and S[i+1]=="#":
            print("No")
            exit(0)
        if i<=D-3 or (i==D-2 and D+1<=N):
            if S[i]=='.' and S[i+1]=='.' and S[i+2]=='.':
                flag=True
    for i in range(A, B-1):
        if S[i]=='#' and S[i+1]=="#":
            print("No")
            exit(0)
    print("Yes" if flag else "No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
L=input()
f=0
r="."
for i in list(L):
  if r=="#" and i=="#":
    f=1
    break
  r=i

if c < d:
  print('No' if f==1 else 'Yes')
else:
  g=0
  t="#"
  s="#"
  for i in range(b-1,d):
    if L[i-1:i+2]=="...":
      g=1
      break
    s=i
  print('No' if f==1 or g==0 else '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 d < c:
        if ('...' in S[b:d-1]) or (S[b-2] == '.' 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())
a, b, c, d = a-1, b-1, c-1, d-1
s = input()
if "##" in s:
    print("No")
elif c < d:
    print("Yes")
elif "..." in s:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

c_swap = True 
# 飛び越し条件整理
if C > D:
    # 飛び越せるか
    if "..." in S[:min(C, D-1)]:
        reset = S.find("...")
        A = reset + 2
        B = reset + 3
    else:
        c_swap = False
    
# funukeとDの間に##がないかチェック
is_f_ok = "##" not in S[B-1:D]

# sunukeとCの間に##がないかチェック
is_s_ok = "##" not in S[A-1:C]

print("Yes") if (is_f_ok & is_s_ok & c_swap) else print("No")

Submission status: Wrong Answer

Solution code:
# coding:utf-8


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

    for i in range(N-1):
        if S[i] == iwa and S[i+1] == iwa:
            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())
S = input()


ans = "Yes"
f = 0
if C>D:
    f = 1


if f == 0:
    now = S[A-1]
    count = 0
    for i in range(A-1,C):
        if S[i]=='#':
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break
  
    count = 0
    for i in range(B-1,D):
        if S[i]=='#':
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break
       


if f == 1:
    now = S[A-1]
    count = 0
    count_space = 0
    space_flag = False
    for i in range(A-1,C):
        if S[i]=='#':
            count += 1
            count_space = 0
        else:
            count_space += 1
            count = 0
        if count == 2:
            ans = "No"
            break
        if count_space == 3:
            space_flag = True
    
    if not space_flag:
        ans = "No"
    
    count = 0
    for i in range(B-1,D):
        if S[i]=='#':
            count += 1
        else:
            count = 0
        if count == 2:
            ans = "No"
            break

print(ans)

Submission status: Wrong Answer

Solution code:
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N, A, B, C, D = [ int(x) for x in input().split() ]
A -= 1
B -= 1
C -= 1
D -= 1
S = input() + "#"

A_blocker = False
B_blocker = False
pass_point = False

A_load = S[A:C]
B_load = S[B:D]
pass_load = S[B-1:D+1]
if '##' in A_load:
    A_blocker = True
if '##' in B_load:
    B_blocker = True
if '...' in pass_load:
    pass_point = True

if D < C:
    if (not A_blocker) and (not B_blocker) and pass_point:
        print ("Yes")
    else:
        print ("No")
else:
    if (not A_blocker) and (not B_blocker):
        print ("Yes")
    else:
        print ("No")

Submission status: Wrong Answer

Solution code:
from copy import deepcopy

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


def start_funuke():
    s = deepcopy(S)
    funuke = s[B - 1 : D]
    # print(funuke)
    for i in range(1, len(funuke)):
        if funuke[i] == "#" and funuke[i - 1] == "#":
            return False
    s[D - 1] = "#"
    sunuke = s[A - 1 : C]
    # print(sunuke)
    for i in range(1, len(sunuke)):
        if sunuke[i] == "#" and sunuke[i - 1] == "#":
            return False
    return True


def start_sunuke():
    s = deepcopy(S)
    sunuke = s[A - 1 : C]
    # print(sunuke)
    for i in range(1, len(sunuke)):
        if sunuke[i] == "#" and sunuke[i - 1] == "#":
            return False
    s[C - 1] = "#"
    funuke = s[B - 1 : D]
    # print(funuke)
    f = True
    for i in range(2, len(funuke)):
        if funuke[i] == "." and funuke[i - 1] == "." and funuke[i - 2] == ".":
            f = False
    if f:
        return False
    for i in range(1, len(funuke)):
        if funuke[i] == "#" and funuke[i - 1] == "#":
            return False
    return True


ans = "Yes" if start_funuke() or start_sunuke() else "No"
print(ans)

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:
        isOK = (not ('##' in s[a:c] or '##' in s[b:d])) and ('...' in s[b:d])
    print('Yes' if isOK else 'No')

Submission status: Wrong Answer

Solution code:
#
#　　　　　　　　　　　　　　,. -─────────‐- .、
#　　　　　　　　　　　　 ／／￣￣＼　　　　　　／￣￣＼＼
#　　　　　　　　　　　／　　　　　　　　　　　　　　　　　　　　 ＼
#　　　　　　　　　 ／　　　　　　　　::::::::::::::::::::::::::::::::　　　　　　　＼
#　　　　　　　　／ 　　／ ／￣＼＼::::;;;;;;;;;;;;;;;;;:::::／／￣＼＼　　＼
#　　　　　　 ／　　　　|　 |.　┃　.|　| ::::;;;;;;;;;;;;;::::｜ |.　┃　.|　|　　　 ＼　　　　　　　　　　　　　　　　　　　　　
#　　　　　／ 　　　　　＼ ＼＿／／　::::::::::::::::::　＼＼＿／／　　　　　 ＼　　　　
#　　　 ／　　　　　..／￣￣＼　／　　　::｜::　　　＼　／￣￣＼..　　　　　＼
#　　 / 　 　 　 　 :::::　　　　　　|　　　　　 |　　　　　 |　　　　　　 :::::　　　　　 ヽ.　　　
#　　| 　　　　　　　　　　　　　　|　　　　　 |　　　　　 |　　　　　　　　　　　　　　|.
#　　| 　　　　　　　　　　　　　　＼＿＿／＼＿＿／ 　　　　　　　　　　　　　　|　　　　　　　　　　　　　　　　　
#　　| 　　　　　　　　　　　　　　　｜　　　　　　　｜　　　　　　　　　　　　　　　|
#　　| 　　　　　　　　　　　　　　　｜r─‐┬──､|　　　　　　　　　　　　　　　 |
#　　ヽ　　　　　　　　　　　　　　　 |/　　　|　　 　｜　　　　　　　　　　　　　　/
#　　　 ＼　　　　　　　　　　　　　 ＼　　　　　　／　　　　　　　　　　　　　／
#　　　　　＼ 　　　　　　　　　　　　　￣￣￣￣　　　　　　　　　　　　　／
#
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [input() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N, A, B, C, D = MI()
    S = "."+ST()

    if A > C or B > D:
        print("No")
        exit()

    for i in range(min(A, B), max(C, D) ):
        if S[i] == "#" and S[i - 1] == "#":
            print("No")
            exit()
    
    if (A - B) * (C - D) > 0:
        print("Yes")
    else:
        #3連続あるか判定
        for i in range(max(A, B)+1, min(C, D)+1):
            if S[i] == "." and S[i - 1] == "." and S[i - 2] == ".":
                print("Yes")
                exit()
        print("No")

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = list(map(int, input().split()))
S = input()
X = [".", "#"]
Ans = ["Yes", "No"]

A -= 1
B -= 1
C -= 1
D -= 1

f = 0
if A < B:
  if (B < C and D < C) or (A > D and C > D):
    f = 1
else:
  if (B > C and D > C) or (A < D and C < D):
    f = 1

if A < C:
  a, b = A, C
else:
  a, b = C, A
s = 0
for i in range(a, b + 1):
  if S[i] == X[1]:
    if s == 1:
      print(Ans[1])
      exit()
    s = 1
  else:
    s = 0

if B < D:
  a, b = B, D
else:
  a, b = D, B
for i in range(a, b + 1):
  if S[i] == X[1]:
    if s == 1:
      print(Ans[1])
      exit()
    s = 1
  else:
    s = 0

if f == 0:
  print(Ans[0])
  exit()

mi = min(A, B, C, D)
ma = max(A, B, C, D)

s = 0
ok = 0
k = 0
for i in range(N):
  if i == mi:
    k = 1
  if S[i] == X[1]:
    if s == 1:
      s = 0
      ok = 0
      if k == 1:
        break
    else:
      s = 1
  else:
    if s == 1:
      s = -1
    else:
      s -= 1
      if s == -3:
        ok = 1
  if k == 1 and ok == 1:
    print(Ans[0])
    exit()

print(Ans[1])

Submission status: Wrong Answer

Solution code:
import numpy as np
NABCD = list(map(int,input().split()))
N = NABCD[0]
A = NABCD[1]
B = NABCD[2]
C = NABCD[3]
D = NABCD[4]
S = input()

output = "No"

cous = 0
maxs = 0
cour = 0
maxr = 0
maxi = np.array([])

for i in range(N):
    p = S[i]
    if p == "#":
        cour += 1
        cous = 0
    elif p == ".":
        cous += 1
        cour = 0
    if cour > maxr:
        maxr = cour
    if cous > maxs:
        maxs = cous
    if cous > 2:
        maxi = np.append(maxi,i+1)

keysum = sum(maxi-1>=B)
if C > D:
    if (maxr < 2)and(maxs >2)and(keysum>0):
        output = "Yes"
elif D > C:
    if maxr < 2:
        output = "Yes"
print(output)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10000)
mod = 1000000007


def mul(a, b):
    return ((a % mod) * (b % mod)) % mod


def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % mod
    elif y % 2 == 0:
        return power(x, y / 2) ** 2 % mod
    else:
        return power(x, y / 2) ** 2 * x % mod


def div(a, b):
    return mul(a, power(b, mod - 2))


# def gcd(a_gcd, b_gcd):
#     while b_gcd != 0:
#         a_gcd, b_gcd = b_gcd, a_gcd % b_gcd
#     return a_gcd
#
#
# def lcm(a_lcm, b_lcm):
#     return a_lcm * b // gcd(a_lcm, b_lcm)
#
#
# def max_sum(N_max_sum, a_max_sum):
#     dp = [0] * (N_max_sum + 1)
#     for i in range(N_max_sum):
#         dp[i + 1] = max(dp[i], dp[i] + a_max_sum[i])
#     return dp[N]
#
#
# def knapsack(N_knapsack, W, weight, value):
#     inf = float("inf")
#     dp = [[-inf for _ in range(W+1)] for j in range(N_knapsack + 1)]
#     for i in range(W+1):
#         dp[0][i] = 0
#
#     for i in range(N_knapsack):
#         for w in range(W+1):
#             if weight[i] <= w:
#                 dp[i+1][w] = max(dp[i][w-weight[i]]+value[i], dp[i][w])
#             else:
#                 dp[i+1][w] = dp[i][w]
#     return dp[N_knapsack][W]
#
#
# class UnionFind:
#     def __init__(self, n):
#         self.par = [i for i in range(n+1)]
#         self.rank = [0] * (n+1)
#
#     # 検索
#     def find(self, x):
#         if self.par[x] == x:
#             return x
#         else:
#             self.par[x] = self.find(self.par[x])
#             return self.par[x]
#
#     # 併合
#     def union(self, x, y):
#         x = self.find(x)
#         y = self.find(y)
#         if self.rank[x] < self.rank[y]:
#             self.par[x] = y
#         else:
#             self.par[y] = x
#             if self.rank[x] == self.rank[y]:
#                 self.rank[x] += 1
#
#     # 同じ集合に属するか判定
#     def same_check(self, x, y):
#         return self.find(x) == self.find(y)


# S = input()
# N = int(input())
# A = list(map(int, input().split()))
# X = [int(input()) for _ in range(N)]

N, A, B, C, D = map(int, input().split())
S = input()
block = "#"
ans = "Yes"
if C < D:
    for i in range(A, C):
        if S[i] == block:
            if S[i + 1] == block:
                ans = "No"
                break
    for i in range(B, D):
        if S[i] == block:
            if S[i + 1] == block:
                ans = "No"
                break
else:
    change_frag = False

    for i in range(A, C):
        if S[i] == block:
            if S[i + 1] == block:
                ans = "No"
                break
    for i in range(B, D):
        if S[i] == block:
            if S[i + 1] == block:
                ans = "No"
                break
        elif i < D-1:
            if S[i+1] != block and S[i+2] != block:
                change_frag = True

    if not change_frag:
        ans = "No"


print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import numpy as np
from functools import lru_cache
import time

def main(): 
    if True:
        N,A,B,C,D = list(map(int, input().split()))
        S = np.asarray(list(str(input())))
    else:
        pass

    scount = 0
    dcount = 0
    swapok = False
    #print(S[A:D])
    for i in range(A,max(C,D)):
        s = S[i]
        if s == "#":
            dcount = 0
            scount += 1
            if scount == 2:
                print("No")
                exit()
        else:
            scount = 0
            if D > i > B-3:
                dcount += 1
                if dcount == 3:
                    swapok = True
    
    if (C>D) & (not swapok):
        print("No")
    else:
        print("Yes")

if __name__ =='__main__':
    main()

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 A > B:
        A,B = B,A
        C,D = D,C

    if A > C or B > D:
        print(NO)
        return

    for i in range(A-1,C-1):
        if S[i] == "#" and S[i+1] == "#":
            print(NO)
            return

    for i in range(B-1,D-1):
        if S[i] == "#" and S[i+1] == "#":
            print(NO)
            return

    if C > D:
        bOK = False
        for i in range(A-1,C-2):
            if S[i] == "." and S[i+1] == "." and S[i+2] == "." and i+2 != B-1 and i+1 < D-1 : 
                bOK = True
                break

        if not bOK:
            print(NO)
            return

    print(YES)







# 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:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,A,B,C,D=MAP()
S='#'+input()+'#'

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

import sys
import re

_,a,b,c,d = [ int(x)-1 for x in sys.stdin.readline().split() ]
m = sys.stdin.readline().strip()
if m[c]!="." or m[d]!=".":
    print( "No" )
    exit()
#
loc= []
for match in re.finditer( "##",m ): loc.append( match.start() )
if c>d:
    if m[b+1:d+1].find("..")<0:
        print( "No" )
        exit()
#
# check b->d
flag= False
ii= b+1
jj= d-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
if flag:
    print( "No" )
    exit()
#
# check a->c
ii= a+1
jj= c-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
#
if flag:
    print( "No" )
    exit()
#
print( "Yes" )

Submission status: Wrong Answer

Solution code:
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
n, a, b, c, d  = map(int, input().split())
a = a-1
b = b-1
c = c-1
d = d-1
s2 = input()
s = list(s2)

if '...' in s2[b:d] and not ('##' in s2[a:d]):
    print('Yes')
    exit()


if all(s[i] == '.' or s[i+1] == '.' for i in range(b,d)):
    s[d] = '#'
    if all(s[i] == '.' or s[i+1] == '.' for i in range(a,c)):
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D=map(int,input().split())
S=input()
if C==D:
  print("No")
elif C<D:
  if B<=C:
    c,d=0,0
    for i in range(A-1,D):
      if S[i]=="#":
        if c==1:
          d=1
          break
        else:
          c=1
      else:
        c=0
    print("Yes" if d==0 else "No")
  else:
    c,d=0,0
    for i in range(A-1,C):
      if S[i]=="#":
        if c==1:
          d=1
          break
        else:
          c=1
      else:
        c=0
    c=0
    for i in range(B-1,D):
      if S[i]=="#":
        if c==1:
          d=1
          break
        else:
          c=1
      else:
        c=0
    print("Yes" if d==0 else "No") 
else:
  c,d=0,0
  for i in range(A-1,C):
    if S[i]=="#":
        if c==1:
          d=1
          break
        else:
          c=1
    else:
      c=0
  if "..." not in S[B-1:D]:
    d=1
  print("Yes" if d==0 else "No")

Submission status: Wrong Answer

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

A = A-1
B = B-1
C = C-1
D = D-1

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

for i in range(A,C):
    if S[i] == "#" and S[i+1] == "#":
        print("No")
        exit()

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

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

Submission status: Wrong Answer

Solution code:
from sys import stdin

n, a, b, c, d = [int(x) for x in stdin.readline().rstrip().split()]
s = stdin.readline().rstrip()

# A..C 二つの岩 あったらだめ
# B..D二つの岩 あったらだめ
# D < Cのとき、 AがBを追い越せななかったらだめ

ans = "Yes"

rock = 0
for i in range(a, c):
    if '#' == s[i-1]:
        rock += 1
        if rock >= 2:
            ans = "No"
            break
    else:
        rock = 0

rock = 0
for i in range(b, d):
    if '#' == s[i-1]:
        rock += 1
        if rock >= 2:
            ans = "No"
            break
    else:
        rock = 0


space = 0
if d < c:
    ok = 0
    for i in range(b, d):
        if '.' == s[i-1]:
            space += 1
            if space >= 3:
                ok = 1
    if '.' == s[d-1-1] and '.' == s[d+1-1]:
        ok = 1
    if 0 == ok:
        ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, raw_input().split())
S = raw_input()
i = 1
flagskip = 0
flagskip2 = 0
flagerror = 0
flags = 0
flagstop = 0
flagstop2 = 0
for c in S:
	if(flagstop2 == 1):
		if(c =='#'):
			flagstop += 1
		flagstop2 = 0
	if(i <= A):
		i += 1
		continue
	elif(i == B or (i == D and D < C)):
		if c == '#':
			flagerror = 1
			break
		if(flags == 1):
			flagstop += 1
		else:
			flagstop2 = 1
	elif(i == A or i == C or i == D):
		if c == '#':
			flagerror = 1
			break
	if(c == '#'):
		if(flags == 1):
			flagerror = 1
			break
		flags = 1
		flagskip2 = 0
	else:
		if(flagskip2 == 1):
			flagskip = 1
		elif(flags == 0 and flagskip == 0 and i > B and i < D):
			flagskip2 = 1
		flags = 0
	i += 1
if(flagstop == 2 and D < C and flagskip == 0):
	flagerror = 1
if(flagerror == 0):
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
Sp = input()[A-1:max([C, D])+1]

if Sp.find('##') != -1:
    print('No')
    exit()

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

if Sp[B-1] == '.' and Sp[B+1] == '.':
    print('Yes')
    exit()

if Sp[B+1:C].find('...') >= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

gyaku = 0
if C > D:
    gyaku = 1

flag = 0
renzoku = 0
irekae = 0
for i in range(N):
    if S[i] == '#':
        renzoku = 0
        if flag == 1:
            if A < i < C-1 or B < i < D-1:
                print('No')
                exit()
        flag = 1

    else:
        flag = 0
        renzoku += 1
        if renzoku == 3:
            irekae = 1
            irekaeiti = i

    if gyaku:
        if i == D-1:
            if S[i-1] == '#':
                if irekae == 0 :
                    print('No')
                    exit()
            if S[i-1] != '.' or S[i+1] != '.':
                print('No')
                exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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

tmp = ''
for i, x in  enumerate(S):
    if i == A or i == B:
        tmp += 'X'
    else:
        tmp += x

if '##' in S:
    print('No')
elif C<D:
    print('Yes')
else:
    if '...' in S[A:]:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, input().split())
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 "..." in s[B:D]:
            print("Yes")
        else:
            print("No")

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
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 c+1 > count:
        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 = input()

if c > b:
  if c < d:
    if "##" in s[a:d]:
      print('No')
    else:
      print('Yes')
  else:
    if (('##' in s[a:c]) or not('...' in s[b:d-2])):
      print('No')
    else:
      print('Yes')
else:
  if (('##' in s[a:c]) or ('##' in s[b:d])):
    print('No')
  else:
    print('Yes')

Submission status: Wrong Answer

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

S = input()

S = S + '...'

def continuous_rock_search(S):
    for i in range(len(S) - 1):
        if S[i] == '#' and S[i+1] == '#':
            return True
    return False
  
def validation_funuke_move(S, B, D):
    '''
    ふぬけ君が両隣に岩がなくなるまで移動したとき、Dより向こうにはイカないことを確認する。
    True/False and ふぬけの移動後の位置
    '''
    funuke_position = B
    while (B <= D):
        if (S[B-2] == '#' or S[B] == '#'):
            if S[B] == '.' :
                B = B + 1
            else:
                B = B + 2
        elif (S[B-2] == '.' and S[B] == '.'):
            return True, B
    
    return False, -1
  
def KenKenRace(S, A, B, C, D):
    if continuous_rock_search(S):
        return False
    
    if C < D:
        return True
    
    if D < C:
        valid , _ = validation_funuke_move(S, B, D)
        if valid:
            return True
        else:
            return False
          
if KenKenRace(S, A, B, C, D):
    print('Yes')
else:
    print('No')