Problem:


Score : 400 points

Problem Statement

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

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

You can repeat the following operation any number of times:

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

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

Determine whether this is possible.

Constraints

4 \leq N \leq 200\ 000

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

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

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

A, B, C and D are all different.

A < B

A < C

B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

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

Sample Input 1

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

Sample Output 1

Yes

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

A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB

Sample Input 2

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

Sample Output 2

No

Sample Input 3

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

Sample Output 3

Yes



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


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)

N, A, B, C, D = map(int, input().split())
S = list(input())
S[A-1] = '#'; S[B-1] = '#'
S.extend(['#']*3)
def dfs(a = A, b = B):
    if a == C and b == D:
        return 'Yes'

    if S[a] == '.':
        S[a] = '#'; S[a-1] = '.'
        return dfs(a+1, b)
    if S[a+1] == '.':
        S[a+1] = '#'; S[a-1] = '.'
        return dfs(a+2, b)
    if S[b] == '.':
        S[b] = '#'; S[b-1] = '.'
        return dfs(a, b+1)
    if S[b+1] == '.':
        S[b+1] = '#'; S[b-1] = '.'
        return dfs(a, b+2)
    return 'No'
print(dfs())

Submission status: Wrong Answer

Solution code:
import math
import numpy as np


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


def main():
    _, A, B, C, D = inputs()
    S = input()
    maxDst = max(C, D)
    courseA = S[A-1:C]
    courseB = S[B-1:D]
    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 S[B-2:D+1]:
            if i == '.':
                cnt += 1
            if cnt == 3:
                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 = list(input())
last = ""
for i in range(a, c):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
for i in range(b, d):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
if c > d:
    print("Yes")
    exit()
    flag = True
    s[b - 1] = "#"
    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(b - 1, d):
        if s[i] == ".":
            count += 1
            if count == 3:
                flag = True
        else:
            count = 0
    if flag:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
lis=list(map(int,input().split()))
S=input()
ans="Yes"
memo=0
if lis[3]<lis[4]:
    #Bを先に行かせてみる
    for i in range(lis[2],lis[4]):
        if S[i:i+2]=="##":
            ans="No"
            break
    #更にAも行かせてみる
    for i in range(lis[1],lis[4]):
        if S[i:i+2]=="##":
            ans="No"
            break
    print(ans)

else:
    #Bの位置に岩を置く
    a=S[:lis[2]-1]
    b=S[lis[2]:]
    S=a+"#"+b
    #Aを先に行かせる。可能なら終了。ダメならBを先に行かせてみる
    for i in range(lis[1],lis[3]):
        if S[i:i+2]=="##":
            ans="No"
            break
    #先にBを行かせる。まず可能か判定
    if ans=="No":
        ans="Yes"
        for i in range(lis[2],lis[4]):
            if S[i:i+2]=="##":
                ans="No"
                break
        for i in range(lis[2],lis[4]-1):
            if S[i:i+3]=="...":
                memo=i+1
                break
        #だめなら終了。可能ならmemoに岩を置いてAについて検討
        if ans=="Yes":
            #print(S)
            if memo>0:
                a=S[:memo]
                b=S[memo+1:]
                S=a+"#"+b
            #print(S)
            a=S[:lis[2]-1]
            b=S[lis[2]:]
            S=a+"."+b
            #print(S,memo)
            for i in range(lis[1],lis[3]):
                if S[i:i+2]=="##":
                    ans="No"
                    break
        if memo==0:
            ans="No"
    print(ans)

Submission status: Wrong Answer

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

def max_stone(a, b):
  m = 0
  for j in range(a, b-1):
    if S[j] == S[j+1] == '#':
      return False
  
  return True
  
def reachable(b, d):
  n_sharp = 0
  n_dot = 0
  for j in range(b, d):
    s = S[j]
    if s=='.':
      n_dot += 1
      n_sharp = 0
    else:
      n_sharp += 1
      n_dot = 0
      
    if n_dot == 3:
      return True
    elif n_sharp == 2:
      return False
    
  return False
  
if C < B:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C < D:
  if max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')
elif B < C and C > D:
  if reachable(B-1, D) and max_stone(A-1, C) and max_stone(B-1, D):
    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)]
cumsum = itertools.accumulate(lst)
cumsum = list(cumsum) 
 
flag = True
flag_oinuki = False
for i in range(A,(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 = map(int,input().split())
s = list(input())
s_a =s[A-1:C]
s_b = s[B-1:D]

count = 0
if C < D :

    for i in range(C-A-1):
        if s_a[i] == "#" and s_a[i+1] == "#" :
            count += 1
    for i in range(D-B-1) :
        if s_b[i] == "#" and s_b[i+1] == "#" : 
            count += 1

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


else :
    p = 0
    for i in range(C-A-1):
        if s_a[i] == "#" and s_a[i+1] == "#" :
            count += 1
    for i in range(D-B-1) :
        if s_b[i] == "#" and s_b[i+1] == "#" : 
            count += 1
    
    for i in range(B-D-2):
        if s_b[i] == "." :
            if  s_b[i+1] == "." and s_b[i+2]=="." :
                p += 1
    if p >= 1 and count == 0:
        print("Yes")
    else: print("No")

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.find('##', A-1, C) >= 0:
        print('No')
    else:
        fnd = st.find('...', B-1, D+1)
        if fnd >= 0:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

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

    
    elif c>d:
        if i>b and i<c and s[i]=='#' and s[i+1]=='#':
            v+=1
            print('No')
            break
        elif i>=b-1 and i<d+1 and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.':
            v+=1
            print('Yes')
            break
if c<d and v==0:
    print('Yes')
    
if c>d and v==0:
    print('No')

Submission status: Wrong Answer

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

ans = "No"
if C < D:
  if "##" not in S:
    ans = "Yes"
elif C > D:
  if "..." in S:
    ans = "Yes"
print(ans)

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  =[]
lis_iwa=[]

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


if len(tmp3) > 2:
    lis3.append(tmp3)
if len(tmp_iwa) > 1:
    lis_iwa.append(tmp_iwa)



flag = 0

lis3 = [x for x in lis3 if x[0] > a - 1 and x[0] < d - 1]

lis_iwa = [x for x in lis_iwa if x[0] > a - 1 and x[-1] < max(c,d) - 1]

#print(lis3, lis_iwa)

if lis_iwa == []:
    if c < d:
        print('Yes')
    else:
        if lis3 != []:
            print('Yes')
        else:
            print('No')

else:
    print('No')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=list(input())
def check(a,c,s):
  if s[a-1]=="#"or"#"==s[c-1]:return False
  for i in range(c-a):
    if s[a-1+i]==s[a+i]=="#":return False
  return True
if c<d:
  if check(a,c,s)and check(b,d,s):print("Yes")
  else:print("No")
else:
  if not(check(b,d,s)):print("No");exit()
  f=False
  for i in range(d-b):
    if s[b-2+i:b+1+i]==[".",".","."]:f=True
  if f and check(a,c,s):print("Yes")
  else:print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(input())
last = ""
for i in range(a, c):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
for i in range(b, d):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
if c > d:
    flag = True
    s[b - 1] = "#"
    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(b - 1, d):
        if s[i] == ".":
            count += 1
            if count == 3:
                flag = True
        else:
            count = 0
    if flag:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

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:
            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()
index = [(n+1) for n, v in enumerate(s) if s[n:n+3] == "..."]
    
if s.count("##")>=1:
    print("No")
    exit()
    
if C < D:
    print("Yes")
    
elif C > D:
    if len(index)>=1:
        for i in range(B-1,D):
            if s[i-1]=="." and s[i]=="." and s[i+1]==".":
                print("Yes")
                exit()
        print("No")
    else:
        print("No")

Submission status: Wrong Answer

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

m = list(input())

m[a-1] = "A"
m[b-1] = "B"

answer = []
def a_mon(x,text,y):
    i = 0
    while True:
        if m.index(text) == y-1:
            answer.append("a")
            break
        elif x+i < n:
            if m[x+i] == ".":
                m[x-1+i],m[x+i] = m[x+i],m[x-1+i]
                i += 1
            if x+1+i < n:
                if m[x+1+i] == ".":
                    m[x-1+i],m[x+1+i] = m[x+1+i],m[x-1+i]
                    i += 2  
                else:
                    break
            else:
                if m.index(text) == y-1:
                    answer.append("a")
                    break
                break
        else:  
            break          
            
a_mon(b,"B",d)
a_mon(a,"A",c)

if len(answer) == 2:
    print("Yes")
else:
    print("No")
# .#..#..

Submission status: Wrong Answer

Solution code:

def input_from_console():
    n, a, b, c, d = map(int, input().split())
    s = input().rstrip()
    return n, a, b, c, d, s


def solve(n, a, b, c, d, s):
    def check(sub):
        if '##' in sub:
            return False
        return True

    # check for a
    s_a = s[a - 1:c]
    s_a_1 = s[a-1:c+1]
    state_a = check(s_a)
    if not state_a:
        return 'No'
    s_b = s[b - 1:d]
    state_b = check(s_b)
    if not state_b:
        return 'No'

    if c < d:
        return 'Yes'
    if c > d:  # can swap?
        s_b_d = s[b-1:d+1]
        if '...' in s_b_d:
            return 'Yes'
        else:
            return 'No'

    return 'Yes'


def main():
    n, a, b, c, d, s = input_from_console()
    print(solve(n, a, b, c, d, s))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = [int(i) for i in input().split()]
s = input()
if(c<d):
    print("Yes")
else:
    if '##' in s[b-2:d+1]:
        print("NO")
    elif '...' in s[b-2:d+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 blank(road):
    n=len(road)
    road='.'+road+'.'
    for i in range(1,n):
        block=road[i-1:i+2]
        if block=='...':
            return True
    return False

def judge(A,B,C,D,S):
    if C<D:
        return passable(S[A:C+1]) and passable(S[B:D+1])
    else:
        return passable(S[A:C+1]) and passable(S[B:D+1]) and blank(S[B:D+1])

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:
S = input()

flag = 0
ans = 0
i = 0
S= list(S)


while flag == 0:
    if len(S) < 3+i:
        flag = 1
    elif S[i]=="A" and S[i+1]=="B" and S[i+2]=="C":
        S[i] = 'B'
        S[i+1] = 'C'
        S[i+2] = 'A'
        i=0
        ans+=1
    elif S[i]=="A":
        i+=1
    else:
        S.pop(i+1)
print(ans)

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  =[]
lis_iwa=[]

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


if len(tmp3) > 2:
    lis3.append(tmp3)
if len(tmp_iwa) > 1:
    lis_iwa.append(tmp_iwa)



flag = 0

lis3 = [x for x in lis3 if x[0] > a - 1 and x[-1] < min(c, d) - 1]

lis_iwa = [x for x in lis_iwa if x[0] > a - 1 and x[-1] < max(c,d) - 1]

#print(lis3, lis_iwa)

if lis_iwa == []:
    if c < d:
        print('Yes')
    else:
        if lis3 != []:
            print('Yes')
        else:
            print('No')

else:
    print('No')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = list(map (int, input().split()))
s = input ()
s = '#' + s
 
ans = True
 
if '##' in s[a:max(c,d)]:
    ans = False
else:
    if d < c:
        ans = False
        for i in range(len(s)):
            if s[i:i+3] == '...':
                if '##' not in s[min(a,i):max(a,i)] and '##' not in s[min(b,i):max(b,i)]:
                    ans = True
                    break
        
 
if ans is True:
    print ('Yes')
else:
    print ('No')

Submission status: Wrong Answer

Solution code:
#Python標準入出力

import numpy as np

# 1行に複数の文字列（数字）を取得，整数に直す
# 今回は2つ受け取って，足し算する

# 0 len root 1 sunuke 2 funuke 3 point1 4 point2 funuke
Masu = list(map(int, input().split()))
Root = input()

N = Masu[0]
A = Masu[1]
B = Masu[2]
C = Masu[3]
D = Masu[4]

S = Root

At = A-1
Bt = B-1
Ct = C-1
Dt = D-1

Judge = True

#Answer 1 パターン入れ込み

# Rock = []
# for i in range(Masu[0]):
#     if Root[i] == "#":
#         Rock.append(i+1)
#
#
# threePoints = False
#
# for k in range(N):
#     if k < 1:
#         gg = 0
#     elif S[k] == "." and S[k-1] == "." and S[k-2] == ".":
#         # print("roop{}".format(k))
#         threePoints = True
#
# # print(threePoints)
#
# for j in range(Masu[0]):
#     if S[j] == "#" and S[j-1] == "#":
#         Judge = False
#
#     if C == j+1 and D == j+1-1 and Root[j-2] == "#" and (not threePoints):
#         Judge = False
#     if C == j+1 and Root[j-1] == "#" and D == j+1-2 and (not threePoints):
#         Judge = False
#
#     # if Masu[3] == j+1:
#     #     for p in range(j):
#     #         if Masu[4] == p+1 and Root[p-1] == "#":
#     #             Judge = False
#
# if Judge:
#     print("Yes")
# else:
#     print("No")









#Answer 2 動かし

Sunuke = At
Funuke = Bt
throuth = 0


if C < D:
    for i in range(N-Funuke):

        ii = i+Bt

        # print("current {0}: funuke: {1}".format(ii,Funuke))
        if Funuke == Dt:
            break

        elif S[ii] == "#" and S[ii+1] == "#":
            Judge = False
            break

        elif S[ii] == "#":
            throuth = 0

        elif S[ii+1] == ".":
            Funuke = Funuke+1

        elif S[ii+1] == "#":
            Funuke = Funuke+2

    #
    # print("Funuke: {}".format(Funuke))
    # print("Sunuke: {}".format(Sunuke))
    # print(At)
    if Judge:
        for j in range(N-Sunuke):

            jj = j+At
            # print("current {0}: Sunuke: {1}".format(jj, Sunuke))

            if Sunuke == Ct:
                break

            elif S[jj] == "#" and jj + 1 == Funuke:
                Judge = False
                break

            elif S[jj] == "#":
                throuth = 0

            elif S[jj + 1] == ".":
                Sunuke = Sunuke + 1

            elif S[jj + 1] == "#" or jj+1 == Funuke:
                Sunuke = Sunuke + 2

    #
    # print(Sunuke)
    # print(Funuke)
    #

else:
    Rock = []
    for i in range(Masu[0]):
        if Root[i] == "#":
            Rock.append(i + 1)

    threePoints = False

    for k in range(N):
        if k < 1:
            gg = 0
        elif S[k] == "." and S[k - 1] == "." and S[k - 2] == ".":
            # print("roop{}".format(k))
            if D+1 > k:
                threePoints = True

    # print(threePoints)

    for j in range(Masu[0]):
        if S[j] == "#" and S[j - 1] == "#":
            Judge = False

        if C == j + 1 and D == j + 1 - 1 and Root[j - 2] == "#" and (not threePoints):
            Judge = False
        if C == j + 1 and Root[j - 1] == "#" and D == j + 1 - 2 and (not threePoints):
            Judge = False

            # if Masu[3] == j+1:
            #     for p in range(j):
            #         if Masu[4] == p+1 and Root[p-1] == "#":
            #             Judge = False

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

Submission status: Wrong Answer

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

m = list(input())

m[a-1] = "A"
m[b-1] = "B"

answer = []
def a_mon(x,text,y):
    i = 0
    while True:
        print(i)
        if m.index(text) == y-1:
            answer.append("a")
            break
        elif x+i < n:
            if m[x+i] == ".":
                m[x-1+i],m[x+i] = m[x+i],m[x-1+i]
                i += 1
            if x+1+i < n:
                if m[x+1+i] == ".":
                    m[x-1+i],m[x+1+i] = m[x+1+i],m[x-1+i]
                    i += 2  
                else:
                    break
            else:
                print(m)
                if m.index(text) == y-1:
                    answer.append("a")
                    break
                break
        else:  
            break          
            
a_mon(b,"B",d)
a_mon(a,"A",c)

if len(answer) == 2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
s = list(input())
s_a =s[A-1:C]
s_b = s[B-1:D]

count = 0
if C < D :

    for i in range(C-A-1):
        if s_a[i] == "#" and s_a[i+1] == "#" :
            count += 1
    for i in range(D-B-1) :
        if s_b[i] == "#" and s_b[i+1] == "#" : 
            count += 1

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


else :
    p = 0
    for i in range(C-A-1):
        if s_a[i] == "#" and s_a[i+1] == "#" :
            count += 1
    for i in range(D-B-1) :
        if s_b[i] == "#" and s_b[i+1] == "#" : 
            count += 1
    
    for i in range(C-A-2):
        if s_a[i] == "." :
            if  s_a[i+1] == "." and s_a[i+2]=="." :
                p += 1
    for i in range(D-B-2):
        if s_b[i] == "." :
            if  s_b[i+1] == "." and s_b[i+2]=="." :
                p += 1
    if p >= 1 and 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())
print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
S = input()
if c > d:
    if a>b:
        if "##" in S[b:c]:
            print("No")
            exit() 
    else:
        if "##" in S[a:c]:
            print("No")
            exit() 
        if "..." not in S[b-1:d+1]:
            print("No")
            exit()
if c < d:
    if a<b:
        if "##" in S[a:d]:
            print("No")
            exit() 
    else:
        if "##" in S[b:d]:
            print("No")
            exit() 
        if "..." not in S[a-1:c+1]:
            print("No")
            exit()

print("Yes")

Submission status: Wrong Answer

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

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:
        fnd = st.find('...', B-1, D+1)
        if fnd >= 0:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

Solution code:
S=input().replace('BC','D')
S.strip('BC')
scount=0
i=0
while i < 1:
    if 'AD' in S:
        scount += S.count('AD')
        S=S.replace('AD','DA')
        i=0
    else:
        print(scount)
        i=2

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# agc034/agc034_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, A, B, C, D = i2nn()
    S = i2s()
    if '##' not in S[B-1:D] and '##' not in S[A-1:C]:
        if C < D:
            print('Yes')
        elif  '...' in S[B-1:D+2]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
    return

main()

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = (int(i) for i in input().split())  
s = input()
e = 0
if c<d:
  if s[a:c+1].count("##")==0 and s[b:d+1].count("##")==0:
    print("Yes")
  else:
    print("No")
else:
  for i in range(b,d+1):
    if s[i-1:i+2]=="...":
      e = 1 
  if e == 1:
    print("Yes")
  else:
    print("No")

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

Solution code:

def input_from_console():
    n, a, b, c, d = map(int, input().split())
    s = input().rstrip()
    return n, a, b, c, d, s


def solve(n, a, b, c, d, s):
    def check(sub):
        if '##' in sub:
            return False
        return True

    # check for a
    s_a = s[a - 1:c]
    s_a_1 = s[a-1:c+1]
    state_a = check(s_a)
    if not state_a:
        return 'No'
    s_b = s[b - 1:d]
    state_b = check(s_b)
    if not state_b:
        return 'No'

    if c < d:
        return 'Yes'
    if c > d:  # can swap?
        if '...' in s_a:
            if '...' in s_b:
                return 'Yes'
        else:
            return 'No'

    return 'Yes'


def main():
    n, a, b, c, d, s = input_from_console()
    print(solve(n, a, b, c, d, s))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Wrong Answer

Solution code:
import sys

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

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

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

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-2,D-1):
                if S[i:i+3] == "...":
                    result = "Yes"

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

print(result)

Submission status: Wrong Answer

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


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


def search(start, goal):
    for i in range(start+1, goal - 2):
        if s[i] + s[i + 1] == '##':
            return False
    return True


def search3(start, goal):
    for i in range(start, goal - 3):
        if s[i] + s[i + 1]+s[i+2] == '...':
            return True
    return False


if c < b:
    if search(a, c) and search(b, d):
        print('Yes')
    else:
        print('No')

else:
    if search3(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()
if c > d:
    if a>b:
        if "##" in S[b:c]:
            print("No")
            exit() 
    else:
        if "##" in S[a:c]:
            print("No")
            exit() 
        if "..." not in S[b-1:d]:
            print("No")
            exit()
if c < d:
    if a<b:
        if "##" in S[a:d]:
            print("No")
            exit() 
    else:
        if "##" in S[b:d]:
            print("No")
            exit() 
        if "..." not in S[a-1:c]:
            print("No")
            exit()

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):
    print("Yes")
else:
    if '...' in s[b-2:d+1]:
        print("YES")
    else:
        print("NO")

Submission status: Wrong Answer

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

e = []
e.append(a)
e.append(b)
e.append(c)
e.append(d)

roada = road[a-1:c]
roadb = road[b-1:d]
roadc = road[a-2:d+1]

if '##' in roada and '##' in roadb:
    print('No')
if d > c:
    print('Yes')
else:
    if '...' in roadc:
        print('Yes')
    else:
        print('No')