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
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-1):d] and not ('##' in s2[a:c]):
    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()

ans = "Yes"
tmpSpace = 0
tmpRock = 0
space = 0
for i in range(min(C, D) + 1):
    if s[i] == ".":
        if i >= max(A, B) - 1:
            tmpSpace += 1
        tmpRock = 0
    else:
        tmpRock += 1
        if tmpRock >= 2:
            ans = "No"
            break
        space = max(space, tmpSpace)
        tmpSpace = 0

space = max(space, tmpSpace)
if (A - B) * (C - D) < 0:
    if space <= 2:
        ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
I=lambda:map(int,input().split())
N,A,B,C,D=I()
S=input()
cross=True if C-A-D+B==0 or 0<=(B-A)/(C-A-D+B)<=1 else False
if not(cross):
    ac = [i for i in range(min(A,C)-1,max(A,C)) if S[i]=='#']
    bd = [i for i in range(min(B,D)-1,max(B,D)) if S[i]=='#']
    f=True
    for i in range(len(ac)-1):
        if ac[i]+1==ac[i+1]:f=False
    for i in range(len(bd)-1):
        if bd[i]+1==bd[i+1]:f=False
    print('Yes' if f else 'No')
else:
    al = [i for i in range(N) if S[i]=='#']
    ins = False
    for i in range(len(al)-1):
        if al[i+1]-al[i]>=4 and (min(B,D)<=al[i]+2<=max(B,D) or min(B,D)<=al[i+1]-2<=max(B,D) or min(A,C)<=al[i]+2<=max(A,C) or min(A,C)<=al[i+1]-2<=max(A,C)):
            al = al[:i+1]+[al[i]+2]+al[i+1:]
            ins = True
            break
    if not(ins):
        print('No')
    else:
        ac = [i for i in al if min(A,C)<=i<=max(A,C)]
        bd = [i for i in al if min(B,D)<=i<=max(B,D)]
        f=True
        for i in range(len(ac)-1):
            if ac[i]+1==ac[i+1]:
                f=False
                break
        for i in range(len(bd)-1):
            if bd[i]+1==bd[i+1]:
                f=False
                break
        print('Yes' if f else 'No')

Submission status: Wrong Answer

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


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


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


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

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

    if C > D:
        # できるだけ早く追い越す
        sunuke = A            # 1-index, 0-index
        funuke = B

        # 追い越すためには、"..."という領域が必要。
        oikoshi = S[B-1:].find("...")
        if oikoshi == -1:
            no()
            return
        A = oikoshi + 2
        B = oikoshi + 1

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


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

N,A,B,C,D = (int(i) for i in input().split())
S = input()
S = list(S)

result = "Yes"
onon = True

if C < D:
    for i in range(len(S)-1):
        if S[i] == "#" and S[i + 1] == "#":
            result =  "No"
else:
    result = "No"
    for i in range(len(S)-1):
        if S[i] == "#" and S[i + 1] == "#":
            onon = False
    if onon:
        for i in range(B -2,D-1):
            if S[i] == "." and S[i + 1] == "."and S[i + 2] == ".":
                result = "Yes"


print(result)

Submission status: Wrong Answer

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

stoneflag = 0
clearflag = 0
for i in range(n - 1):
    if i >= min(a,b) and i <= max(c,d):
        if s[i] == '#' and s[i + 1] == '#':
            stoneflag = 1
        elif i > b and i < d and i <= n - 3:
            if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
                clearflag = 1

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if c<d:
	if not '##' in s[a:c]:
		if not '##' in s[b:d]:
			print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
def inverse(a):
    return pow(a, mod - 2, mod)

def main():
    n,a,b,c,d = map(int, input().split())
    a -=1
    b -=1
    c -=1
    d -=1

    s = input()

    a_r = a
    cnt = 0
    for i in range(a, n):
        if s[i] == '#':
            cnt += 1
        else:
            cnt = 0
        a_r = i
        if cnt == 2:
            a_r = i
            break

    b_r = a
    cnt = 0
    for i in range(b, n):
        if s[i] == '#':
            cnt += 1
        else:
            cnt = 0
        b_r = i
        if cnt == 2:
            b_r = i - 2
            break
    if a_r < c or b_r < d:
        print('No')
        return
    if c < d:
        print('Yes')
        return
    cnt = 0
    for i in range(b, c+1):
        if s[i] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt > 2:
            print('Yes')
            return

    if s[b-1] == '.' and s[b+1] == '.':
        print('Yes')
        return
    if d < n-1 and s[d-1] == '.' and s[d+1] == '.':
        print('Yes')
        return

    print('No')


main()

Submission status: Wrong Answer

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

import sys
if B > C:
    isi = 0
    cnt = 0
    for j in range(A-1,C):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    for j in range(B-1,D):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    if isi <= 1:
        print('Yes')
    else:
        print('No')
    sys.exit()


aki = 0
isi = 0
cnt = 0
for j in range(min(A,B)-1,max(C,D)):
    i = S[j]
    if i == '.':
        cnt = 0
    elif i == '#':
        cnt += 1
        isi = max(isi,cnt)
        
cnt = 0
for j in range(max(0,max(A,B)-2),min(C,D)):
    i = S[j]
    if i == '#':
        cnt = 0
    elif i == '.':
        cnt += 1
        aki = max(aki,cnt)
        

if C > D:
    if aki >= 3 and isi <= 1:
        print('Yes')
    else:
        print('No')
else:
    if isi <= 1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

DS = False
TD = False
nd = 0
ns = 0
if A + 1 == B:
    nd = 1
for x in range(A+1, max(C, D)+1):
    s = S[x-1]
    if s == '.':
        nd = nd + 1
        ns = 0
    else:
        nd = 0
        ns = ns + 1
    if A <= x <= C or B <= x <= D:
        if ns >= 2:
            DS = True
    if B <= x <= D + 1:
        if nd >= 3:
            TD = True

if DS == True or (D < C and TD == False):
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = [int(x) for x in input().split()]
S = input()
S_ = list(S)
cross = False
minS = A
maxS = B
minG = C
maxG = D

if C < D:
    if A > B:
        maxS = A
        minS = B
        cross = True
else:
    minG = D
    maxG = C
    if A < B:
        cross = True

wall = S.find("##")
even = S.find("...")

if cross == False:
    if wall == -1:
        print("Yes")
    elif wall < minS or maxG < wall:
        print("Yes")
    else:
        print("No")
else:
    if even == -1:
        print("No")
    if minS <= wall and wall <= maxG:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

# -*- coding: utf-8 -*-


from sys import stdin
import itertools



############################################

# read data for n sequences.
temp = stdin.readline().split()
N = int(temp[0])
A = int(temp[1])
B = int(temp[2])
C = int(temp[3])
D = int(temp[4])

a = stdin.readline().split()
rock = []
for i in a[0]:
    rock.append(i)
    
# which one is further?
ok = 0
if D>C:
    if D-1 == len(rock):
        rock2 = rock[C-2:D-1]
    else:
        rock2 = rock[C-2:D]
else:
    if C-1 == len(rock):
        rock2 = rock[D-2:C-1]
    else:
        rock2 = rock[D-2:C]
#if D > C:
#    # place sunuke
#    rock2 = rock
#    rock2[A-1] = "#" 
#    for i,elem in enumerate(rock2[B-1:D-1]):
#        # check if two rocks exist
#        if elem=="#" and rock2[i+1]=="#":
#            ok = 1    
#            break
#        # place sunuke
#        rock[D-1] = "#"
#    for i,elem in enumerate(rock[A-1:C-1]):
#        if elem=="#" and rock[i+1]=="#":
#            ok = 1    
#            break
#else:
#    # place sunuke
#    rock2 = rock
#    rock2[B-1] = "#" 
#    for i,elem in enumerate(rock2[A-1:C-1]):
#        # check if two rocks exist
#        if elem=="#" and rock2[i+1]=="#":
#            ok = 1    
#            break
#        rock[C-1] = "#"
#    for i,elem in enumerate(rock[B-1:D-1]):
#        if elem=="#" and rock[i+1]=="#":
#            ok = 1    
#            break
if ok == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = [int(x) for x in input().split(" ")]
S = str(input())

Sn = list()
for i in S:
    if(i == "."):
        Sn.append(0)
    else:
        Sn.append(1)


if(a>b):
    front = a-1
    back = b-1
    tof = c-1
    tob = d-1
else:
    front = b-1
    back = a-1
    tof = d-1
    tob = c-1

isCan = True
isHide = False
for i in range(front,tof):
    if(Sn[i] == 1 and Sn[i+1] == 1):
        isCan = False
        break
        
    if(i != 0 and Sn[i] == 0 and Sn[i-1] == 0 and Sn[i+1] == 0):
        isHide = True


if(isCan == True and isHide == False):
    Sn[tof] = 1

for j in range(back,tob):
    if(Sn[j] == 1 and Sn[i+1] == 1):
        isCan = False
        break
        
if(isCan == True):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

def yn(a):
    print('Yes' if a else 'No')

if C < D:
    # `##` is NG btw A and D
    yn('##' not in S[A:C] and '##' not in S[B:D])
else:
    # `#` is NG prev D except oikoseru
    oikoseru = S[B] == '.' or '...' in S[B:D]
    yn('##' not in S[A:C] and ('#' != S[D-2] or oikoseru))

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
rocks = []
flag = True
for i, s in enumerate(S):
    if s == '#':
        rocks.append(i+1)
if 1 in [rocks[i+1] - rocks[i] for i in range(len(rocks) - 1)]:
    flag = False
if flag:
    if C > D:
        r_in_fpath = [r for r in rocks if r in range(B, D)]
        dif_r_in_fpath = [r_in_fpath[i+1] - r_in_fpath[i] for i in range(len(r_in_fpath) - 1)]
        if (B + 1 in rocks or B - 1 in rocks) and len(set(dif_r_in_fpath) - {2, 3}) == 0:
            flag = False
if flag:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if C<D:
    if "##" in S[A-1:C] or "##" in S[B-1:D]:
        print("No")
    else:
        print("Yes")
else:
    s = S.split("##")
    l=-2
    for ss in s:
        l += 2+len(ss)
        if l >= A:break
    if ("..." in ss) and (l >= C):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = [int(i) for i in input().split()]
s = input()
t = s.split("#")
if(s.count('##') > 0):
    frag = 0
if(c<d):
    frag = 1
else:
    frag = 0
    for i in range(len(t)):
        if(t[i].count(".") >= 3):
            frag = 1
        if(frag == 1):
            break
if(frag == 1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
a = input()
k = A
found = True
ffond = False
b = 0
c = 0
if C <D :
    while  found == True and k < D:
        if a[k] == "#":
            b += 1
        else:
            b = 0
        if b == 2:
            found = False
        k += 1
    if found == False:
        print("No")
    else:
        print("Yes")
else:
    while  found == True and k < C:
        if a[k] == "#":
            b += 1
            if k > B and k <= D:
                c = 0
        else:
            b = 0
            if k > B and k <=D:
                c +=1
        if b == 2:
            found = False
        if c == 3:
            ffond = True
        k += 1
    if found == False or ffond == False:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
s=list(s)
s.append('#')
s.append('#')
ct=0
if c<d:
    for i in range(a-1,c):
        if s[i]=='#' and s[i+1]=='#':
            print('No')
            ct+=1
            break
    for i in range(b-1,d):
        if s[i]=='#' and s[i+1]=='#':
            print('No')
            ct+=1
            break
elif c>d:
    for i in range(a-1,c):
        if s[i]=='#' and s[i+1]=='#':
            print('No')
            ct+=1
            break
    for i in range(b-1,d):
        if s[i]=='#' and s[i+1]=='#':
            print('No')
            ct+=1
            break
    for i in range(b-1,d):
        if s[i]=='.' and s[i+1]=='.' and s[i+2]=='.':
            print('Yes')
            ct+=1
            break
    if(1):ct=0
        
if ct==0:
    print('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(flags == 1):
			flagstop += 1
		else:
			flagstop2 = 1
	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 flagskip == 0):
	flagerror = 1
if(flagerror == 0):
	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
a -= 1
b -= 1
c -= 1
d -= 1
if c < d:
  for i in s:
    if count < a or count > d:
      pass
    elif i == "#":
      if judgesharp == True:
        print("No")
        sys.exit()
      else:
        judgesharp = True
    else:
      judgesharp = False
    count += 1
  print("Yes")
else:
  for i in s:
    if count < a or count > d:
      pass
    elif i == "#":
      threepoint = 0
      if judgesharp == True:
        print("No")
        sys.exit()
      else:
        judgesharp = True
    else:
      if b-1 <= count and count <= c+1:
        threepoint += 1
      judgesharp = False
    if threepoint == 3:
      judgepass = True
    count += 1
  if judgepass:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
S = input()
# ふぬけ が すぬけ より前にいる
if C < D:
    S_cut = S[A-1:D]
    num = S_cut.count("##")
    # print(A,B,C,D)
    print(S_cut)
    if num > 0:
        print("No")
    else:
        print("Yes")
# すぬけ が ふぬけ より前にいる
else:
    S_cut1 = S[A-1:C]
    # 飛び越えられる
    flg1 = (S_cut1.count("##") == 0)
    # S_cut2 = S[B-1:D+1]
    # print(S_cut1,S_cut2)
    # 抜く場所
    # flg2 = (S_cut2.count("...")>=1)
    flg2 = (S_cut1.count("...")>=1)
    if flg1 and flg2:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

if C < D:
    if len(re.findall('##', S[A:C])) != 0:
        print('No')
    elif len(re.findall('##', S[B:D])) != 0:
        print('No')
    else:
        print('Yes')
else:
    if len(re.findall('##', S[A:C])) != 0:
        print('No')
    elif len(re.findall('xxx', S[B - 2:D])) == 0:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

Solution code:
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
s[a] = "A"
s[b] = "B"
ans = True
flag = 0

while a<n and b<n:
  while a<b:
    if a==c:
      break
    elif a+1<n and a+1<b and s[a+1]==".":
      s[a] = "."
      s[a+1] = "A"
      a += 1
    elif a+2<n and a+2<b and s[a+2]==".":
      s[a] = "."
      s[a+2] = "A"
      a += 2
    else:
      break

  if a+2<n and d<c and s[a+1]=="B" and s[a+2]==".":
    s[a] = "."
    s[a+2] = "A"
    a += 2

  if b<a:
    while a<n:
      if a==c:
        break
      elif a+1<n and s[a+1]==".":
        s[a] = "."
        s[a+1] = "A"
        a += 1
      elif a+2<n and s[a+2]==".":
        s[a] = "."
        s[a+2] = "A"
        a += 2
      else:
        ans = False
        break

  if a==c and b==d:
    break
  elif b+1<n and s[b+1]==".":
    s[b] = "."
    s[b+1] = "B"
    b += 1
  elif b+2<n and s[b+2]==".":
    s[b] = "."
    s[b+2] = "B"
    b += 2
  else:
    ans = False
    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()
if c<d:
    if "##" in s[a:d]:
        print("No")
    else:
        print("Yes")
else:
    if "##" in s[a:c]:
        print("No")
    elif "..." in s[b-1:d]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n,a,b,c,d = f()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = input()

    has_2_consecu = 0
    for i in range(a+1, max(c,d)-1):
        if s[i]=='#' and s[i+1] == '#':
            has_2_consecu = 1
            break



    if has_2_consecu:
        print('No')
        return

    if d>c:
        print('Yes')
        return
    else:
        has_3_consecu = 0
        for i in range(b, d):
            if s[i]=='.' and s[i+1] == '.' and s[i+2]=='.':
                has_3_consecu = 1
                break
        
        if has_3_consecu:
            print('Yes')
            return
        
        if a+1 == b and s[b+1] == '.':
            print('Yes')
            return
    
    print('No')




solve()

Submission status: Wrong Answer

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

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

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


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

Submission status: Wrong Answer

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

c_swap = True 
# 飛び越し条件整理
if C > D:
    # 飛び越せるか
    if "..." in S[B-2:min(C, D-1)]:
        reset = S.find("...") + 1
        A = reset + 1
        B = reset + 2
    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:
N, A, B, C, D = map( int, input().split())
S = input()
check = "Yes"
for i in range(A-1, C):
    if S[i] == "#" and S[i+1] == "#":
        check = "No"
        break
if check == "Yes":
    for i in range(B-1, 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:
import sys
# input = sys.stdin.readline

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

# 1. place fnuke
cnt_o = 0
for pos in range(B - 1, D):
    Si = S[pos]
    if Si == '.':
        cnt_o += 1
        if cnt_o > 2:
            pos_fnk = pos - 1
            break
    else:
        cnt_o = 0
else:
    pos_fnk = pos

S[pos_fnk] = '#'
# print("# after funuke", ''.join(S))

# 2. place snuke
cnt_x = 0
for pos in range(A - 1, C):
    Si = S[pos]
    if Si == '#':
        cnt_x += 1
        if cnt_x > 1:
            ans = 'No'
            break
    else:
        cnt_x = 0
else:
    ans = 'Yes'

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import copy

def solve(n, a, b, c, d, s):
    if c < d:
        for i in range(a-1, d-1):
            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 i < d - 2 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:
# 1.A_C間,B_D間に##となっているマスがないこと
# 2.D>CまたはDの周辺に#がないまたはB_D間に...があること
n, a, b, c, d = map(int, input().split())
s = " " + input()
Triple_floor = False
before_stat = ""
floor_num = 0
counter = a
for char in s[a:]:
    if(counter > c and counter > d):
        # この先はどうでもいい.
        break
    if(char == "."):
        floor_num += 1
        if(floor_num >= 3 and counter > (b+1) and counter <= (d+1)):
            Triple_floor = True
    else:
        floor_num = 0
        if(before_stat == "#"):
            c=d
            Triple_floor = False
            break
    before_stat = char
    counter += 1
if(c<d or Triple_floor):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

    if c < d:
        count = 0
        for i in range(a - 1, d - 1):
            if s[i] == '#':
                count += 1
                if count == 2:
                    print('No')
                    exit(0)
            else:
                count = 0
        print('Yes')
    else:
        flag = 0
        countr = 0
        countv = 0
        for i in range(a - 1, c - 1):
            if s[i] == '#':
                countr += 1
                countv = 0
                if countr == 2:
                    print('No')
            else:
                if b - 2 <= i <= d:
                    countv += 1
                countr = 0
                if countv == 3:
                    flag = 1
        print('Yes') if flag else print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
#n=int(input())
n,a,b,c,d=map(int,input().split())
#a=[int(i) for i in input().split()]
s='_'+input()
ai=0
ans=['Yes','No']

#print(s,n,a,b,c,d)

def CanGo(x,y):
    cnt=0
    root=s[x:y]
    for c in root:
        if c=='#':
            cnt+=1
        elif c=='.':
            if cnt>2:
                return False
            cnt=0
    return True


def CanPass(x,y):  #(b,d)
    root=s[x:y+1]
    q=s[x:x+4]
    #print(root,len(root)-4)
    for i in range(len(root)-4):
        if q=='..#.' or  q=='.#..':
            return True
        q=q[1:4]+s[x+4+i]
        
    root=s[x-1:x+2]
    if root=='...':
        return True
    
    if x-2>=0:
        root=s[x-2:x+2]
        if root=='.#..':
            return True
        
    return False
        


if c<d:
    if CanGo(b,d) and CanGo(a,c):
        ai=0
    else:
        ai=1
elif c>d:
    if CanGo(b,d) and CanGo(a,c) and CanPass(b,d):
        ai=0
    else:
        ai=1
    
    

print(ans[ai])

Submission status: Wrong Answer

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

if ('##' in s[b:d]) and ('##' in s[a:c]):
    print('No')
elif c > d:
    if '...' in s[b - 1:d]:
        print('Yes')
    else:
        print('No') 
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
import numpy as np

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

reachable_C = np.full(N+2, False, np.bool)
reachable_D = np.full(N+2, False, np.bool)

reachable_C[C] = True
reachable_D[D] = True

for i in range(N)[::-1]:
	if S[i] == '#':
		continue
	
	if reachable_C[i+1] or reachable_C[i+2]:
		reachable_C[i] = True
	if reachable_D[i+1] or reachable_D[i+2]:
		reachable_D[i] = True

print('Yes'
	if reachable_C[A]
		and reachable_D[B]
		and (
			(A < B and C < D or B < A and D < C)
			or "..." in S)
	else '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-1:D].find('...')!=-1:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
number_of_masu, firstsunuke, firstfunuke, lastsunuke, lastfunuke = map(int, input().split())
s = str(input())
tobenaiflag = 0
nukaseruflag = 0

for i in range(firstsunuke, lastsunuke-1):
    if s[i] == '#' and s[i+1] == '#':
        tobenaiflag += 1
        break
for k in range(firstfunuke, lastfunuke-1):
    if s[k] == '#' and s[k+1] == '#':
        tobenaiflag += 1
        break
if lastfunuke < lastsunuke:
    for j in range(max(firstsunuke, firstfunuke)-1, min(lastsunuke, lastfunuke)-1-1):
        if s[j] == '.' and s[j+1] == '.' and s[j+2] == '.':
            nukaseruflag += 1
            break
else:
    nukaseruflag += 1
if tobenaiflag == 0 and nukaseruflag == 1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, A, B, C, D = read_ints()
S = input()

A -= 1
B -= 1
C -= 1
D -= 1
# 大小関係の実装
planA = True  # ひっくり返らない処理がA
if D < C:
    planA = False

from sys import exit

# 入れ替わるかの条件ごとに実装する
if planA:
    s = min(A, B, C, D)
    g = max(A, B, C, D)
    for s_left, s_right in zip(S[s:g-1], S[s + 1:g]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()
    print('Yes')
else:
    # planAでない。つまり入れ替わる場合
    s = min(A, B, C, D)
    g = max(A, B, C, D)
    for s_left, s_right in zip(S[s:g-1], S[s + 1:g]):
        if s_left == '#' and s_right == '#':
            print('No')
            exit()
    for s_left, s_center, s_right in zip(S[B:D - 1], S[B + 1:D], S[B + 2:D + 1]):
        if s_left == '.' and s_center == '.' and s_right == '.':
            print('Yes')
            exit()
    print('No')