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:
from collections import deque
n, a, b, c, d = map(int, input().split())
s = list(input())
visited1 = [False] * (n+1)
visited2 = [visited1] * (n+1)
visited2[a][b] = True
space_list = [False] * (n+3)
for i in range(n):
    if s[i] == '.':
        space_list[i+1] = True
# print(space_list)

# q = queue.Queue()
# q.put([a,b])
q = []
q.append([a,b])
is_possible = False
while len(q) > 0:
    current_q = q.pop()
    pos_a = current_q[0]
    pos_b = current_q[1]
    if pos_a == c and pos_b == d:
        is_possible = True
        break
    if space_list[pos_a+2] and (pos_a+2 != pos_b) and pos_a+2 <= c:
        if not visited2[pos_a+2][pos_b]:
            q.append([pos_a+2, pos_b])
            visited2[pos_a+2][pos_b] = True
    if space_list[pos_a+1] and (pos_a+1 != pos_b) and pos_a+1 <= c:
        if not visited2[pos_a+1][pos_b]:
            q.append([pos_a+1, pos_b])
            visited2[pos_a+1][pos_b] = True
    if space_list[pos_b+2] and (pos_b+2 != pos_a) and pos_b+2 <= d:
        if not visited2[pos_a][pos_b+2]:
            q.append([pos_a, pos_b+2])
            visited2[pos_a][pos_b+2] = True
    if space_list[pos_b+1] and (pos_b+1 != pos_a) and pos_b+1 <= d:
        if not visited2[pos_a][pos_b+1]:
            q.append([pos_a, pos_b+1])
            visited2[pos_a][pos_b+1] = True
    

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

Submission status: Wrong Answer

Solution code:
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [0] + [1 if i == "#" else 0 for i in list(S)] + [1]
cumsum = itertools.accumulate(lst)
cumsum = list(cumsum) 
 
flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if ((cumsum[i+2] - cumsum[i]) == 2):
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3] and (j + 2 <= D):
        flag_oinuki = True
 
if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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


flag1 = False
block = 0
for i in range(b, len(s)):
    if block == 2:
        flag1 = False
        break
    elif i == d-1:
        flag1 = True
        break
    elif s[i] == ".":
        block = 0
    elif s[i] == "#":
        block += 1

if flag1 == True:
    s2 = s[:d-1]+'#'+s[d:]
    flag1 = False
    block = 0
    for i in range(a, len(s)):
        if block == 2:
            flag1 = False
            break
        elif i == c-1:
            flag1 = True
            break
        elif s2[i] == ".":
            block = 0
        elif s2[i] == "#":
            block += 1


flag2 = False
flag3 = False
temp = 0
block = 0
for i in range(b-2,c-2):
    if temp == 3:
        flag2 = True
        temp = i-1
        break
    elif s[i] == "#":
        temp = 0
    elif s[i] == ".":
        temp += 1

if flag2 == True:
    flag3 = False
    block = 0
    s1 = s[:temp-1]+'#'+s[temp:]
    for i in range(a, len(s)):
        if block == 2:
            flag3 = False
            break
        elif i == c-1:
            flag3 = True
            break
        elif s1[i] == ".":
            block = 0
        elif s1[i] == "#":
            block += 1

    if flag3 == True:
        s3 = s1[:c - 1] + '#' + s1[c:]
        flag3 = False
        block = 0
        for i in range(temp + 1, len(s)):
            if block == 2:
                flag3 = False
                break
            elif i == c-1:
                flag3 = True
                break
            elif s3[i] == ".":
                block = 0
            elif s3[i] == "#":
                block += 1

if flag1 or flag3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
import math
import numpy as np


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


def main():
    N, A, B, C, D = inputs()
    S = input()
    maxDst = max(C, D)
    courseA = S[A:C+1]
    courseB = S[B:D+1]
    cnt = 0
    ans = []
    for i in courseB:
        if i == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            ans.append(False)
            break
    else:
        ans.append(True)
    cnt = 0
    for i in courseA:
        if i == '#':
            cnt += 1
        else:
            cnt = 0
        if cnt == 2:
            ans.append(False)
            break
    else:
        ans.append(True)
    if maxDst == C:
        cnt = 0
        for i in courseB:
            if i == '.':
                cnt += 1
            else:
                cnt = 0
            if cnt == 2:
                ans.append(True)
                break
        else:
            ans.append(False)

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


if __name__ == '__main__':
    main()

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:
    l = 0
    r = N-1
    for i in range(1,N):
        if S[i-1] == "#" and S[i] == "#":
            if i+1 <= A-1:
                l=i+1
            else:
                r = i-2
                break
    
    if ("..." in S[l:r+1]) and (r >= C-1):
        print("Yes")
    else:
        print("No")

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):
            sf = (S[A-1:D].count('...'))
            if(sf == 0):
                print(NO)
            ######### あとはここだけ考える ####
            elif(sf == 1):
                tS = list(S)
                tS[B-1] = 'b'
                tS = ''.join(tS)
                if(tS[A-1:D].count('..b') == 1):
                    print(NO)
                else:
                    print(YES)
            #################################
            elif(sf >= 2):
                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())
a-=1
b-=1
c-=1
d-=1

temp=str(input())
maxim=max(a,b)
minim=min(a,b)
if temp[maxim:].count("...")!=0 or temp[maxim+1]==temp[maxim+2]=="." or temp[maxim+1]==temp[maxim-1]==".":
    flag=1
else:
    flag=0
    
s=list(temp)
s[a]="A"
s[b]="B"
s[c]="C"
s[d]="D"

ans=1

for i in range(minim,n-1):
    if s[i]==s[i+1]=="#":
        ans=0
        

if c<d and ans==1:
    ans=1
elif c>d and ans==1:
    if flag==1:
        ans=1
    elif s[d-1]=="#" or s[d+1]=="#":
        ans=0
    else:
        ans=0
                
if ans==1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def passable(road):
    n=len(road)
    for i in range(n-1):
        block=road[i:i+2]
        if block=='##':
            return False
    return True

def safe_place(road):
    n=len(road)
    for i in range(n-2):
        block=road[i:i+3]
        if block=='...':
            return i+1
    return -1

def passEach(A,B,C,D,road):
    if passable(road[A:C+1]) and passable(road[B:D+1]):
        return True
    else:
        return False

def judge(A,B,C,D,S):
    if C<D:
        return passEach(A,B,C,D,S)
    else:
        S2=S[:B]+'#'+S[B+1:]
        if passable(S2[A:C+1]) and passable(S[B:D]):
            return True
        safePlace=safe_place(S[B:D+1])
        if safePlace!=-1 and passEach(A,B,C,safePlace+B,S) and passEach(A,safePlace+B,C,D,S):
            return True
    return False

N,A,B,C,D=map(int,input().split())
S=input()
if judge(A-1,B-1,C-1,D-1,S):
    print('Yes')
else:
    print('No')

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 s[d-2]=='.' and s[d]=='.':
        flg=False
    if 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:
N, A, B, C, D = [int(i) - 1 for i in input().strip().split(' ')]
N += 1
S = [c for c in input().strip()]


def get(a, b):
  s = S[:]
  s[a] = 'A'
  s[b] = 'B'

  return s


def is_reachable(s, a, b):
  i = a
  while i < C:
    if i + 1 <= C and s[i + 1] == '.':
      i = i + 1
    elif i + 2 <= C and s[i + 2] == '.':
      i = i + 2
    else:
      break
  is_a = i == C

  i = b
  while i < D:
    if i + 1 <= D and s[i + 1] == '.':
      i = i + 1
    elif i + 2 <= D and s[i + 2] == '.':
      i = i + 2
    else:
      break
  is_b = i == D

  return is_a, is_b


def move(s, i, dest):
  if i == dest:
    return -1

  while i <= dest:
    if i == dest:
      return dest

    if i + 1 <= dest and i + 2 < N:
      if s[i] == '.' and s[i + 1] == '.' and s[i + 2] == '.':
        return i + 1

    i = i + 1

  return -1


def main():
  a = A
  b = B

  for _ in range(1000):
    s = get(a, b)
    is_a, is_b = is_reachable(s, a, b)
    # print(_, (is_a, is_b), s)
    if is_a and is_b:
      return True
    elif not is_a:
      b = move(s, b, D)
      if b < 0:
        return False
    elif not is_b:
      a = move(s, a, C)
      if a < 0:
        return False
    else:
      return False


print('Yes' if main() else 'No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

can=True
CD = max(C,D)
for i in range(A,CD-1):
  if (S[i] & S[i+1]):
    can=False

if (C>D):
  safe=True
  for i in range(A,D-2):
    if (S[i] & S[i+1] & S[i+2]):
      safe=False
  can = can & safe

print("Yes" if can else "No")

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):
            sf = (S[A-1:D].count('...'))
            if(sf == 0):
                print(NO)
            ######### あとはここだけ考える ####
            elif(sf == 1):
                tS = list(S)
                tS[B-1] = 'b'
                tS = ''.join(tS)
                if(tS[A-1:D].count('..b#') == 1):
                    print(NO)
                else:
                    print(YES)
            #################################
            elif(sf >= 2):
                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:
number_of_masu, firstsunuke, firstfunuke, lastsunuke, lastfunuke = map(int, input().split())
s = str(input())
tobenaiflag = 0
nukaseruflag = 0
lastfunuke -= 1
lastsunuke -= 1
firstsunuke -= 1
firstfunuke -= 1

# 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
tobenaiflag = 1
if lastfunuke < lastsunuke:
    for j in range(max(firstsunuke, firstfunuke)-1, lastfunuke-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')
print('Yes')

Submission status: Wrong Answer

Solution code:
n = [int(i) for i in input().split()]
s = input()

if n[3] > n[4]:
    s1 = n[1]
    s2 = n[2]
    g1 = n[3]
    g2 = n[4]

    sss = s[n[1]: g2].find('##')
    if sss == -1:
        ssss = s[s2:g1].find('...')
        if ssss == -1:
            print('No')
        else:
            print('Yes')
    else:
        print('No')

else:
    s1 = n[2]
    s2 = n[1]
    g1 = n[4]
    g2 = n[3]

    sss = s[n[1]: g2].find('##')
    if sss == -1:
        print("Yes")
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
n, a_, b_, c_, d_ = map(int, input().split())
s_ = input()

def unchi(a,b,c,d,s):
  ss, s = s, s[:b] + '#' + s[b+1:]
    
  if (len(max(s[b:d].split("."))) < 2):
    b = d
    s = s[:b] + '#' + s[b+1:]
  
  s = ss
  if(len(max(s[a:c].split("."))) < 2):
    a = c
    s = s[:a] + '#' + s[a+1:]
  
  if(a==c and b==d):
    return 1
  else:
    return 0
    
#if (c_ < d_):
if (unchi(a_-1,b_-1,c_-1,d_-1,s_)==1 or unchi(b_-1,a_-1,d_-1,c_-1,s_)==1):
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

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

A -= 1
B -= 1
C -= 1
D -= 1
S[A] = 'a'
S[B] = 'b'

ans_D = False
ans_C = False

b = B
a = A

if C <= D:
    while True:
        if b == D:
            ans_D = True
            break
        else:
            if S[b+1] == '.':
                S[b] = '.'
                S[b+1] = 'b'
                b += 1
            else:
                if S[b+2] == '.':
                    S[b] = '.'
                    S[b+2] = 'b'
                    b += 2
                else:
                    break
    if ans_D:
        while True:
            if a == C:
                ans_C = True
                break
            else:
                if S[a+1] == '.':
                    S[a] = '.'
                    S[a+1] = 'a'
                    a += 1
                else:
                    if S[a+2] == '.':
                        S[a] = '.'
                        S[a+2] = 'a'
                        a += 2
                    else:
                        break
    if ans_C and ans_D:
        print('YES')
    else:
        print('No')
else:
    swap_flag = False
    while b + 1 < N:
        if (S[b-1] == '.' and S[b+1] == '.') or (S[b-1] == 'a' and S[b+1] == '.'):
            swap_flag = True
            break
        else:
            if S[b+1] == '.':
                S[b] = '.'
                S[b+1] = 'b'
                b += 1
            else:
                if S[b+2] == '.':
                    S[b] = '.'
                    S[b+2] = 'b'
                    b += 2
                else:
                    break
    if swap_flag:
        while True:
            if a == C:
                ans_C = True
                break
            else:
                if S[a+1] == '.':
                    S[a] = '.'
                    S[a+1] = 'a'
                    a += 1
                else:
                    if S[a+2] == '.':
                        S[a] = '.'
                        S[a+2] = 'a'
                        a += 2
                    else:
                        break
        if ans_C:
            while True:
                if b == D:
                    ans_D = True
                    break
                else:
                    if S[b+1] == '.':
                        S[b] = '.'
                        S[b+1] = 'b'
                        b += 1
                    else:
                        if S[b+2] == '.':
                            S[b] = '.'
                            S[b+2] = 'b'
                            b += 2
                        else:
                            break
            if ans_C and ans_D:
                print('YES')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
def clear_check(s,start,target):
    block_len = 0
    for i in range(start,target+1):
        if s[i] == '#':
            block_len += 1
        else:
            block_len = 0

        if block_len > 1:
            return False

    return True

def rev_check(s,start,end):
    space_len = 0
    for i in range(start,end+1):
        if s[i] == '.':
            space_len += 1
        else:
            space_len = 0

        if space_len >= 3:
            return True

    return False

def calc():
    n, a, b, c, d = [int(i) for i in input().split()]
    s = input()
    result = clear_check(s,a-1,c-1) and clear_check(s,b-1,d-1)

    if result and  c > d :
        result = rev_check(s,b-1,d-1)

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

if __name__ == '__main__':
    calc()

Submission status: Wrong Answer

Solution code:
from itertools import*
import math
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N,A,B,C,D = map(int,input().split())
S = list(input())
SA = deepcopy(S)
SB = deepcopy(S)
SA[B-1] = "#"
SB[D-1]=  "#"

bool=False
for i in range(B-1,D):
    if i >= N-1:
        break
    if S[i] == "." and S[i-1]=="." and S[i+1]==".":
        bool = True
        break
if bool:
    for i in range(A,max(C,D)):
        if S[i]=="#"and S[i-1]=="#":
            print("No")
            exit()
    print("Yes")
else:
    bool1,bool2,bool3 = True,True,True
    #Bを先にDに進める戦略
    for i in range(A,C):
        if SB[i-1]=="#" and SB[i]=="#":
            bool1 = False
            break
    #Aを先に進めるため最初進められるかどうかの判定
    for i in range(A,C):
        if SA[i-1]=="#" and SA[i]=="#":
            bool2 = False
            break
    SA[B-1]="."
    SA[C-1]="#"
    #Aを先にCに進める戦略
    for i in range(B,D):
        if SA[i-1]=="#" and SA[i]=="#":
            bool3 = False
            break
    if bool1 or(bool2 and bool3):
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
x = input().split()
s = input()
n = int(x[0])
a = int(x[1])
b = int(x[2])
c = int(x[3])
d = int(x[4])
 
 
kome_flag = False
santen_flag = False
 
a_s = s[a:c]
b_s = s[b:d]

if c < d:
  if '...' in s[b:c]:
    santen_flag = True
if d < c:
  if '...' in s[b:d]:
    santen_flag = True
  
if not '##' in a_s and not '##' in b_s:
  kome_flag = True
    
if not '#' in b_s:
	print('Yes')
else:
	if c < d:
		if kome_flag:
			print('Yes')
		else:
			print('No')
 
	if d < c:
		if kome_flag and santen_flag:
			print('Yes')
		else:
			print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = list(map(int, input().split()))
S = [0]+[0 if s=='.' else 1 for s in input()]
can_jump = [0] + [1-S[i]*S[i+1] for i in range(N-1)]
can_change = [0] + [(1-S[i])*(1-S[i+1])*(1-S[i+2]) for i in range(N-2)]

def Solution():
  if not all(can_jump[A:C]):
    return False
  if not all(can_jump[B:D]):
    return False
  
  if C<D:
    return True
  if C>D:
    if any(can_change[B-1:C-1]):
      return True
    else:
      return False

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)

# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

def main():
	N, A, B, C, D = map(int, input().split(" "))
	#N = int(input())
	S = input()
	S = list(S)
	S = S[:-1]

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

	if C < D:
		S = S[A:D+1]
	else:
		S = S[A:C+1]

	iwa = []
	kara = []
	nige = []
	for i, val in enumerate(S):
		if val == "#":
			if len(iwa) > 1 and iwa[-1] == i-1:
				print("No")
				sys.exit()
			iwa.append(i)
		else:
			if len(kara) > 2 and kara[-1] == i-1 and kara[-2] == i-2:
				nige.append(i-2)
			kara.append(i)
	#print(S)
	#print(nige)
	'''
	for i in range(A+1, C):
		if i in iwa:
			tmp = iwa.index(i)
			if len(iwa)-1 > tmp and iwa[tmp+1] == i+1:
				print("No")
				sys.exit()

	for i in range(B+1, D):
		if i in iwa:
			tmp = iwa.index(i)
			if len(iwa)-1 > tmp and iwa[tmp+1] == i+1:
				print("No")
				sys.exit()
	'''
	if A < B and B < C and C < D:
		print("Yes")
		sys.exit()
	elif A < C and C < B and B < D:
		print("Yes")
		sys.exit()
	else:
		for i in nige:
			if B <= i and i+2 <= D:
				print("Yes")
				sys.exit()
	'''
	elif A < B and B < D and D < C:
		for i in range(A+1, C):
			if i in kara:
				tmp = kara.index(i)
				if C >= i+2 and len(kara)-2 > tmp :
					if (kara[tmp+1] == i+1) and (kara[tmp+2] == i+2):
						print("Yes")
						sys.exit()
		print("No")
		sys.exit()
	'''
	print("No")
	

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

S= input()

if('##'  in S[A-1:max({C,D})]):
  print("No")
elif(C<D):
  print("Yes")
elif(C>D):
  if('...'in S):
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

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


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

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

if S[B-2] != "#" and S[B] == ".":
    print("Yes")
    exit()
    
if S[B-2] == "#" and S[B] == "." and S[B+1] == ".":
    print("Yes")
    exit()

for i in range(N):
    
    if i+B+2 >= N:
        print("No")
        exit()
        break
    
    if i+B+2 > D:
        print("Yes")
        exit()
        break
        
    if S[i+B] == "." and S[i+B+1] == "." and S[i+B+2] == ".":
        print("Yes")
        exit()

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
lastfunuke -= 1
lastsunuke -= 1
firstsunuke -= 1
firstfunuke -= 1

# 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
tobenaiflag = 1
if lastfunuke < lastsunuke:
    for j in range(max(firstsunuke, firstfunuke)-1, lastfunuke-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')
print('No')

Submission status: Wrong Answer

Solution code:
l = list(map(str, input().split()))
str=input()

num = int(l[0])
ast = l[1]
bst = l[2]
afin=int(l[3])
bfin=int(l[4])




if(ast > bst):
    st=int(bst)
    fin=int(ast)
if(bst > ast):
    st=int(ast)
    fin=int(bst)


if(afin > bfin):
    fst=int(bfin)
    ffin=int(afin)
if(bfin > afin):
    fst=int(afin)
    ffin=int(bfin)


kiritorist= str[st+1:num]
kiritorifin=str[fin-1:fst]

if(afin !="#" or bfin !="#"):
    if(kiritorist.find('##')>0):
        print("No")
    
    if(kiritorist.find('##')<0):
        if((ast<bst and afin<bfin)or(bst<ast and bfin<afin)):
            print("Yes")
    
        if((ast<bst and bfin<afin)or(bst<ast and afin<bfin)):
            if(kiritorifin.find('...'))>0:
                print("Yes")
            else:
                print("No")

Submission status: Wrong Answer

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

# 間に＃が連続していなければ通るはず

if not "##" in S[B-1:D-1]:
    S = list(S)
    S[D-1] = "B"
    S = ''.join(S)
    if not "##" in S[A-1:C-1]:
        if "B#" in S[A-1:C-1] or "#B" in S[A-1:C-1]:
            if "..." in S[B-2:C]:
                print("Yes")
            else:
                print("No")
        else:
            print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
# import statistics
import bisect
import copy
import fractions
import math
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v):
    # ノードに訪れた
    visited[v] = True
    for v2 in range(n):
        if graph[v][v2] == False:  # そもそもvとv2が辺でつながっていない
            continue
        if visited[v2] == True:  # もう見た
            continue
        dfs(v2)


n, a, b, c, d = MI()
s = [s for s in input()]
aki = []
for i in range(1, len(s)):
    if s[i] == '#' and s[i-1] == '#':
        if a-1 < i < c-1 or b-1 < i < d-1:
            print('No')
            exit()

if c < d:
    print('Yes')
else:
    for i in range(2, len(s)):
        if s[i] == '.' and s[i-1] == '.' and s[i-2] == '.':
            aki.append(i)
    if s[d-2] == '#' and s[d] == '#':
        for num in aki:
            if b-1 <= num < d-2:
                print('Yes')
                exit()
        print('No')
        exit()
    elif s[d-2] == '#':
        for num in aki:
            if b-1 <= num < d-2:
                print('Yes')
                exit()
        print('No')
        exit()
    elif s[d] == '#':
        for num in aki:
            if b-1 <= num < d:
                print('Yes')
                exit()
        print('No')
        exit()
    elif s[d-2] == '.' and s[d] == '.':
        print('Yes')
        exit()
    print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if s[a-1:max(c,d)].count("##")>0:
    print("No")
elif c<d:
    print("Yes")
else:
    if s[b-2:d:].count("...")==0:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
cou1 = 0
ans1 = 0
cou2 = 0
ans2 = 0
S = S[A: max(C, D)-1]
for i in S:
    if i == "#":
        cou1 += 1
        ans2 = min(ans2, cou2)
        cou2 = 0
    else:
        cou2 += 1
        ans1 = max(ans1, cou1)
        cou1 = 0
if D > C:
    ans2 = 4
if ans1 < 2 and ans2 >= 3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = [int(i) for i in input().split()]
s = input()
t = s.split("#")
cnt = -1
if(s.count('##') > 0):
    frag = 0
elif(c<d):
    frag = 1
else:
    frag = 0
    frag1 = 0
    frag2 = 0
    frag3 = 0
    for i in range(len(t)):
        cnt += len(t[i])+1
        if(cnt < d and i > 0):
                if(t[i].count('.') >= 3):
                    frag1 = 1
    cnt -= t[len(t)-1].count('.')
    if(s[b] == '.' or frag1 == 1):
        frag2 = 1
    if(s[d-2] == '.' or frag1 == 1):
        frag3 = 1
    if(frag1 == 1 and frag2 == 1 and frag3 == 1):
        frag = 1
if(frag == 1):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

if "##" in S:
    print("No")
    exit()

for i in range(B-1,D):
    if S[i] == ".":
        if D == len(S):
            S_ = S[:i] + "#"
        else:
            S_ = S[:i] + "#" + S[i+1:]

        if not "##" in S_[A-1:C]:
            print("Yes")
            exit()

print("No")

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-1:d+1].count("...")>0 :
    print("Yes")
  elif s[a:c+1].count("##")==0 and s[b:d+1].count("##")==0 and s[d-1:d+2]=="..." :
    print("Yes")
  else:
    print("No")