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 = (int(i) for i in input().split())  
s = input()
if c<d:
  if s[a:c].count("##")>0 and s[b:d].count("##")>0:
    print("No")
  else:
    print("Yes")
else:
  if s[a:c].count("##")==0 and s[b:d].count("##")==0 and s[b:d].count("...")>0:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(input())
for i in range(b, d - 1):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        exit(0)
for i in range(a, c - 1):
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        exit(0)
if (a < b and c < d) or (b < a and d < c):
    print('Yes')
else:
    if a < b:
        l, r = a - 1, a
    else:
        l, r = b - 1, b
    while l >= 0 and (s[l] != '#' or s[l + 1] != '#'):
        l -= 1
    l += 2 - int(l == -1)
    while r < n and (s[r - 1] != '#' or s[r] != '#'):
        r += 1
    r -= 2 - int(r == n)
    for i in range(l, r - 1):
        if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
            print('Yes')
            break
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
for i in range(a, d - 2):
    if s[i] == "#" and s[i + 1] == "#":
        print("No")
        exit()
if c > d:
    f = s[b - 3:].find("...")
    if f == -1:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = [int(x) for x in input().split()]
# index変換
A -= 1; B -= 1
S = input()
if (C<D):
    if ("##" in S[A:D]):
        print("No")
    else:
        print("Yes")
else:
    if ("##" not in S[A:C]) and ("..." in S[B-1:D]):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
temp = input()
temp2 = input()

N, A, B, C, D = [int(x) for x in temp.split()]
flag = True
before = -1
 
for x, xi in enumerate(temp2):
    x = x + 1
    if x<A:# 初めはいらない
        continue
    elif x>D:# 後半もいらない
        break
        
    if xi==".":
        continue
    else:
        # 以下ブロック箇所
        if x in [A, B, C, D]:
            flag = False
            break
        else:
            if x-before==1:
                flag = False
                break
            else:
                before = x
    
            
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(input())
last = ""
for i in range(a, max(c, d)):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
if c > d:
    s[b - 1] = "#"
    flag = True
    for i in range(a, c):
        if last == "#" and s[i] == "#":
            flag = False
        last = s[i]
    count = 0
    for i in range(a, c):
        if s[i] == ".":
            count += 1
            if count == 3:
                flag = True
        else:
            count = 0
else:
    flag = True
    for i in range(b, d):
        if last == "#" and s[i] == "#":
            flag = False
        last = s[i]
if flag:
    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()
s=[0]*N
stop=[0]*N
space=[0]*N
for i in range(N):
    if S[i]=='#':
        s[i]=1
        if i>0 and s[i-1]==1:
            stop[i]=1
    elif i>1 and s[i-1]==0 and s[i-2]==0:
        space[i]=1
    if i>0:
        stop[i]+=stop[i-1]
        space[i]+=space[i-1]
if stop[C]-stop[A]>0 or stop[D]-stop[B]>0:
    ans=0
elif C<D:
    ans=1
elif space[D+1]-space[B]>0:
    ans=1
else:
    ans=0
print(s,stop,space)
print(['No','Yes'][ans])

Submission status: Wrong Answer

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

flag = True

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

if c > d:
    # ゴールの左が#
    if s[d-2] != "." and s[b] != ".":
        s_bd = s[b-1:d]
        has_ddd = False
        for i in range(len(s_bd)-2):
            if s_bd[i:i+3] == "...":
                has_ddd = True
        if has_ddd == False:
            flag = False

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

Submission status: Wrong Answer

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

a_s = B
f = False
if D < C:
  S[a_s] ='#'
  f = True
  a = A
  A = B
  B = a
  c = C
  C = D
  D = c
  
  
b_l = S[B:D]

t = False
for b in b_l:
  if b !='#':
    t = False
    continue
  if b == '#' and t:
    print('No')
    quit()
  if b == '#' and not t:
    t = True
if f:
  S[a_s -1] ='.'
S[D-1] = '#'
a_l = S[A:C]
for a in a_l:
  if a !='#':
    t = False
    continue
  if a == '#' and t:
    print('No')
    quit()
  if a == '#' and not t:
    t = True

print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
 
n, a, b, c, d = map(int, input().split(' '))
s = input()
 
# 2連続石が無いか調べる
# & 連続空白を調べる
isStone = False
spaceChainCount = 0
threeSpaceCenterIndex = -1
for i in range(len(s)):
    if s[i] == '#':
        if isStone:
            print("No")
            sys.exit()
        isStone = True
        spaceChainCount = 0
    else:
        isStone = False
        spaceChainCount += 1
        if spaceChainCount >= 3:
            threeSpaceCenterIndex = i - 1

# A,Bが入れ替わる場合
if ((a < b and c > d) or (a > b and c < d)):
    # 3連続空白が無い場合 or 3空白がA,B両方より左の場合
    if threeSpaceCenterIndex < 0 or (threeSpaceCenterIndex > 0 and threeSpaceCenterIndex < max(a, b)):
        print("No")
        sys.exit()

# 通ってきたならOK
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(B,D-2):
	if S[i]=="#" and S[i+1]=="#":
		print("No")
		sys.exit()


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

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

Submission status: Wrong Answer

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

for k in range(max(C,D)-2):
    if S[k] == S[k+1] == "#":
        print("No")
        exit(0)

if C < D:
    print("Yes")
    exit(0)
for k in range(N-2):
    if S[k] == S[k+1] == S[k+2] == ".":
        if k+2 <= D and k+3 <= C:
            print("Yes")
            exit(0)
print("No")
exit(0)

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):
        # print(S[i])
        if S[i] == block:
            if S[i + 1] == block:
                ans = "No"
                break
    for i in range(B-1, D):
        # print(i, S[i])
        if S[i] == block:
            if S[i + 1] == block:
                ans = "No"
                break
        elif i < D-1:
            if S[i-1] != block and S[i+1] != block:
                # print(i)
                change_frag = True

    if not change_frag:
        ans = "No"


print(ans)

Submission status: Wrong Answer

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

    s.insert(0, '.')
    s[a] = 'A'
    s[b] = 'B'

    # C D までに岩が2個あるか
    t = s[min(a,b):max(c,d)]
    st = "".join(t)
    if '##' in st:
        print("No")
        return

    # A B が入れ替わるかどうか
    if (c > d):
        # 入れ替わるスペースがあるか
        if not '...' in st:
            print("No")
            return

    print("Yes")

test()

Submission status: Wrong Answer

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

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



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


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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
mx = max(C,D)
r_count = [len(s) for s in S[A-1:mx].split('.') if len(s) > 1]
if r_count != []:
    print('No')
    exit()
if C < D:
    print('Yes')
    exit()

count = [len(s) for s in S[B-1:D].split('#') if len(s) > 2]
print('Yes' if len(count) > 0 or (S[D] == '.' and S[D-2] == '.') else 'No')

Submission status: Wrong Answer

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

if C < B:
    if S[A-1:C].find('##') < 0 and S[B-1:D].find('##') < 0: print 'Yes'
    else: print 'No'
elif C < D:
    if S[B-1:D].find('##') >= 0: print 'No'
    elif S[A-1:C].find('##') >= 0: print 'No'
    else:
        print 'Yes'
else:
    if S[B-1:D].find('##') >= 0: print 'No'
    else:
        if S[A-1:C].find('##') >= 0: print 'No'
        list_s = list(S)
        list_s[D-1] = '#'
        S = ''.join(list_s)
        if S[A-1:C].find('##') >= 0:
            if S[B-1:D].find('...') >= 0: print 'Yes'
            else: print 'No'
        else: print 'Yes'

Submission status: Wrong Answer

Solution code:
import math

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

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

flag = 1



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

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

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(str(input()))
a, b, c, d = a-1, b-1, c-1, d-1
rng = []
chg = []
left = a
for i in range(max(a, 1), min(n-1, max(c, d))):
  if s[i] == s[i+1] == "#":
    rng.append([left, i-1])
    left = i + 1
  elif i == n-2:
    rng.append([left, i+1])
  if s[i-1] == s[i] == s[i+1] == ".":
    chg.append(i)
#print(rng)
check = 0
if c < d:
  for r in rng:
    if r[0] <= a:
      if c <= r[1]:
        check = 1
      break
  if check:
    check = 0
    for r in rng:
      if r[0] <= b:
        if d <= r[1]:
          check = 1
        break

else:
  for r in rng:
    if r[0] <= a:
      if c <= r[1]:
        check = 1
      break
  if check:
    check = 0
    for i in chg:
      if b <= i <= d:
        check = 1
        break


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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""
import numpy as np
import sys
import collections
import scipy.misc
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        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 と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]
    

"""
N, X = map(int, input().split())

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

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
dp = np.zeros((N+1, 4,4,4))
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break
# 累積和
add = 1 # 問題によって決まる
res = 0
sums = [0]*(len(nums)+1)
for i in range(len(nums)):
    sums[i+1] = sums[i] + nums[i]
for i in range(0, len(nums), 2):
    left = i
    right = min(i+add, len(nums))
    tmp = sums[right] - sums[left]
    res = max(tmp, res)

#２分探索
li, ri = bisect.bisect_left(p_ac, l[i]-1), bisect.bisect_right(p_ac, r[i]-1)    

#ソート関数
org_list = [3, 1, 4, 5, 2]
new_list = sorted(org_list)
print(org_list)
print(new_list)
# [3, 1, 4, 5, 2]
# [1, 2, 3, 4, 5]

#Distance Transformation
    for h in range(0,H):
        for w in range(0,W):
            if h == 0 and w == 0:
                pass
            elif h == 0:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h-1][W-w]+1)
            elif w == 0:   
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1)
            else:
                D[H-h-1][W-w-1]= min(D[H-h-1][W-w-1], D[H-h][W-w-1]+1, D[H-h-1][W-w]+1, D[H-h][W-w]+2)
            d_max = max(D[H-h-1][W-w-1], d_max)

"""



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

A = A-1
B = B-1
C = C-1
D = D-1
def main(): 
    if C < D:
        past = True
        now = True
        for i in range(B, D):
            if S[i] == ".":
                now = True
            else:
                now = False
            
            if now == False and past ==False:
                return print("No")
            else:
                pass
            past = now
            
        past = True
        now = True
        for i in range(A, C):
            if S[i] == ".":
                now = True
            else:
                now = False
            
            if now == False and past ==False:
                return print("No")
            else:
                pass
            past = now
        return print("Yes")
    else:
        past = True
        now = True
        for i in range(A, C):
            if S[i] == ".":
                now = True
            else:
                now = False
            
            if now == False and past ==False:
                return print("No")
            else:
                pass
            past = now
                
        past2 = False
        past1 = False
        now   = True
        flg   = False
        
        if S[B-1] == "." and S[B] == "." and S[B+1] ==".":
            flg = True
        
        for i in range(A, C):
            if S[i] == ".":
                now = True
            else:
                now = False
            if now == True and past1 ==True and past2 == True:
                flg = True
            else:
                pass
            past2 = past1
            past1 = now
        if S[D-1] == ".":
            flg = True
        if flg == True:
            return print("Yes")        
        else:
            return print("No")
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
s = input()
if '##' in s:
    print('No')
else:
    if C > D:
        if '...' in s[B-1:D]:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
s = input()
if C<D:
    ans = 'Yes'
else:
    if s[B-2:D].count('...')>0:
        
        ans = 'Yes'
    else:
        ans = 'No'
if s[A:C-2].count('##')!=0 and s[B:D-2].count('##')!=0:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
import re
from collections import deque
import sys
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_invs(n, mod=DIV):
    inv = [0]*(n+1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, n+1):
        inv[i] = (-(mod//i)*inv[mod % i]) % mod
    return inv


N,A,B,C,D = ints_raw()
S = input()
#N = int_raw()


def main():
    ans = 0
    if D==C:
        return "No"
    if S[D-1]=="#" or S[C-1]=="#":
        return "No"
    if "##" in S[A:max(B, D)]:
        return "No"
    if D>C:
        return "Yes"
    else:
        if "..." in S[B-2:min(max(D+1,N),C)]:
            #print (S[B-2:min(max(D+1, N), C)])
            return "Yes"
        if (B-A ==1) and S[B]==".":
            return "Yes"
        if S[B-2:B+1]==".#.":
            return "Yes"
        return "No" 
    return ans


print(main())

Submission status: Wrong Answer

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

if len(s)>max([c, d]):
    n = len(s)
    s = s[:n]
    
if '##' in s:
    print('No')
else:
    if c-1==d and s[d-2] == '#':
        if '...' in s:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import Counter as D, defaultdict as dd
from math import factorial as ft, ceil as aron
from fractions import gcd as pg 
from bisect import insort as ins, bisect_left as bl, bisect_right as br
import sys

#sys.stdin=open("./testfile.txt","r")
raw_input=sys.stdin.readline

f1=lambda : map(int,raw_input().split())
f2=lambda : map(int,list(raw_input()))
f3=lambda : int(raw_input())
f4=lambda : raw_input().rstrip()

n,a,b,d,e=f1()
s=list(f4())
t=0

for i in xrange(b-1,e):
	if s[i]=="#":
		t+=1
	else:
		t=0
	if t==2: break

if t==2:
	print "No"
else:
	s[e-1]="#"
	t=0
	for i in xrange(a-1,d):
		if s[i]=="#":
			t+=1
		else:
			t=0
		if t==2: break
	if t==2:
		print "No"
	else:
		print "Yes"

Submission status: Wrong Answer

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

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


def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    A -= 1
    B -= 1
    C -= 1
    D -= 1

    S_original = S
    S = list(S_original)

    flag = False
    
    # case1 Cに先にたどり着くパターン
    S[C] = '#'
    S[B] = '#'

    S = ''.join(S)
    if '##' in S[A+1:C]:
        pass
    elif '##' in S[B+1:D]:
        pass
    else:
        flag = True

    # case2 Dに先にたどり着くパターン
    S = list(S_original)

    S[D] = '#'
    S[A] = '#'

    S = ''.join(S)
    if '##' in S[A+1:C]:
        pass
    elif '##' in S[B+1:D]:
        pass
    else:
        flag = True

    # case 3 途中で追い越すパターン
    S = list(S_original)

    S = ''.join(S)
    if '...' in S[B+1:C] or '..' == S[B+1:B+1+2] or '..' == S[C-2:C]:
        # case 3-1 Cに先にたどり着くパターン
        S = list(S_original)
        S[C] = '#'
        S = ''.join(S)
        
        if '##' in S[A+1:C]:
            pass
        elif '##' in S[B+1:D]:
            pass
        else:
            flag = True

        # case 3-2 Dに先にたどり着くパターン
        S = list(S_original)

        S[D] = '#'

        S = ''.join(S)
        if '##' in S[A+1:C]:
            pass
        elif '##' in S[B+1:D]:
            pass
        else:
            flag = True


    if flag == True:
        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:
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([])
maxir = 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)
    if cour >= 2:
        maxir = np.append(maxir,i+1)

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

Submission status: Wrong Answer

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

#C<Dのとき　AはBを抜かなくて良い
if C < D:
    if ''.join(S[A:C]).find('##') == -1 and ''.join(S[B:D]).find('##') == -1:
        print('Yes')
    else:
        print('No')
        
#C>Dのとき　AはBを抜かなければならない
else:
    if ''.join(S[A:C]).find('##') == -1 and ''.join(S[B:D]).find('##') == -1 and ''.join(S[B:D]).find('...') > 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

rock = 0
max_rock = []
non = 0
max_non = []
k = 0
for i in s:
    if i == '#':
        rock += 1
        if non >= 3:
            max_non.append([non, k])
        non = 0
    else:
        non += 1
        if rock >= 2:
            max_rock.append([rock, k])
        rock = 0
    if k == n-1:
        k += 1
        if non >= 3:
            max_non.append([non, k])
        if rock >= 2:
            max_rock.append([rock, k])
    k += 1

max_non1 = [i for i in max_non if i[1]-3 < d and i[1]-3 < c]
max_rock1 = [i for i in max_rock if i[1]-3 < d and i[1]-3 < c]

if len(max_rock1) > 0:
    print('No')
elif d > c:
    print('Yes')
else:
    if len(max_non) > 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(1, len(S)):
    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(max(A, B) , min(C, D) - 1):
            if S[i-2] == "." 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:
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(min(C,D)-2):
        if S[i] == "." and S[i+1] == "." and S[i+2]==".":
            return True
        else:
            pass
    return False

if C > D:
    if canover():
        print(syori1(sunuke,hunuke))
    else:
        print("No")
else:
    print(syori1(sunuke,hunuke))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import sys

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

def is_change(A, B, C, D):
    if (A < B) and (C > D):
        return True
    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=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<=i:
      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 '##' in s:
    print('No')
else:
    if C > D:
        if '...' in s[B-1:D]:
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')
print(s[B-1:D])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

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