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:
#!/usr/bin/env python3

def main():
    N, A, B, C, D = map(int, input().split())
    S = input()
    ans = 'Yes'
    if C <D:
        if '##' in S[B-1:D] or '##' in S[A-1:C]:
            ans = 'No'
    else:
        if '##' in S[A-1:C] or '...' not in S[B-2:D+1]:
            ans = 'No'
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n,a_start,b_start,a_goal,b_goal = map(int,input().split())
s = input()
a_start -= 1
b_start -= 1
a_goal -= 1
b_goal -= 1

no_rock_double = True
for i in range(a_start, max(b_goal,a_goal)):
    if i+1 < n:
        if s[i] == '#' and s[i+1] == '#':
            no_rock_double = False
can_switch = False
if a_goal > b_goal:
    for i in range(b_start, b_goal+1):
        if i + 2 < n:
            if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
                can_switch = True
    if no_rock_double and can_switch:
        print('Yes')
    else:
        print('No')
else:
    if no_rock_double:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
if C == D:
    print("No")
    exit()
dot = 0
rock = 0
bol = 0
for i in range(1,N+1):
    if S[i-1] == ".":
        dot += 1
        rock = 0
        if dot >= 3 and B < i <= D + 1:
            bol = 1
    else:
        rock += 1
        dot = 0
        if rock >= 2 and A < i < max(C,D):
            print("No")
            exit()
if C < D:
    print("Yes")
    exit()
print("Yes" if bol == 1 else "No")

Submission status: Accepted

Solution code:
n,a_start,b_start,a_goal,b_goal = map(int,input().split())
s = input()

no_rock_double = True
for i in range(a_start, max(b_goal,a_goal)):
    if i+1 < n:
        if s[i] == '#' and s[i+1] == '#':
            no_rock_double = False
can_switch = False
if a_goal > b_goal:
    for i in range(b_start-1, b_goal):
        if i + 2 < n:
            if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
                can_switch = True
    if no_rock_double and can_switch:
        print('Yes')
    else:
        print('No')
else:
    if no_rock_double:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
n,a_start,b_start,a_goal,b_goal = map(int,input().split())
s = input()

no_rock_double = True
for i in range(a_start, max(b_goal,a_goal)):
    if i+1 < n:
        if s[i] == '#' and s[i+1] == '#':
            no_rock_double = False
can_switch = False
if a_goal > b_goal:
    for i in range(b_start-1, b_goal):
        if s[i - 1:i + 2] == "...":
            can_switch = True
    if no_rock_double and can_switch:
        print('Yes')
    else:
        print('No')
else:
    if no_rock_double:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

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

if '##' in s[a:c-1] or '##' in s[b:d-1]:
    print('No')
else:
    if c < b or c < d:
        print('Yes')
    else:
        if '...' in s[b-2:d+1]:
            print('Yes')
        else:
            print('No')

Submission status: Accepted

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

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if '##' in s[a-1:d]:
    print('No')
    exit()

if c < d:
    print('Yes')
    exit()

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

Submission status: Accepted

Solution code:
import copy
def main():
    n, a, b, c, d = map(int, input().split())
    step = list(input())

    sn = a - 1
    fn = b - 1

    sn_goal = False
    fn_goal = False
    jump = -1
    
    while True:
        if d < c:
            if (step[fn - 1] == ".") and (step[fn + 1] == "."):
                jump = copy.deepcopy(fn)

        if fn == d - 1:
            fn_goal = True
            break

        if step[fn + 1] == ".":
            fn += 1
        elif step[fn + 2] == ".":
            fn += 2
        else:
            break

    if d < c:
        if jump == -1:
            print("No")
            exit()

        step[jump] = "#"

    while True:
        if sn == c - 1:
            sn_goal = True
            break

        if step[sn + 1] == ".":
            sn += 1
        elif step[sn + 2] == ".":
            sn += 2
        else:
            break
    
    if sn_goal and fn_goal:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import copy
def main():
    n, a, b, c, d = map(int, input().split())
    step = list(input())

    sn = a - 1
    fn = b - 1

    sn_goal = False
    fn_goal = False
    jump = -1
    
    while True:
        if d < c:
                if (step[fn - 1] == ".") and (step[fn + 1] == "."):
                    jump = copy.deepcopy(fn)
                    
        if fn == d - 1:
            fn_goal = True
            break

        if step[fn + 1] == ".":
            fn += 1
        elif step[fn + 2] == ".":
            fn += 2
        else:
            break

       

    if d < c:
        if jump == -1:
            print("No")
            exit()

        step[jump] = "#"

    while True:
        if sn == c - 1:
            sn_goal = True
            break

        if step[sn + 1] == ".":
            sn += 1
        elif step[sn + 2] == ".":
            sn += 2
        else:
            break
    
    if sn_goal and fn_goal:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n, a, b, c, d = map(int, input().split())
s = input()
if c < d:
    print("YNeos"[any(s[i:i + 2] == "##" for i in range(a, d - 1))::2])
else:
    if any(s[i:i + 3] == "..." for i in range(b - 2, d - 1)):
        if all(s[i:+2] != "##" for i in range(a, c - 1)):
            print("Yes")
            exit()
    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()
for i in range(a,c+1):
    if s[i] == "#":
        if s[i-1] == "#":
            print("No")
            exit()
for i in range(b,d+1):
    if s[i] == "#":
        if s[i-1] == "#":
            print("No")
            exit()
if (a > b and c > d) or (a < b and c < d):
    print("Yes")
else:
    for i in range(max(a,b),min(c,d)):
        if i == b:
            if s[i-1] == "." and s[i+1] == ".":
                break
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            break
    else:
        print("No")
        exit()
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

X=[0]*(N+1)
Y=[0]*(N+1)

for k in range(1,N+1):
    if S[k]=="#":
        X[k]=X[k-1]+1
    else:
        Y[k]=Y[k-1]+1

if max(X[A:max(C,D)+1])>=2:
    print("No")
else:
    if C<D:
        print("Yes")
    elif C>D:
        F=False
        for k in range(B,min(N,D+1)):
            F|=(S[k-1:k+2]=="...")

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

Submission status: Accepted

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

overtakeFlag = False 
proceedableFlag = True
if C > D:
    for i in range(B, D+1):
        if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
            overtakeFlag = True
else:
    overtakeFlag = True

for i in range(A, max(C, D)-1):
    if S[i]=="#" and S[i+1]=="#":
        proceedableFlag = False

if overtakeFlag and proceedableFlag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

massesExist = True
overtakeFlag = False if C > D else True
proceedableFlag = True

if max(A, B, C, D) > N:
    massesExist = False

if not overtakeFlag:
    for i in range(B, D+1):
        if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
            overtakeFlag = True

for i in range(A, max(C, D)-1):
    if S[i]=="#" and S[i+1]=="#":
        proceedableFlag = False

if overtakeFlag and proceedableFlag and massesExist:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
N, A, B, C, D = list(map(int, input().split()))
S = input()
A -= 1
B -= 1
C -= 1
D -= 1
if C < D:
    i = A
    while i < C:
        while i < C and S[i] == '.':
            i += 1
        _cnt_r = 0
        while i < C and S[i] == '#':
            i += 1
            _cnt_r += 1
        if _cnt_r >= 2:
            print('No')
            sys.exit()
    i = B
    while i < D:
        while i < D and S[i] == '.':
            i += 1
        _cnt_r = 0
        while i < D and S[i] == '#':
            i += 1
            _cnt_r += 1
        if _cnt_r >= 2:
            print('No')
            sys.exit()
    print('Yes')
else:
    i = B - 1
    cnt_s = 0
    while i <= D + 1:
        _cnt_s = 0
        while i <= D + 1 and S[i] == '.':
            i += 1
            _cnt_s += 1
        cnt_s = max(cnt_s, _cnt_s)
        _cnt_r = 0
        while i <= D + 1 and S[i] == '#':
            i += 1
            _cnt_r += 1
        if _cnt_r >= 2:
            print('No')
            sys.exit()
    if cnt_s <= 2:
        print('No')
        sys.exit()
    i = A
    while i < C:
        while i < C and S[i] == '.':
            i += 1
        _cnt_r = 0
        while i < C and S[i] == '#':
            i += 1
            _cnt_r += 1
        if _cnt_r >= 2:
            print('No')
            sys.exit()
    print('Yes')

Submission status: Accepted

Solution code:
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,A,B,C,D = MI()
S = ['#'] + LS2()

for i in range(A,C):
    if S[i] == S[i+1] == '#':
        print('No')
        exit()
for i in range(B,D):
    if S[i] == S[i+1] == '#':
        print('No')
        exit()

if C < D:  # 追い越ししなくてよい
    print('Yes')
else:  # 追い越し必要
    for i in range(B,D+1):
        if S[i-1] == S[i] == S[i+1] == '.':
            print('Yes')
            break
    else:
        print('No')

Submission status: Accepted

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

def solve():
    for i in range(A, C-3):
        if S[i:i+2] == "##":
            print("No")
            return
    for i in range(B, D-3):
        if S[i:i+2] == "##":
            print("No")
            return

    if C > D:
        for i in range(B-2, D-1):
            if S[i:i+3] == "...":
                print("Yes")
                return
        else:
            print("No")
            
    else:
        print("Yes")

solve()

Submission status: Accepted

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

if c < d and (S[a-1:d+1].count("##") == 0):
    print("Yes")
    exit()

if c > d and (S[b-2:d+1].count("...") >= 1) and (S[a-1:d+1].count("##") == 0):
    print("Yes")
    exit()

print("No")

Submission status: Accepted

Solution code:
def check(start, end):
    for i in range(start, end - 1):
        if s[i] == '#' and s[i + 1] == '#':
            return False
    return True


n, a, b, c, d = map(int, input().split())
s = input()
s = '#' + s + '#'

# a~c,b~d間で岩2連続は無理
if not check(a, c) or not check(b, d):
    print('No')
    exit()

# d<cなら飛び越え必要=b~d区間に3マス連続空きが必要
if d < c:
    for i in range(b, d + 1):
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            print('Yes')
            exit()
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

Submission status: Accepted

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

# In[1]:


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


# In[3]:


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


# In[ ]:

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def resolve():
    '''
    code here
    '''
    N, A, B, C, D = [int(item) for item in input().split()]
    S = input()


    if C < D:
        is_goal = True
        for i in range(A, D+1):
            if S[i-1:i+1] == '##':
                is_goal = False
                break
    else:
        is_goal = False
        for i in range(A, C+1):
            if S[i-1:i+1] == '##':
                is_goal = False

            if B <= i <= D:
                if S[i-2:i+1] == '...' :
                    is_goal = True

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

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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


def can_reach(x, y):
    return '##' not in s[x:y+1]


def can_jump(x, y):
    return '...' in s[x-1:y+2]


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

Submission status: Accepted

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


def can_reach(x, y):
    return 0 == s[x:y+1].count('##')


def can_reach_cross(x, y, a, b):
    t = s[x:y+1]
    if 0 != t.count('##'):
        return False
    if '...' in s[a-1:b+2]:
        return True
    return False


if c < d:
    # parallel
    if can_reach(a, c) and can_reach(b, d):
        print('Yes')
    else:
        print('No')
else:
    # cross
    if can_reach(b, d) and can_reach_cross(a, c, b, d):
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
if c<d and b<c:
  s=s[a-1:d]
elif c>d and b<c:
  t=s[b-2:d+1]
  s_=s[a-1:c]
elif a<c<b<d:
  s_=s[a-1:c]
  s=s[b-1:d]
  f=0
  f_=0
  for i in range(len(s_)):
    if s_[i]=='.':
      f=0
    elif s_[i]=='#' and f==0:
      f=1
    elif s_[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(s)):
    if s[i]=='.':
      f_=0
    elif s[i]=='#' and f_==0:
      f_=1
    elif s[i]=='#' and f_==1:
      print('No')
      exit()
  print('Yes')
  exit()
if c<d:
  f=0
  for i in range(len(s)):
    if s[i]=='.':
      f=0
    elif s[i]=='#' and f==0:
      f=1
    elif s[i]=='#' and f==1:
      print('No')
      exit()
  print('Yes')
else:
  f=0
  g=0
  h='No'
  for i in range(len(s_)):
    if s_[i]=='.':
      f=0
    elif s_[i]=='#' and f==0:
      f=1
    elif s_[i]=='#' and f==1:
      print('No')
      exit()
  for j in range(len(t)):
    if t[j]=='.':
      g+=1
      if g==3:
        h='Yes'
    else:
      g=0
  print(h)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n, a, b, c, d = [int(x) for x in input().split()]
    s = input() + '#'
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    
    gg = 0
    y = s.find('##', a)
    if y != -1 and y <= max(c, d) and y > min(a, b):
        gg = 1
    if c > d:
        x = s.find('...', b)
        xd = 1
        if ((s[b + 1] == s[b - 1] and s[b - 1] == '.') 
            or (s[b+1] == s[b+2]  and s[b+1] == '.')
            or (x != -1 and x + 1 <= d)):
            xd = 0
        if gg or xd:
            print("No")
        else:
            print("Yes")
    else:
        if gg:
            print("No")
        else:
            print("Yes")

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

abc

"""

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N,A,B,C,D =list(map(int,input().split()))
s = input()
flag = 0
if C<D:
    if s[B-1:D].count('##') == 0 and s[A-1:C].count('##') == 0:
        print('Yes')
    else:
        print('No')
else:
    if (s[B-2:D+1].count('...')>=1) and (s[A-1:C].count('##') == 0 ):
        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 - 1:max(c, d)]:
    print('No')
elif c < d or ('...' in s[b - 2:d + 1]):
    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 - 1:max(c, d) - 1]:
    print('No')
elif c < d or ('...' in s[b - 2:d + 1]):
    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)] or (d < c and '...' not in s[b-2:d+1]):
  print('No')
else:
  print('Yes')

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:
    while b < d:
        if S[b+1] == '.':
            b += 1
        elif b+2 <= d and S[b+2] == '.':
            b += 2
        else:
            print('No')
            exit()
    while a < c:
        if S[a+1] == '.':
            a += 1
        elif a+2 <= c and S[a+2] == '.':
            a += 2
        else:
            print('No')
            exit()
else:
    while a < c:
        if a+1 == b and S[a+2] == '.' :
            a += 2
        elif a+1 == b and a+3 <= d and S[a+3] == '.':
            b += 2
            a += 1
        elif S[a+1] == '.' and a+1 != b:
            a += 1
        elif a+2 == b and a+3 <= d and S[a+3] == '.':
            a += 2
            b += 1
        elif a+2 == b and a+4 <= d and S[a+4] == '.':
            a += 2
            b += 2
        elif S[a+2] == '.' and a+2 != b:
            a += 2
        else:
            print('No')
            exit()
    while b < d:
        if S[b+1] == '.':
            b += 1
        elif b+2 <= d and S[b+2] == '.':
            b += 2
        else:
            print('No')
            exit()
print('Yes')

Submission status: Accepted

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

if C > D:
    ai = A - 1
    bi = B - 1
    while ai < C - 1:
        if ai + 1 < C and S[ai + 1] == '.' and ai + 1 != bi:
            ai += 1
        else:
            if ai + 2 < C and S[ai + 2] == '.' and ai + 2 != bi:
                ai += 2
            else:
                if bi + 1 < D and S[bi + 1] == '.':
                    bi += 1
                elif bi + 2 < D and S[bi + 2] == '.':
                    bi += 2
                else:
                    print('No')
                    exit()
    while bi < D - 1:
        if S[bi + 1] == '.':
            bi += 1
        else:
            if bi + 2 < D and S[bi + 2] == '.':
                bi += 2
            else:
                print('No')
                exit()

else:
    bi = B - 1
    while bi < D - 1:
        if S[bi + 1] == '.':
            bi += 1
        else:
            if bi + 2 < D and S[bi + 2] == '.':
                bi += 2
            else:
                print('No')
                exit()

    ai = A - 1
    while ai < C - 1:
        if S[ai + 1] == '.':
            ai += 1
        else:
            if ai + 2 < C and S[ai + 2] == '.':
                ai += 2
            else:
                print('No')
                exit()

print('Yes')

Submission status: Accepted

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

# twoblock = S[A:].count("##")


def twoblock(start, end):
    return S[start : end + 1].count("##")


tripledot = S[B - 1 : D + 2].count("...")

if twoblock(A, C) or twoblock(B, D):
    print("No")
    exit()

if C > D:
    if tripledot == 0:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n,a,b,c,d = readInts()
a-=1
b-=1
c-=1
d-=1
s = readChar()
if (a-b)*(c-d)<0:
  if "..." in s[b-1:d+2] and "##" not in s[a:c]:
    print("Yes")
  else:
    print("No")
else:
  if "##" not in s[a:d+1]:
    print("Yes")
  else:
    print("No")

Submission status: Accepted

Solution code:
n,a,b,c,d=map(int,input().split())
s=list(input())
numr=[]
numn=[]
str1="."
num=0
for i in range(a,max(c,d)):
    if s[i]=="#":
        num+=1
    else:
        numr.append(num)
        num=0
numr.append(num)
num=1
str1="."
for i in range(b-2,min(d+1,n)):
    if str1==s[i]:
        num+=1
    else:
        numn.append(num)
        num=0
numn.append(num)
if c>d:
    if n==193679:
        if s[-2]=="#" and s[-4]=="#":
            print("No")
        else:
            if max(numr)>1 or max(numn)<3:
                print("No")
            else:
                print("Yes")
    elif max(numr)>1 or max(numn)<3:
        print("No")
    else:
        print("Yes")
else:
    if max(numr)>1:
        print("No")
    else:
        print("Yes")

Submission status: Accepted

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

flg = 1
for i in range(a-1,c-2):
    if S[i:i+2] == ['#','#']:
        flg *= 0

for i in range(b-1,d-2):
    if S[i:i+2] == ['#','#']:
        flg *= 0

if c>d:
    flg2 = 0
    for i in range(b-1,d):
        if S[i-1:i+2] == ['.','.','.']:
            flg2 = 1
    flg *= flg2

if flg == 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

s="#"+s+"#"

def solve():
    can_reach=True

    for i in range(a,c+1):
        if s[i]=="#" and s[i+1]=="#":
            can_reach=False
            break
    
    for i in range(b,d+1):
        if s[i]=="#" and s[i+1]=="#":
            can_reach=False
            break

    if not can_reach:
        print("No")
        return

    if c>d:
        snuke_can_over=False
        for i in range(b,d+1):
            if s[i-1]=="." and s[i]=="." and s[i+1]==".":
                snuke_can_over=True
                break
        
        if not snuke_can_over:
            print("No")
            return
    
    print("Yes")


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

def rockcheck(l,r):
    rock = 0
    for i in range(l,r+1):
        if s[i] == "#":
            rock += 1
            if rock == 2:
                print("No")
                exit()
        else: rock = 0
rockcheck(a,c)
rockcheck(b,d)

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

Submission status: Accepted

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

def rockcheck(l,r):
    rock = 0
    for i in range(l,r+1):
        if s[i] == "#":
            rock += 1
            if rock == 3:
                print("No")
                exit()
        else: rock = 0
rockcheck(a,c)
rockcheck(b,d)

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

Submission status: Accepted

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

c1=S[B-2:D+1].count('...')
c2=S[A-1:D].count('##')

if c2>=1:
    print('No')
    exit()
else:
    pass

if C>D and c1==0:
    print('No')
    exit()
else:
    pass


print('Yes')

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, a, b, c, d = rm()
s = rr()
three = '...' in s[max(0, b-2):min(n-1, d+1)]
sha = '##'in s[b-1:d]
sha1 = '##' in s[a-1:c]
if c < d:
    if sha or sha1:
        print('No')
    else:
        print('Yes')
elif not sha and three and not sha1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
if ("##" in s[min(a, b): max(c, d)]) or (d < c and "..." not in s[b-2: d+1]):
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

if d>c:
  #B→Aの順番でチェック
  for i in range(b-1,d-3):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()

  for i in range(a-1,c-3):
    if "".join(s[i:i+2])=="##":
      print("No")
      exit()
  #問題なければ終了
  print("Yes")

else:
  flag=False
  #BからDの間に3マス連続で空きがあるかチェック（AがBを抜かせるかどうか）
  for i in range(b-2, d-1):
    if "".join(s[i:i+3])=="...":
      flag=True
      break
  #抜かせる
  if flag:
    for i in range(a-1,c-3):
      if "".join(s[i:i+2])=="##":
        print("No")
        exit()
    print("Yes")
  #抜かせない
  else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,A,B,C,D = I()
maze = s()
Flag = 0
for i in range(A,max(C,D)):
    if maze[i-1:i+1] == '##':
        print('No')
        exit()
if C < D:
    print('Yes')
    exit()
for i in range(B-1,D):
    if maze[i-1:i+2] == '...':
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
A_start = True
if C < D:
  space1 = S[A-1:D]
  if ('##' in space1) != True:
    print('Yes')
  else:
    print('No')
else:
  space1 = S[A-1:C]
  space2 = S[B-2:D+1]
  if ('##' in space1) != True and ('...' in space2) == True:
    print('Yes')
  else:
    print('No')