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: Accepted

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-1, d+2):
    s = S[j]
    if s=='.':
      n_dot += 1
      n_sharp = 0
    else:
      n_sharp += 1
      n_dot = 0
      
    if n_dot == 3:
      return True
    
  return False

def reachable2(b, d):
  for k in range(b-1,d):
    if S[k] == S[k+1] == S[k+2] == ".":
      return True
  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 reachable2(B-1, D-1) and max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')

Submission status: Accepted

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-1, d+1):
    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

def reachable2(b, d):
  for k in range(b-1,d):
    if S[k] == S[k+1] == S[k+2] == ".":
      return True
  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 reachable2(B-1, D-1) and max_stone(A-1, C) and max_stone(B-1, D):
    print('Yes')
  else:
    print('No')

Submission status: Accepted

Solution code:
def main():
	n,a,b,c,d = map(int,input().split())
	a-=1
	b-=1
	c-=1
	d-=1
	s = input()
	if '##' in s[a:c+1] or '##' in s[b:d+1]:
		print('No')
		return

	if c<d:
		print('Yes')
		return
	elif '...' in s[b-1:d+2]:
		print('Yes')
		return
	else:
		print('No')
main()

Submission status: Accepted

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

ans = "No"
if "##" in s[a-1:c] or "##" in s[b-1:d]: pass
else:
    if c<d: ans = "Yes"
    else:
        if "..." in s[b-2:d+1]: ans = "Yes"


print(ans)

Submission status: Accepted

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+1].count("...")!=0:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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

s = input()

if c < d:
    for i in range(a,d-1):
        if s[i]==s[i+1]=='#':
            print('No')
            exit()
    print('Yes')
else:
    flag = False
    for i in range(a,c-1):
        if s[i]==s[i+1]=='#':
            print('No')
            exit()
    for i in range(b-1,d):
        if s[i]==s[i+1]==s[i+2]=='.':
            flag = True
            break
    if not flag:
        print('No')
        exit()
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

def solve():
    ac = S[A - 1:C]
    if A < B < D < C:
        bd = S[B - 2:D + 1]
        return ("##" not in ac and "..." in bd)
    else:
        bd = S[B - 1:D]
        return ("##" not in ac and "##" not in bd)

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

Submission status: Accepted

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):
    ret = YES
    if '##' in S[A - 1:C] or '##' in S[B - 1:D]:
        ret = NO
    else:
        if D < C:
            #if S[B - 2:B] == '..' or S[B - 1:B + 1] == '..':
            if not '...' in S[B - 2:D + 1]:
                ret = NO
    print(ret)
    return
 
 
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)
 
if __name__ == '__main__':
    main()

Submission status: Accepted

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: Accepted

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):
    ret = YES
    if '##' in S[A:C] or '##' in S[B:D]:
        ret = NO
    else:
        if D < C:
            #if S[B - 2:B] == '..' or S[B - 1:B + 1] == '..':
            if not '...' in S[B - 2:D + 1]:
                ret = NO
    print(ret)
    return
 
 
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)
 
if __name__ == '__main__':
    main()

Submission status: Accepted

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()
    ans = []
    if '##' in S[A:C]:
        ans.append(False)
    else:
        ans.append(True)
    if '##' in S[B:D]:
        ans.append(False)
    else:
        ans.append(True)
    if D < C:
        if '...' in S[B-2: D+1]:
            ans.append(True)
        else:
            ans.append(False)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N, A, B, C, D = map(int, input().split())
    S = str(input())
 
    answer = "-1"
 
    if C < D:
       if S[A:D:].count("##") >= 1:
           answer = "No"
       else:
           answer = "Yes"
    else:
       if S[B-2:D+1:].count("...") >= 1:
           answer = "Yes"
       else:
           answer = "No"
 
    print(answer)

Submission status: Accepted

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

if "##" in S[A:max(C, D)]:
    print("No")
    exit()

if C > D:
    if "..." in S[B-2:D+1]:
        print("Yes")
    else:
        print("No")
else:
    print("Yes")

Submission status: Accepted

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):
    ret = YES
    ##for i in range(A - 1, C - 1):
    ##    if S[i:i + 2] == '##':
    ##        ret = NO
    ##        print(ret)
    ##        return
    ##for i in range(B - 1, D - 1):
    ##    if S[i:i + 2] == '##':
    ##        ret = NO
    ##        print(ret)
    ##        return
    ##if D < C:
    ##    ret = NO
    ##    for i in range(B - 2, D - 1):
    ##        if S[i:i + 3] == '...':
    ##            ret = YES
    ##            break

    if '##' in S[A - 1:C] or '##' in S[B - 1:D]:
        ret = NO
    else:
        if D < C:
            #if S[B - 2:B] == '..' or S[B - 1:B + 1] == '..':
            if '...' not in S[B - 2:D + 1]:
                ret = NO
    print(ret)
    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

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):
    ret = YES
    ##for i in range(A - 1, C - 1):
    ##    if S[i:i + 2] == '##':
    ##        ret = NO
    ##        print(ret)
    ##        return
    ##for i in range(B - 1, D - 1):
    ##    if S[i:i + 2] == '##':
    ##        ret = NO
    ##        print(ret)
    ##        return
    ##if D < C:
    ##    ret = NO
    ##    for i in range(B - 2, D - 1):
    ##        if S[i:i + 3] == '...':
    ##            ret = YES
    ##            break

    if '##' in S[A - 1:C] or '##' in S[B - 1:D]:
        ret = NO
    else:
        if D < C:
            #if S[B - 2:B] == '..' or S[B - 1:B + 1] == '..':
            if not '...' in S[B - 2:D + 1]:
                ret = NO
    print(ret)
    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
inputa = list(map(int, input().split()))
inputb = list(input())
#double mountain
mountain = 0
for i in range(min(inputa[1], inputa[2]) - 1, max(inputa[3], inputa[4])):
  if inputb[i] == "#":
    if mountain == 1:
      mountain = 2
      break
    mountain = 1
  else:
    mountain = 0

if mountain == 2:
  print("No")
  exit()
    
#need oikoshi
oikoshi = 0
if inputa[3] > inputa[4]:
  oikoshi = 1

#triple step
triplestep = 0
for i in range(inputa[2] - 1, inputa[4]):
  if oikoshi == 0:
    break
  if inputb[i - 1] == ".":
    if inputb[i] == ".":
      if inputb[i + 1] == ".":
        triplestep = 1
        break

if oikoshi == 0:
  print("Yes")
else:
  if triplestep == 1:
    print("Yes")
  else:
    print("No")

Submission status: Accepted

Solution code:
#これが一番できたやつ

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

if D > C:
    if '##' in S[B:D] or '##' in S[A:C]:
        print('No')
    else:
        print('Yes')
elif C > D:
    if '...' in S[B - 2: D + 1] and '##' not in S[A: C]:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

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

if "##" in S[a:max(c, d)]:
    print("No")
elif c < d:
    print("Yes")
else:
    print("Yes" if "..." in S[b - 2:d + 1] else "No")

Submission status: Accepted

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]
last = ""
for i in range(b, d):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
last = ""
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 + 1):
        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: Accepted

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)+1]:
    ans = False
else:
    if d < c:
        ans = False
        if '...' in s[b-1:d+2]:
            ans = True
        
 
if ans is True:
    print ('Yes')
else:
    print ('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jun  2 22:01:55 2019

@author: hisaki
"""

import sys
N, A, B, C, D = map(int, input().split())
S = input()
A_start = A -1
B_start = B -1
A_goal = C -1
B_goal = D -1

A_pos = A_start
B_pos = B_start

flag = True
for i in range(A_pos, A_goal):
    if S[i] == '#':
        if S[i+1] == '#':
            flag = False

for i in range(B_pos, B_goal):
    if S[i] == '#':
        if S[i+1] == '#':
            flag = False
            
if flag == False:
    print ("No")
    sys.exit()
  


if A_goal < B_goal:
    print ("Yes")
    sys.exit()


if B_goal < A_goal :
    for i in range(B_pos , B_goal+1):
        if (S[i-1] == '.' or i-1 == A_pos) and (S[i]== '.') and (S[i+1] == '.'):
            print ("Yes")
            sys.exit()

            
print ("No")

Submission status: Accepted

Solution code:
# 2019/06/02
# AtCoder Grand Contest 034 - A

# For the answer:
# 1-1. Search min(ac) and max(abcd)
# 1-2. Search ## between min and max
# 2. Case:B<C, Left of B is . and (. or C), or exist .. -> Yes

# Def 1 : True is "Case No"
def searchRock(in_l, in_r, in_str, in_tg):
    rcflg = False
    for i in range(in_l - 1, in_r - 1): # Change -2 -> -1
        if in_str[i] == in_tg and in_str[i+1] == in_tg:
            rcflg = True
            break
    return rcflg

def searchPlain(in_l, in_r, in_str, in_tg):
    rcflg = False
    for i in range(in_l - 1, in_r - 1): # Change -2 -> -1
        if in_str[i] == in_tg and in_str[i+1] == in_tg and in_str[i+2] == in_tg:
            rcflg = True
            break
    return rcflg

# Input
n, a, b, c, d = map(int, input().split())
s = input()
ans = ""

# 1. Search ##
if c < b:
    # Search between a and c, b and d
    rflg = searchRock(a, c+1, s, "#")
    if rflg == True:
        ans = "No"
    else:
        rflg = searchRock(b, d+1, s, "#")
        if rflg == True:
            ans = "No"

else:
    # Search between a and max(c, d)
    rflg = searchRock(a, max(c, d)+1, s, "#")
    if rflg == True:
        ans = "No"
    
# 2. Check around b
if ans != "No":
    if (b < c and d < c):
        # Case: B < D < C 
        pflg = searchPlain(b-1, d, s, ".")
        if pflg == False:
            ans = "No"
#            if s[b-2] == "." and s[b] == ".":
#                ans = "Yes"
#            else:
#                ans = "No"
        else:
            ans = "Yes"
    else:
        ans = "Yes"

# Output
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a, b, c, d = map(int, input().split())
s = list(str(input()))
a, b, c, d = a-1, b-1, c-1, d-1
check = 1
if c < d:
  for i in range(a,c):
    if s[i] == s[i+1] == "#":
      check = 0
      break
  if check:
    for i in range(b,d):
      if s[i] == s[i+1] == "#":
        check = 0
        break

else:
  for i in range(a,c):
    if s[i] == s[i+1] == "#":
      check = 0
      break
  if check:
    check = 0
    for i in range(b, d+1):
      if s[i-1] == s[i] == s[i+1] == ".":
        check = 1
        break


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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[43]:


N, A, B, C, D = map(int, input().split())
S = input()
"""
7 1 3 7 6
.#..#..
"""


# In[55]:


if '##' in S[A-1:C] or '##' in S[B-1:D]:
    print('No')
else:# A~C B~D間に##は無い
    if C<D: # ACBD or ABCD
        print('Yes')
    else: # ABDC
        if '...' in S[B-2:D+1]:
            print('Yes')
        else:
            print('No')

"""
if C<D: # C < D のとき、A~C、B~Dに#が2連続じゃなければYes
    shc = 0
    for s in S[A-1:C]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
        if s == '.':
            shc = 0
    shc = 0
    for s in S[B-1:D]:
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
        if s == '.':
            shc = 0
elif C>D: # C > Dのとき、順番入れ替えが必要, dotが3個以上並べば、入れ替えられる
    #print(1)
    shc = 0
    dc = 0
    mdc = 0
    for i, s in enumerate(S[A-1:C]): # A~Cで　#が二個以上あればアウト
        if shc > 1:
            ans = 'No'
            break
        if s == '#':
            shc += 1
            if dc>0:
                mdc = max(dc, mdc)
                dc = 0
        if s == '.':
            dc += 1
            shc = 0
        if i >= C-A:
            mdc = max(dc, mdc)
    if mdc >= 3:
        #print(2)
        pass
    elif mdc < 3: # A~Cに dotが3個以上並んでいないとき、
        #print(2)
        shc = 0
        for i, s in enumerate(S[0:A:-1]):
            if shc >1:
                l = A-i+1
                break
            if s == '#':
                shc += 1
            if s == '.':
                shc = 0
            if i >= A-1 and shc > 1:
                l = A-i+2
        else:
            l = 0
            
        shc = 0
        for i, s in enumerate(S[C:]):
            if shc >1:
                r = C+i-2
                break
            if s == '#':
                shc += 1
            if s == '.':
                shc = 0
            if i >= N-C-1 and shc > 1:
                r = C+i-2
        else:
            r = N
        
        #print(l, r)
        mdc = 0
        dc = 0
        for i, s in enumerate(S[l:r]):
            #print('{}: {}'.format(i, dc))
            if s == '#':
                if dc>0:
                    mdc = max(dc, mdc)
                    dc = 0
            if s == '.':
                dc += 1
            if i >= r-l-1:
                mdc = max(dc, mdc)
        if mdc < 3:
            ans = 'No'
print(ans)
"""


# In[ ]:

Submission status: Accepted

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]
last = ""
for i in range(b, d):
    if last == "#" and s[i] == "#":
        print("No")
        exit()
    last = s[i]
last = ""
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+1):
        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: Accepted

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

s_cnt = 0
max_s_cnt = 0
pre_s = ''

goal = max(C, D)

if C < B:
  for i in range(A-1, C):
    if pre_s == "#":
      if S[i] == "#":
        print("No")
        exit()
    pre_s = S[i]
  for i in range(B-1, D):
    if pre_s == "#":
      if S[i] == "#":
        print("No")
        exit()
    pre_s = S[i]
  print("Yes")
  exit()

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N, A, B, C, D = map(int, input().split())
    S = str(input())

    # print(S[A:D:])
    # print(S[A:D:].count("##"))
    # print(S[A:D:].count("#.#"))
    # print(S[A:D:].count("#..#"))

    answer = "-1"

    if C < D:
       if S[A:D:].count("##") >= 1:
           answer = "No"
       else:
           answer = "Yes"
    else:
       if S[B-2:D+1:].count("...") >= 1:
           answer = "Yes"
       else:
           answer = "No"

    print(answer)

Submission status: Accepted

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

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

    def main(self):
        result = False

        # C < D のとき
        if self.C < self.D:
            # クリアできるか確かめる
            result = self.__canClear(self.A, self.C) and self.__canClear(self.B, self.D)

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

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

    def __canClear(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):
        isTriple = False
        objectCount = 0
        severalCount = 0

        # Bについて検証
        if self.S[self.B - 2] == "." and self.S[self.B] == ".":
            return True

        if self.S[self.B] == "." and self.S[self.B + 1] == ".":
            return True

        # Dについて検証
        if self.S[self.D - 2] == "." and self.S[self.D] == ".":
            return True

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

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

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

        return isTriple


kenkenRace = KenkenRace()
kenkenRace.main()

Submission status: Accepted

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] == '.' and a != C:
        S[a] = '#'; S[a-1] = '.'
        return dfs(a+1, b)
    if S[a+1] == '.' and a != C:
        S[a+1] = '#'; S[a-1] = '.'
        return dfs(a+2, b)
    if S[b] == '.' and b != D:
        S[b] = '#'; S[b-1] = '.'
        return dfs(a, b+1)
    if S[b+1] == '.' and b != D:
        S[b+1] = '#'; S[b-1] = '.'
        return dfs(a, b+2)
    return 'No'
print(dfs())

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split());s=input();print('YNeos'['##'in s[a:c]or'##'in s[b:d]or c>d and'...'not in s[b-2:d+1]::2])

Submission status: Accepted

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

S = input()

if '##' in S[A-1:C] or '##' in S[B-1:D]:
    print('No')
elif D < C and not '...' in S[B-2:D+1]:
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

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

if '##' in S[A:max(C, D)]:
    print('No')
elif C<D:
    print('Yes')
else:
    if '...' in S[B-2:D+1]:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, a, b, c, d = map(lambda x: int(x) - 1, input().split())
s = input()

if d < c:
    f = False
    for i in range(n)[b:d + 1]:
        if '...' in s[i - 1:i + 2]:
            f = True
    if not f:
        print('No')
        exit()
    a, b = b, a
    c, d = d, c
print(['Yes', 'No']['##' in s[a:d + 1]])

Submission status: Accepted

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

if c>d: #ABDC
  if s[b-2:d+1].find("...")!=-1 and s[a-1:c].find("##")==-1:
    print("Yes")
  else:
    print("No")
elif s[a-1:c].find("##")==-1 and s[b-1:d].find("##")==-1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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-2:d+1].count('...')>0:
        flg=False
    if flg:
        print('No')
        exit()

if s[a:c].count('##')>0:
    print('No')
    exit()

print('Yes')

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split());s=input();print('YNeos'[('##'in s[a-1:c])or('##'in s[b-1:d])or(c>d and'...'not in s[b-2:d+1])::2])

Submission status: Accepted

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

if B < C and C < D :
    if "##" in S[A-1:D-1] :
        print("No")
    else:
        print("Yes")
if B < D and D < C:
    if "##" in S[A-1:C-1] :
        print("No")
    else:
        # Bの一つ手前からDの次までに...があればよい
        if "..." in S[B-2:D+1]:
            print("Yes")
        else:
            print("No")

if C < B and B < D:
    # A..Cに2つ連続#がなければよい
    # B..Dに2つ連続#がなければよい
    if "##" in S[A-1:C-1] or "##" in S[B-1:D-1] :
        print("No")
    else:
        print("Yes")

Submission status: Accepted

Solution code:
# すぬけ君がふぬけ君を追い越す必要があるならば
# 追い越すためのスペースが必要になる

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

    if S[A-1:C].count('##'):
        return 0

    if S[B-1:D].count('##'):
        return 0

    if D < C and not(S[B-2:D+1].count('...')):
        return 0

    return 1

print(['No','Yes'][main()])

Submission status: Accepted

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-1,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: Accepted

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-2:D+1]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
    return

main()

Submission status: Accepted

Solution code:
N,A,B,C,D = map(int,input().split())
s = input()
#ans = 'Yes'
if C<D:
    ans = 'Yes' 
else:
    if s[B-2:D+1].count('...')>0:
        ans = 'Yes'
#    elif D-B == 1:
#        ans = 'No'
#    elif D-B == 2: 
#        if s[B-2:D].count('#')!=0:
#            ans = 'No'
    else:
        ans = 'No'
if s[A:C-1].count('##')!=0 or s[B:D-1].count('##')!=0:
    ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
N, A, B, C, D = map(int, input().split(' '))
S = input()
blocks = [i+1 for i, s in enumerate([s for s in S]) if s == '#']

if '##' in S[A-1:C] or '##' in S[B-1:D]:
    print('No')
elif C < D:
    if S[C-1] == '.' and S[D-1] == '.':
        print('Yes')
    else:
        print('No')
else:
    if '...' in S[max(0, B - 2):D+1]:
        print('Yes')
    else:
        print('No')