Problem:


Score : 400 points

Problem Statement

There are N squares arranged in a row, numbered 1, 2, ..., N from left to right.
You are given a string S of length N consisting of . and #. If the i-th character of S is #, Square i contains a rock; if the i-th character of S is ., Square i is empty.

In the beginning, Snuke stands on Square A, and Fnuke stands on Square B.

You can repeat the following operation any number of times:

Choose Snuke or Fnuke, and make him jump one or two squares to the right. The destination must be one of the squares, and it must not contain a rock or the other person.

You want to repeat this operation so that Snuke will stand on Square C and Fnuke will stand on Square D.

Determine whether this is possible.

Constraints

4 \leq N \leq 200\ 000

S is a string of length N consisting of . and #.

1 \leq A, B, C, D \leq N

Square A, B, C and D do not contain a rock.

A, B, C and D are all different.

A < B

A < C

B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

Print Yes if the objective is achievable, and No if it is not.

Sample Input 1

7 1 3 6 7
.#..#..

Sample Output 1

Yes

The objective is achievable by, for example, moving the two persons as follows. (A and B represent Snuke and Fnuke, respectively.)

A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB

Sample Input 2

7 1 3 7 6
.#..#..

Sample Output 2

No

Sample Input 3

15 1 3 15 13
...#.#...#.#...

Sample Output 3

Yes



Sample input:
7 1 3 6 7
.#..#..


Sample output:
Yes

Submission status: Wrong Answer

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

    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
class KenkenRace:
    def __init__(self):
        N, A, B, C, D = map(int, input().split())
        S = [str(c) for c in input()]

        self.N = N
        self.A = A
        self.B = B
        self.C = C
        self.D = D
        self.S = S

    def main(self):
        result = False

        # C < D のとき
        if self.C < self.D:
            # クリアできるか確かめる
            result = self.__canClear__(self.D)

        # D < C のとき
        else:
            # 追い越せるかどうかを確かめる and クリアできるか確かめる
            result = self.__canClear__(self.C) and self.__canOvertake__(self.D)

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

    def __canClear__(self, higher):
        isDouble = False
        preObject = ""
        for i in range(self.A - 1, higher - 1):
            c = self.S[i]
            if c == "#" and preObject == "#":
                isDouble = True
                break
            else:
                preObject = c

        return not isDouble

    def __canOvertake__(self, lower):
        isTriple = False
        objectCount = 0
        severalCount = 0

        for i in range(self.A - 1, lower - 1):
            c = self.S[i]
            objectCount += 1

            # 何もない箇所が何連続目か, カウント
            if c == ".":
                severalCount += 1
            else:
                severalCount = 0

            if objectCount == lower:
                # この位置 or 次の位置で3連続でない場合, 追い越せない
                if severalCount < 2:
                    break

            # 3連続で何もなければ追い越し可能か
            if severalCount == 3:
                isTriple = True
                break

        return isTriple


kenkenRace = KenkenRace()
kenkenRace.main()

Submission status: Wrong Answer

Solution code:
N,a,b,c,d = map(int,input().split())
S = input()
a -= 1
b -= 1
c -= 1
d -= 1

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

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

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

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

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

Submission status: Wrong Answer

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

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

if s[c-1] == "#" or s[d-1] == "#":
    ans = "No"

print(ans)

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'
        if D-B == 1:
            ans == 'No'
    else:
        ans = 'No'
if s[A:C-2].count('##')!=0 or s[B:D-2].count('##')!=0:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def SI(): return input()

N,A,B,C,D=LI()
st=input()

if C < D:
    if st[A:C].find('##') >= 0 or st[B:D].find('##') >= 0:
        print('No')
    else:
        print('Yes')
else:
    # Cの方がおおきいケース 入れ替わる
    if st[A:C].find('##') >= 0:
        print('No')
    else:
        lft = 0
        for i in reversed(range(1, A)):
            if st[i] == '#' and st[i-1] == '#':
                lft = i+1
        rgt = st.find('##', C)

        aru = st[lft:rgt].find('...')
        print("lft{} rgt{} aru{}".format(lft, rgt, aru))
        if aru == -1:
            print('No')
        else:
            print('Yes')

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):
        # 入れ替わるスペースがあるか
        u = s[max(a,b):min(c,d)]
        su = "".join(u)
        if not '...' in su:
            print("No")
            return

    print("Yes")

test()

Submission status: Wrong Answer

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

if '##' in S :
    print("No")
    quit()

if C > D:
    if '...' not in S[B:C-2]:
        print("No")
        quit()
    if C-D == 2 and S[C-2] == '#' and S[D-2] == '#':
        print("No")
        quit()


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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

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

    # A,Bからみて先が"##"の状態になったら詰み
    if "##" not in S[A:] and "##" not in S[B:]:
        if C < D:
            # 先にBをDまで移動させればAもたどり着ける
            print("Yes")
        else:
            # AがBを追い抜く必要があるので、
            # その瞬間に#B or B#にならないようにしないといけない
            # BからD+1の間に ... があればOK
            if "..." in S[B:D+2]:
                print("Yes")
            else:
                print("No")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

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

'''
#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 == 1 and C < D:
        result = 'Yes'
    if kusa_cnt == 3:
        result = 'Yes'
print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def solve():
	cnt = 0
	for i in range(N):
		if S[i:i+1]=='#':
			cnt += 1
			if cnt>=2:
				print('No')
				return
		else:
			cnt = 0

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

	cnt = 0
	for i in range(B-1, N):
		if S[i:i+1]=='.':
			cnt += 1
			if cnt>=3 and i>=B and i<=D:
				print('Yes')
				return
		else:
			cnt = 0
	print('No')

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

Submission status: Wrong Answer

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

if '#' not in s:
    print('Yes')
elif '##' in s and  a < s.index('##') < c:
    print('No')
elif '##' in s and  b < s.index('##') < d:
    print('No')
if c > d:
    if '...' in	s and a < s.index('...') < c:
        print('Yes')
    else:
    	print('No')
# elif '#.#' in s and a < s.index('#.#') and s.index('#.#') < c and a < b and c > d:
#     print('No')
# elif '#.#' in s and b < s.index('#.#') and s.index('#.#') < d:
#     print('No')
# elif '#..#' in s and a < b and c > d:
#     print('No')
# elif '#..#' in s and a > b and c < d:
#     print('No')
elif '...' in s:
    print('Yes')
elif c < d:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

S = input()

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

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

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
c, d , cc, dd = 0, 0, 0, 0
if "##" in S[A-1:C] or "##" in S[B-1:D]:
  print("No")

elif C < D:
  print("Yes")

else:
  for i in S[C:]:
    if c == 2:
      cc = cc - 2
      break
    elif i == "#":
      c += 1
      cc += 1
    else:
      c = 0
      cc += 1
  for i in S[:A][::-1]:
    if d == 2:
      dd = dd - 2
      break
    elif i == "#":
      d += 1
      dd += 1
    else:
      d = 0
      dd += 1
  if "..." in S[A-d-1:C+cc]:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

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

A -= 1
B -= 1

ans = False
if C < B:
    # A ~ C に行けるか
    # B ~ D に行けるか
    count_x = 0
    ans = True
    for i in range(A, C):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_x = 0
        for i in range(B, D):
            if S[i] == "#":
                count_x += 1
            else:
                count_x = 0
            if count_x > 1:
                ans = False
                break
elif C < D:
    # B ~ D に行けるか
    # A ~ C に行けるか
    count_x = 0
    ans = True
    for i in range(A, D):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
else:
    # A ~ Cに行けるか
    # AがBを超えれるか
    # (B~Dに3つ以上の連続空きがある)
    count_x = 0
    ans = True
    for i in range(A, C):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_o = 0
        ans = False
        for i in range(B, D+1):
            if S[i] == "#":
                count_o = 0
            else:
                count_o += 1
            if count_o > 2:
                ans = True
                break
if ans:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b,c,d=map(int,input().split(' '))
    s=input()
    result = 'Yes'
    if a<b<d<c:
        tmp =0
        cnt=0
        for i in range(b-2,d+1):
            if s[i]=='#'and s[i+1]=='#':
                result='No'
                break
            if s[i]=='#':
                if tmp > cnt:
                    cnt = tmp
                    tmp=0
            else:
                tmp +=1
        if cnt < 3:
                result = 'No'
        if result =='Yes':
            for i in range(a,c-1):
                if s[i]=='#'and s[i+1]=='#':
                    result='No'
    else:
        for i in range(b,d):
            if s[i] =='#' and s[i+1]=='#':
                result ='No'
                break
        if result=='Yes':
            for i in range(a,c-1):
                if s[i] =='#' and s[i+1]=='#':
                    result = 'No'
    print(result)

main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()


def main():
    global a, b
    n, a, b, c, d = read_int_array()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = read() + b'###'
    if s[d] == '#' or s[c] == '#' or c == d:
        print('NO')
    else:
        def move_a():
            global a, b
            if s[a + 1] == '.' and b != a + 1:
                a += 1
            elif s[a + 2] == '.' and b != a + 2:
                a += 2
            elif a + 1 == b:
                if move_b():
                    a += 1
                else:
                    return False
            elif a + 2 == b:
                if move_b():
                    a += 2
                else:
                    return False
            else:
                return False
            return True

        def move_b():
            global a, b
            if s[b + 1] == '.':
                b += 1
                return True
            if s[b + 2] == '.':
                b += 2
                return True
            return False

        if c < d:
            while b < d:
                if not move_b():
                    print('NO')
                    return
            if b != d:
                print("NO")
                return
            while a < c:
                if not move_a():
                    print('NO')
                    return
            print("YES")
        else:
            while a < c:
                if not move_a():
                    print("NO")
                    return
            if b > d:
                print("NO")
                return
            while b < d:
                if not move_b():
                    print("NO")
                    return
            print("YES")


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")


def read():
    return input()


def read_array(sep=None, maxsplit=-1):
    return read().split(sep, maxsplit)


def read_int():
    return int(read())


def read_int_array(sep=None, maxsplit=-1):
    return [int(a) for a in read_array(sep, maxsplit)]

# endregion

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(input())
last = ""
for i in range(a, 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]
    s[b - 1] = "."
    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:
I=lambda:map(int,input().split())
N,A,B,C,D=I()
S=input()
cross=True if D<C else False
if not(cross):
    ac = [i for i in range(A-1,C) if S[i]=='#']
    bd = [i for i in range(B-1,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:
    bl = [i for i in range(A-1,C) if S[i]=='.']
    ac = [i for i in range(A-1,C) if S[i]=='#']
    bd = [i for i in range(B-1,D) if S[i]=='#']
    f=True
    akichi=False
    for i in range(B-1,D):
        if S[i-1]==S[i]==S[i+1]=='.':akichi=True
    #if ac==[] or bd==[]:akichi=True
    for i in range(len(ac)-1):
        if ac[i+1]-ac[i]<=1:f=False
        if ac[i+1]-ac[i]>=4:akichi=True
    for i in range(len(bd)-1):
        if bd[i+1]-bd[i]<=1:f=False
    print('Yes' if f and akichi else 'No')

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

# 連続空白を調べる
isStone = False
spaceChainCount = 0
threeSpaceCenterIndex = -1
for i in range(a, len(s)):
    if s[i] == '#':
        # 2連続の場合
        if isStone:
            print("No")
            sys.exit()
        isStone = True
        spaceChainCount = 0
    else:
        isStone = False
        spaceChainCount += 1
        if spaceChainCount >= 3:
            threeSpaceCenterIndex = i - 1

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

# 通ってきたならOK
print("Yes")

Submission status: Wrong Answer

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

def max_stone(seq):
  m = 0
  for j in range(len(seq)-1):
    if S[j:j+1] == '##':
      return False
  
  return True
  
def reachable(n):
  for j in range(n, len(S)):
    s = S[j]
    n_sharp = 0
    n_dot = 0
    if s=='.':
      n_dot += 1
      n_sharp = 0
    else:
      n_sharp += 1
      n_dot = 0
    if n_sharp == 2:
      return False
    elif n_dot == 3:
      return True
  for j in range(n):
    s = S[j]
    n_sharp = 0
    n_dot = 0
    if s=='.':
      n_dot += 1
      n_sharp = 0
    else:
      n_sharp += 1
      n_dot = 0
    if n_sharp == 2:
      return False
    elif n_dot == 3:
      return True
  return False
  
if C < B:
  if max_stone(S[A-1:C-1]) and max_stone(S[B-1:D-1]):
    print('Yes')
  else:
    print('No')
elif B < C and C < D:
  if max_stone(S[A-1:C-1]) and max_stone(S[B-1:D-1]):
    print('Yes')
  else:
    print('No')
elif B < C and C > D:
  if reachable(A-1) and max_stone(S[A-1:C-1]) and max_stone(S[B-1:D-1]):
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

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

stoneflag = 0
clearflag = 0
if b < c:
    for i in range(n - 1):
        if i >= min(a - 1,b - 1) and i <= max(c - 1,d - 1):
            if s[i] == '#' and s[i + 1] == '#':
                stoneflag = 1
            elif i > b - 1 and i < d - 1 and i <= n - 3:
                if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
                    clearflag = 1
else:
    for i in range(n - 1):
        if i > a and i < c:
            if s[i] == '#' and s[i + 1] == '#':
                stoneflag = 1
        if i > b and i < d:
            if s[i] == '#' and s[i + 1] == '#':
                stoneflag = 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 = 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-1:D+1]).find('...') > 0:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

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

if s[c-1] == "#" or s[d-1] == "#":
    ans = "No"

print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, input().split())
S = input()
S.split()
answer = 1
a = 1
distance = []
distance_2 = []
for n in range(A-1,max(C-1,D-1)):
  a += 1
  if S[n] == "#":
    distance.append(a)
    a = 0
if 1 in distance:
  answer = 0
if D < C and answer == 1:
  a = 1
  for n in range(B-2,D-1):
    a += 1
    if S[n] == "#":
      distance_2.append(a)
      a = 0
  if max(distance_2) < 4:
    answer = 0
if answer == 1:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

sunuke = ""
hunuke = ""


if C > D:
    k = ''.join(s[B:D-1])
    result = "..." in k
    if result == 0:
        print("No")
        exit()

while B <= D:
    if s[B] == ".":
        B += 1
        if B == D:
            hunuke = "ok"
            break
    elif s[B+1] == ".":
        B += 2
        if B == D:
            hunuke = "ok"
            break
    else:
        print("No")
        exit()

while A <= C:
    if s[A] == ".":
        A += 1
        if A == C:
            sunuke = "ok"
            break
    elif s[A+1] == ".":
        A += 2
        if A == C:
            sunuke = "ok"
            break
        elif A > C:
            print("No")
            exit()
    else:
        print("No")
        exit()

if sunuke == "ok" and hunuke == "ok":
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def check(start,end,road):
    s = road[start-1:end-1]
    if '##' in s:
        return False
    else:
        return True

def check2(start,end,road):
    s = road[start-1:end-1]
    if '...' in s:
        return True
    else:
        return False

if __name__ == '__main__':
    n,a,b, c,d = map(int, input().split())
    s = input()
    if c < d:
        if check(a,d,s):
            print('Yes')
        else:
            print('No')
    else:
        if check2(b,d,s):
            if check(a,d,s):
                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()
s_flag = False
can_flag = True
count = 0

for i in range(n):
  if s[i] == '#':
    count = 0
    if s_flag:
      s_flag = True
      can_flag = False
      break
    else:
      s_flag = False
  else:
    count += 1
if count > 0 and count <= 2:
  if c >= d:
    can_flag = False
  can_flag 
if can_flag:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

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

l_s = []
for i in range(len(s)):
    l_s += [0 if s[i] == '.' else 1]

ans = 'Yes'
if i in range(len(s)-1):
    if sum(l_s[i:i+2])==2:
        ans = 'No'

if ans == 'Yes':
    if d>c:
        pass
    else:
        ans = 'No'
        for j in range(c-b-2):
            if sum(l_s[j:3+j]) == 0:
                ans = 'Yes'
            else:
                pass

print(ans)

Submission status: Wrong Answer

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

if C<D:
  if B<C:
    d=0
    if "##" in S[A-1:D]:
      d=1
    print("Yes" if d==0 else "No")
  else:
    d=0
    if "##" in S[A-1:C]:
      d=1
    if "##" in S[B-1:D]:
      d=1
    print("Yes" if d==0 else "No") 
else:
  d=0
  if "##" in S[A-1:C]:
    d=1
  if "..." not in S[B-2:max(N,D+1)]:
    d=1
  print("Yes" if d==0 else "No")

Submission status: Wrong Answer

Solution code:
def solve2():
    N, A, B, C, D = [int(_) for _ in raw_input().split()]
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = raw_input()
    R3 = False
    E3 = False
    EREE = False
    for i in range (A+1, max(C,D)-1):
        if S[i:(i+3)] == '###':
            R3 = True
            break
    if C == D or R3:
        return False
    elif C < D:
        return True
    elif C > D:
        for i in range (B, D-2):
            if S[i:(i+3)] == '...':
                E3 = True
                break
            elif i < D - 3 and S[i:(i+4)] == '.#..':
                EREE = True
                break
        ret = E3 or EREE
        return ret

if __name__ == '__main__':
    ret = solve2()
    if ret:
        print 'Yes'
    else:
        print 'No'