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:
def give(list):
    i=0
    count=0
    count1=0
    while i<len(list)-2:
        if list[i]=='A':
            count1+=1
            if list[i]=='A' and list[i+1]=='B' and list[i+2]=='C':
                list[i]='B'
                list[i+1]='C'
                list[i+2]='A'
                i+=2
                count+=count1
                count1-=1
            else:
                i+=1
        else:
            count1=0
            i+=1
    return count
s=list(input())
print(give(s))

Submission status: Wrong Answer

Solution code:
## AからＣ　ＢからＤに移動させたい
## C<D なら簡単

N,A,B,C,D = map(int,input().split())
S = input()
flag = 0
obs = []
esc = []
ans = 1

#ＡとＢで小さいほうを low
if A<B:
    low = A
    mid1 = B
else:
    low = B
    mid1 = A
#ＣとＤで大きいほうをhigh
if C<D:
    high = D
    mid2 = C
else:
    high = C
    mid2 = D



for i in range(low,high):
     if S[i]=="#" and flag == 1:
         obs.append(i)
         flag = 0
     elif S[i] == "#":
         flag = 1
     else: flag = 0

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

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

if D<C :
    flag = 0
    for i in range(len(esc)):
        if mid1< esc[i] <= mid2+1:
            flag = 1
    if flag == 0:
        ans = 0


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

Submission status: Wrong Answer

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

def scan(a_, c_):
    mae = ''
    for i, l in enumerate(s, 1):
        if a_ > i:
            continue
        if c_ == i:
            return True
        if mae == l == '#':
            return False
        mae = l

def scan2(a_, c_):
    mae = ''
    maemae = ''
    for i, l in enumerate(s, 1):
        if a_ > i:
            continue
        if c_ == i:
            return False
        if mae == maemae == l == '.':
            return True
        maemae = mae
        mae = l

def scan3(a_, c_):
    for i, l in enumerate(s, 1):
        if a_ > i:
            continue
        if i == b + 1:
            return l == '.'
        if l == '#':
            return False

if d > c and scan(a, c) and scan(b, d):
    print('Yes')
elif d < c and scan(a, c) and scan(b, d) and scan2(b, d) or scan3(a, b):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

curval = "x"
cnt = 0
initidx = 0
ngarea = [-1]
triarea = [-1]

for idx,val in enumerate(S):
    if val == curval:
        cnt += 1
    else:
        if cnt >= 2 and curval == '#':
            ngarea.append(initidx + 1)
        elif cnt >= 3 and curval == '.':
            triarea.append(initidx + 1)
        initidx = idx
        cnt = 1
    curval = val
else:
    if cnt >= 2 and curval == '#':
        ngarea.append(initidx + 1)
    elif cnt >= 3 and curval == '.':
        triarea.append(initidx + 1)

if C < D:
    isBflg = True
    isABflg = True
    for ngp in ngarea:
        if ngp > B and ngp < D:
            isBflg = False
        if ngp > A and ngp < B:
            isABflg = False
    if isBflg and isABflg:
        print('Yes')
        exit()
    else:
        print('No')
        exit()
else:
    isChangeFlg = False
    # Changepoint = -1
    for trp in triarea:
        if trp > A and trp + 1 >= B:
            Changepoint = trp
            isChangeFlg = True
            break
    if isChangeFlg == False:
        print('No')
        exit()
    else:
        isBflg = True
        isABflg = True
        isChange2DFlg = True
        for ngp in ngarea:
            if ngp > B and ngp < Changepoint:
                isBflg = False
            if ngp > A and ngp < B:
                isABflg = False
            if ngp > Changepoint and ngp < D:
                isChange2DFlg = False
        if isBflg and isABflg and isChange2DFlg:
            print('Yes')
            exit()
        else:
            print('No')
            exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

# 整数の入力
#n = int(input())

# スペース区切りの整数の入力
#a = [x for x in map(int, input().split())]
n, a, b, c, d = map(int, input().split())
#print("sp", n, q, file=sys.stderr)

# 改行区切りの整数の入力
#a = []
#for x in range(m):
#  a.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]

# 文字列の入力
s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()

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

def canswap(s, b, d):
  print("canswap", s, file=sys.stderr)
  for x in range(b, d + 1):
    #print(x, file=sys.stderr)
    prev = s[x - 1] != '#'
    curr = s[x] != '#'
    post = s[x + 1] != '#'
    print(prev, post, file=sys.stderr)
    if post and prev:
      return True
  return False

def canmove(s, a, c):
  print(s, file=sys.stderr)
  if a + 1 == c:
    return True
  prev = s[a + 1] != '.'
  for x in range(a + 2, c):
    #print(x, file=sys.stderr)
    post = s[x] != '.'
    if post and prev:
      return False
    prev = post
      
  return True

def doit():  
  s2 = list(s)
  print(s2, file=sys.stderr)
  s2[a] = 'A'
  s2[b] = 'B'
  print('s2 ', s2, file=sys.stderr)

  res = list(s)
  res[c] = 'A'
  res[d] = 'B'
  print('res', res, file=sys.stderr)
  
  if c < d:
    if not canmove(s2, b, d):
      return False
    s2[b] = '.'
    s2[d] = 'B'
    return canmove(s2, a, c)
  else:
    if not canmove(s2, a, c):
      if not canswap(s2, b, d):
        return False
      else:
        s2[b] = '.'
        return canmove(s2, a, c)
    s2[a] = '.'
    s2[c] = 'A'
    return canmove(s2, b, d)

#print(doit([0] * 4))
#doit()
try:
  print('Yes' if doit() else 'No')
    
except Exception as e:
  print("e", e, file=sys.stderr)

Submission status: Wrong Answer

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

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

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 < B のとき
        if self.C < self.B:
            # 割れているので, A -> C and B -> D を検証
            result = self.__canSepClear__(self.A, self.C) and self.__canSepClear__(self.B, self.D)

        # C < D のとき
        elif 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):
            c = self.S[i]
            if c == "#" and preObject == "#":
                isDouble = True
                break
            else:
                preObject = c

        return not isDouble

    def __canSepClear__(self, start, end):
        isDouble = False
        preObject = ""

        for i in range(start - 1, end):
            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):
            c = self.S[i]
            objectCount += 1

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

            if objectCount == lower:
                # この位置 or 次の位置で3連続でない場合, 追い越せない
                if severalCount < 2:
                    break
                elif severalCount == 2 and self.S[i + 1]:
                    isTriple = True
                    break

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

        return isTriple


kenkenRace = KenkenRace()
kenkenRace.main()

Submission status: Wrong Answer

Solution code:
def g(i, y, S):
    while i != y:
        if S[i + 2] == '.':
            i += 2
        elif S[i + 1] == '.':
            i += 1
        else:
            break
    return i
def dc(n, a, b, c, d, S):
    S = list(S)
    S[b] = 'B'
    while a < b:
        a = g(a, c, S)
        if S[b + 1] == '.':
            S[b] = '.'
            b += 1
            S[b] = 'B'
        elif S[b + 2] == '.':
            S[b] = '.'
            b += 2
            S[b] = 'B'
        else:
            return a == c and b == d
    return True
def solve():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    S = input() + "##"
    if "##" in S[a + 1:max(c, d)]:
        return False
    if c < d:
        return True
    else:
        return dc(n, a, b, c, d, S)
    return True
print("Yes" if solve() else "No")

Submission status: Wrong Answer

Solution code:
# -*- coding; utf 8 -*-
# KenKen race
# 2019. 6/2

import sys


def jump_right(S, current, goal):
    for i in range(current, goal - 1):
        if (S[i+1] == '#' and S[i+2] == '#'):
            return False
    return True



if __name__ == '__main__':
    N, A, B, C, D = map(int, input().split())
    S = list(input())
    S.insert(0, "")

    is_hunuke = jump_right(S, B, D)
    if not is_hunuke:
        print("No")
        sys.exit()

    if is_hunuke:
        S[D] = '#'

    is_sunuke = jump_right(S, A, C)
    if not is_sunuke:
        print("No")
        sys.exit()

    if is_sunuke:
        print("Yes")

Submission status: Wrong Answer

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

for i in range(max(C, D)):
    if S[i:i+2] == "##":
        print("No")
        quit()

if C > D and C - D == 1:
    if S[D-2:D] == "#." and S.count("...") == 0:
        print("No")
    else:
        print("Yes")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
s = input()
S = list(s) + ['.','.']
ans = True

if C > D:
    if '...' not in s[B+1:]:
        if s[B-1] != '.' or s[B+1] != '.':  ans = False

if ans:
    while B < D:
        if S[B] == '#':
            if S[B+1] == '#':
                ans = False
                break
            else:   B += 2
        else:   B += 1

if ans:
    while A < C:
        if S[A] == '#':
            if S[A+1] == '#':
                ans = False
                break
            else:   A += 2
        else:   A += 1

if ans: print('Yes')
else:   print('No')

Submission status: Wrong Answer

Solution code:
a=input().split()
b=input()

ans = 0
re = 0
if int(a[3])>int(a[4]):
	re = 1

p = 0
rock = 0
dot = 0
rock_ver = 0
re_ok = 0
for i in range(int(a[0])):
	if i + 1 == int(a[2]):
		p = 1
	b_i = b[int(i)]
	if b_i == "#":
		if rock == 1:
			ans = 1
			break
		if p == 1:
			if rock_ver == 0:
				rock_ver = 1
		rock = 1
		dot = 0
	else:
		rock = 0
		if p == 1:
			dot += 1
			if rock_ver == 0:
				if dot >=2:
					re_ok = 1
					break
			elif dot >= 3:
				re_ok = 1
				break

if re == 1:
	if re_ok == 0:
		ans = 1

if ans == 0:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

if '##' in s:
    print('No')
elif c < d:
    print('Yes')
elif not '...' in s:
    print('No')
else:
    i = 0
    while True:
        i = s.find('...', i + 1)
        
        if b <= i < d:
            print('Yes')
            break
        elif i >= d:
            print('No')
            break
        else:
            pass

Submission status: Wrong Answer

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

flag3 = 0
flagno = 0

if c > d:

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

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

    if flagno == 0:

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

    else:
        print("No")

else:

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

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

    for i in range(b,d-1):

        if s[i:i+2] == "##":
            flagno += 1
            break
    
    if flagno == 0:
        print("Yes")

    else:
        print("No")

Submission status: Wrong Answer

Solution code:
line = input().split()
object_ = input()

N = int(line[0])
A = int(line[1])-1
B = int(line[2])-1
C = int(line[3])-1
D = int(line[4])-1

placing_objects = [True if s == '#' else False for s in list(object_)]

def main():
    if (A < B and C < D) or (A > B and C > D):
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1]:
                print('No')
                return
        print('Yes')
        return
    else:
        possible_trans = False
        trans_index = -1
        for i in range(N-1):
            if placing_objects[i] and placing_objects[i+1]:
                print('No')
                return
            if i < N-2 and (not placing_objects[i]) and (not placing_objects[i+1]) and (not placing_objects[i+2]):
                possible_trans = True
                trans_index = i+1
        if not possible_trans:
            if C < D:
                if placing_objects[C-1] or placing_objects[C+1]:
                    print('No')
                    return
            else:
                if placing_objects[D-1] or placing_objects[D+1]:
                    print('No')
                    return
        else:
            if A > B:
                if A > trans_index:
                    print('No')
                    return
            else:
                if B > trans_index:
                    print('No')
                    return
        print('Yes')
        
main()

Submission status: Wrong Answer

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

S = list(input().split()[0])

result = "Yes"
flag = False

if C < D:
    for i in range(B, D - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
                print(result)
                flag = True
                break
else:
    for i in range(B, C - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
                print(result)
                flag = True
                break
if not flag:
    print(result)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if s[b:d].count('##')>0:
    print('No')
    exit()

if c>d:
    flg=True
    if s[b:d].count('..')>0:
        flg=False
    if d<n and s[d-2]=='.' and s[d]=='.':
        flg=False
    if b!=d-1 and s[b-2]=='.' and s[b]=='.':
        flg=False
    if flg:
        print('No')
        exit()

if s[a:c].count('##')>0:
    print('No')
    exit()
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): 
    if(S[A-1] == '#' or S[B-1] == '#' or  S[C-1] == '#' or S[D-1] == '#'):
        print(NO)
        sys.exit()

    if(S[A-1:C].count('##') == 0 and S[B-1:D].count('##') == 0):
        if(D < C):
            if(S[B-1:D].count('...') == 0):
                print(NO)
            else:
                tS = list(S)
                tS[B-1] = '#'
                tS = ''.join(tS)
                if(tS[A-1:D].count('...') == 0 and B-1 == S[A-1:D].rfind('...')+2):
                    print(NO)
                else:
                    print(YES)
        else: # D > Cの場合
            print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

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

'''
#print(S)
iwa_cnt = 0
kusa_cnt = 0
result ='No'
for i,s in enumerate(S[A-1:max(C,D)-1]):
    #print(s)
    #print(i)
    #print(iwa_cnt)
    #print(kusa_cnt)
    if s =='#':
        iwa_cnt +=1
        kusa_cnt = 0
    else:
        if i + A - 1 > B -1:
            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 == 2:
        result = 'Yes'
print(result)

Submission status: Wrong Answer

Solution code:
argN, argA, argB, argC, argD = list(map(int,input().split()))
argS = input()

if argA < argB and argC < argD:
  flgOIKOSI = False
elif argB < argA and argD < argC:
  flgOIKOSI = False
else:
  flgOIKOSI = True
#print(flgOIKOSI)
  
if "##" in argS[argA - 1:argC]:
  #print(argS[argA - 1:argC])
  print("No")
elif "##" in argS[argB - 1:argD]:
  #print(argS[argB - 1:argD])
  print("No")
elif flgOIKOSI == False:
  print("Yes")
else:
  aryS = list(argS.split("#"))
  #print(aryS)
  #print(len(max(aryS)))
  if len(max(aryS)) > 2:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

Solution code:
# from sys import exit
N, A, B, C, D = [int(n)-1 for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
S = list(str(input()))
L = len(S)
# T = str(input())
# # exit()
# S[A] = "A"
# S[B] = "B"
# S[C] = "AG"
# S[D] = "BG"
# print(S)
# 連続岩チェック
for i in range(0, L-1):
    if S[i] == "#" and S[i+1] == "#":
        if A < i < C or B < i < D:
            print("No")
            exit()

# Bをこす必要があって越せるかチェック
if D < C:
    OK = False
    if S[B+1] == "." and (S[B-1] == "." or S[B-1] == "A"):
        print("Yes")
        exit()
    for i in range(0, L-2):
        if S[i] == "." and S[i+1] == "." and S[i+2] == ".":
            if B < i:
                print("Yes")
                exit()
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
# sample code

v = list(map(int, input().split()))
n, a, b, c, d = v[0], v[1], v[2], v[3], v[4]
s = input()

ac_cnt_1, ac_max_1 = 0, 0
bd_cnt_1, bd_max_1 = 0, 0
bd_cnt_0, bd_max_0 = 0, 0

for i in range(c-a):
	if s[i+a-1] == '#':
		ac_cnt_1 += 1
		if ac_max_1 < ac_cnt_1:
			ac_max_1 = ac_cnt_1
	else:
		ac_cnt_1 = 0
for i in range(d-b):
	if s[i+b-1] == '#':
		bd_cnt_0 = 0
		bd_cnt_1 += 1
		if bd_max_1 < bd_cnt_1:
			bd_max_1 = bd_cnt_1
	else:
		bd_cnt_0 += 1
		bd_cnt_1 = 0
		if bd_max_0 < bd_cnt_0:
			bd_max_0 = bd_cnt_0
if c < b:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1):
		print('Yes')
	else:
		print('No')
elif c < d:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1):
		print('Yes')
	else:
		print('No')
else:
	if (ac_max_1 <= 1) and (bd_max_1 <= 1) and (bd_max_0 >= 3):
		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()
cross = False
minG = C
maxG = D

if C > D:
    minG = D
    maxG = C
    cross = True

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

if cross == False:
    if wall == -1:
        print("Yes")
    elif wall + 1 < A or maxG < wall + 1:
        print("Yes")
    elif B < wall + 1 and wall + 1 < minG:
        print("Yes")
    else:
        print("No")
else:
    if even == -1:
        print("No")
    elif even + 2 < B:
        print("No")
    elif minG < even + 2:
        print("No")
    elif A < wall + 1 and wall + 1 < maxG:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
import re
a=list(map(int,input().split()))
s=input()
N=a[0]
A=a[1]
B=a[2]
C=a[3]
D=a[4]
if C<D:
    l=s[A-1:C]
    l1=re.findall('#+',l)
    n=0
    max=0
    while True:
        if max<len(l1[n]):
            max=len(l1[n])
        n=n+1
        if n==len(l1):
            break            
    if max>=2:
        print('No')
    else:
        l=s[B-1:D]
        l1=re.findall('#+',l)
        n=0
        max=0
        while True:
            if max<len(l1[n]):
                max=len(l1[n])
            n=n+1
            if n==len(l1):
                break
        if max>=2:
           print('No')
        else:
            print('YES')
else:
    l=s[A-1:C]
    l1=re.findall('#+',l)
    n=0
    max=0
    while True:
        if max<len(l1[n]):
            max=len(l1[n])
        n=n+1
        if n==len(l1):
            break            
    if max>=2:
        print('No')
    else:
        l=s[B-1:D]
        l1=re.findall('#+',l)
        n=0
        max=0
        while True:
            if max<len(l1[n]):
                max=len(l1[n])
            n=n+1
            if n==len(l1):
                break
        if max>=2:
            print('No')
        else:            
            s_list = list(s)
            s_list[D-1]='#'
            s="".join(s_list)
            l=s[B-2:D+1]
            l1=re.findall('\.+',l)
            n=0
            max=0
            while True:
                if max<len(l1[n]):
                    max=len(l1[n])
                n=n+1
                if n==len(l1):
                    break
            if max>=3:
                print('Yes')
            else:
                print('No')

Submission status: Wrong Answer

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

if b < a:
    a, b = b, a
    c, d = d, c

def solveSimple(s, a, b, c, d):     
    if '##' in s[b-1:d]:
        return False 
    if '##' in s[a-1:c]:
        return False
    return True

import re
def solveDifficult(s, a, b, c, d):
    center = (a+b)//2
    spot = [m.start() for m in re.finditer('\.\.\.', s)]
    
    if len(spot) == 0:
        return False

    for i, it in enumerate(spot):
        if it > center:
            break

    exchange = [i]
    exchange.append(i)

    for it in exchange:
        if solveSimple(s, a, b, it, it+1) and solveSimple(s, it, it+1, c, d):
            return True
    return False

# simple 
if c < d:
    ans = solveSimple(s, a, b, c, d)
    
# solveDifficult
else:
    ans = solveDifficult(s, a, b, c, d)
    
if ans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int,input().split())
S = input()
slist = list(S)
buf = "".join(slist[A:max(C,D)-1])
#print(N, A, B, C, D)
#print(S)

judge = buf.find("##")
#print(judge)

#print(slist[A::])
#print(judge)
if judge != -1:
  print("No")
else:
  if C < D:
    print("Yes")
  else:
    s_change= "".join(slist[A:C-1])
    print(s_change)
    judge = s_change.count("..")
    #print(judge)
    if judge > 1:
      print("Yes")
    else:
      judge = s_change.count("...")
      if judge >0:
        print("Yes")
      else:
        print("No")

Submission status: Wrong Answer

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

for i in range(len(S)):
    if S[i:i+2]=="##":
        print("No")
        break

if result == "":
    if C < D:
        result ="Yes"
    else: # D < C
        if S[B-2] == "." and S[B] == ".":
            result = "Yes"
        else:
            for i in range(B,D-5):
                if S[i:i+5] == "#...#":
                    result = "Yes"
                    break

if result == "":
    result = "No"

print(result)

Submission status: Wrong Answer

Solution code:
n,A,B,C,D = map(int,input().split())
s = input()[A-1:max(C,D)]
flag = 1
a,b,c,d = 0,B-A,C-A,D-A
if s[a]=='#' or s[b]=='#' or s[c]=='#' or s[d]=='#':
  flag = 0
if bool('##' in s) == 1:
  flag = 0
if c > d:
  scut = s[b-1:d+2]
  if bool('...' in scut) == 0:
    flag = 0
if flag == 1:
  print('YES')
else:
  print('NO')

Submission status: Wrong Answer

Solution code:
INPUT = input().split()
S = input()     # Nと同じ長さの文字列'.'と'#からなる。'

N = int(INPUT[0])    #マス目（文字列）の長さ
A = int(INPUT[1])    #すぬけ君の最初の位置
B = int(INPUT[2])    #ふぬけ君の最初の位置
C = int(INPUT[3])    #すぬけ君に最終的にいてほしい位置
D = int(INPUT[4])    #ふぬけ君に最終的にいてほしい位置

searchWord = '##'

if searchWord in S:
    print("No")
else:
    if C > D:
        if S[D - 1] == '#':
            print("No")
        else:
            if "..." in S:
                print("Yes")
            else:
                print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
def spaceinput():
    return list(map(int, input().split(" ")))


def count3(S, l, r):
    for i in range(l, r+1):
        if S[i:i+3] == "...":
            return True
    return False


def is_twocontinusblock(S, l, r):
    for i in range(l, r):
        if S[i:i+2] == "##":
            return True
    return False


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


def solve():
    if is_twocontinusblock(S, A, C-1) or is_twocontinusblock(S, B, D-1):
        return False
    if D < C:
        if count3(S, B-1, D-1):
            return True
        else:
            return False

    return True


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

Submission status: Wrong Answer

Solution code:
a=input().split()
b=input()

ans = 0
re = 0
if int(a[3])>int(a[4]):
	re = 1

p = 0
rock = 0
dot = 0
rock_ver = 0
re_ok = 0
for i in range(int(a[0])):
	if i + 1 == int(a[2]):
		p = 1
	b_i = b[int(i)]
	if b_i == "#":
		if rock == 1:
			ans = 1
			break
		if p == 1:
			if rock_ver == 0:
				rock_ver = 1
		rock = 1
		dot = 0
	else:
		rock = 0
		if p == 1:
			dot += 1
			if rock_ver == 0:
				if dot >=2:
					re_ok = 1
					break
			elif dot >= 3:
				re_ok = 1
				break

if re == 1:
	if re_ok == 0:
		ans = 1

print(re, re_ok, rock_ver)
if ans == 0:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

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


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


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


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


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


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

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

lis3  =[]
ct_iwa=0

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


if len(tmp3) == 3:
    lis3.append(tmp3)
if len(tmp_iwa) > 1:
    ct_iwa += 1

#print(lis3, ct_iwa)

flag=0

if c < d:
    #print('1')
    if ct_iwa == 0:
        print('Yes')
    else:
        print('No')
else:
    #print('2')
    for x in lis3:
        if x[0] < d - 1 and ct_iwa == 0:
            print('Yes')
            flag = 1
            break

    if flag == 0:
        print('No')