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:
n,a,b,c,d=list(map(int,input().split()))
s=input()

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if c<d:
    for i in range(b+1,d):
        if s[i]=='#' and s[i+1]=='#':
            print('No')
            exit(0)
    
    for i in range(a+1,c):
        if s[i]=='#' and s[i+1]=='#':
            print('No')
            exit(0)
    print('Yes')
else:
    for i in range(b,d):
        if s[i]=='#' or i+1>=n:
            continue

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

Submission status: Wrong Answer

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

if c<d:
    for i in range(b+1,d):
        if s[i]=='#' and s[i+1]=='#':
            print('No')
            exit(0)
    
    for i in range(a+1,c):
        if s[i]=='#' and s[i+1]=='#':
            print('No')
            exit(0)
    print('Yes')
else:
    for i in range(b,d+1):
        if s[i]=='#' or i+1>=n:
            continue

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

Submission status: Wrong Answer

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

if c<d:
    for i in range(b+1,d):
        if s[i]=='#' and s[i+1]=='#':
            print('No')
            exit(0)
    
    for i in range(a+1,c):
        if s[i]=='#' and s[i+1]=='#':
            print('No')
            exit(0)
    print('Yes')
else:
    for i in range(b,d):
        if s[i]=='#':
            continue

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

Submission status: Wrong Answer

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

if c<d:
    for i in range(b+1,d):
        if s[i]=='#' and s[i+1]=='#':
            print('No')
            exit(0)
    
    for i in range(a+1,c):
        if s[i]=='#' and s[i+1]=='#':
            print('No')
            exit(0)
    print('Yes')
else:
    for i in range(b,d):
        if s[i]=='#':
            continue

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,A,B,C,D =MI()
    S=input()
    A-=1
    B-=1
    C-=1
    D-=1
    
    flag=1
    if "##" in S[A:C+1]:
        flag=0
    if "##" in S[B:D+1]:
        flag=0
        
    if C>D:
        if "..." in S[B-1:D+1]:
            pass
        else:
            flag=0
            
    if flag:
        print("Yes")
    else:
        print("No")
        

main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,A,B,C,D =MI()
    S=input()
    A-=1
    B-=1
    C-=1
    D-=1
    
    flag=1
    if "##" in S[A:C+1]:
        flag=0
    if "##" in S[B:D+1]:
        flag=0
        
    if C>D:
        if "..." in S[B:D+1]:
            pass
        else:
            flag=0
            
    if flag:
        print("Yes")
    else:
        print("No")
        

main()

Submission status: Wrong Answer

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

l = b
r = min(c,d)
li = s[l:r-1]

flag,OK = True,False
for i in range(len(li)-1):
    if li[i]== "#" and li[i+1] == "#":
        flag = False
        
for i in range(len(li)-2):
    if li[i]== "." and li[i+1] == "." and li[i+2] == ".":
        OK = True

if c < d and flag:
    print("Yes")
    exit()
if d < c and OK and flag:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

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

l = b
r = min(c,d)
li = s[l:r-1]

flag,OK = True,False
for i in range(len(li)-1):
    if li[i]== "#" and li[i+1] == "#":
        flag = False
        
for i in range(len(li)-2):
    if li[i]== "." and li[i+1] == "." and li[i+2] == ".":
        OK = True

if c < d and flag:
    print("Yes")
    exit()
if d < c and OK:
    print("Yes")
    exit()
print("No")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

s = list(input())

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

Submission status: Wrong Answer

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

s = list(input())

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

Submission status: Wrong Answer

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

s = list(input())

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

Submission status: Wrong Answer

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

s = list(input())

a -= 1
b -= 1
c -= 1
d -= 1
for i in range(a,c-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
for i in range(b,d-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()

s[d] = "#"
check = True

for i in range(a,c-1):
    if s[i] == s[i+1] == "#":
        check = False
        break
if check:
    print("Yes")
    exit()
s[d] = "."
s[b] = "#"
check = True
for i in range(a,c-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
s[b] = "."
s[c] = "#"
for i in range(b,d-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

s = list(input())

a -= 1
b -= 1
c -= 1
d -= 1
for i in range(a,c-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
for i in range(b,d-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
count = 0
ma = 0
for i in range(b+1,c):
    if s[i] == ".":
        count += 1
        ma = max(ma,count)
    else:
        count = 0
if ma >= 3:
    print("Yes")
    exit()

s[d] = "#"
check = True

for i in range(a,c-1):
    if s[i] == s[i+1] == "#":
        check = False
        break
if check:
    print("Yes")
    exit()
s[d] = "."
s[b] = "#"
check = True
for i in range(a,c-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
s[b] = "."
s[c] = "#"
for i in range(b,d-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

s = list(input())

a -= 1
b -= 1
c -= 1
d -= 1
for i in range(a,max(c,d)-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
count = 0
ma = 0
for i in range(b+1,c):
    if s[i] == ".":
        count += 1
        ma = max(ma,count)
    else:
        count = 0
if ma >= 3:
    print("Yes")
    exit()

s[d] = "#"
check = True

for i in range(a,c-1):
    if s[i] == s[i+1] == "#":
        check = False
        break
if check:
    print("Yes")
    exit()
s[d] = "."
s[b] = "#"
check = True
for i in range(a,c-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
s[b] = "."
s[c] = "#"
for i in range(b,d-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

s = list(input())

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

count = 0
ma = 0
for i in range(b+1,c):
    if s[i] == ".":
        count += 1
        ma = max(ma,count)
    else:
        count = 0
if ma >= 3:
    print("Yes")
    exit()

s[d] = "#"
check = True

for i in range(a,c-1):
    if s[i] == s[i+1] == "#":
        check = False
        break
if check:
    print("Yes")
    exit()
s[d] = "."
s[b] = "#"
check = True
for i in range(a,c-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
s[b] = "."
s[c] = "#"
for i in range(b,d-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
print("Yes")

Submission status: Wrong Answer

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

s = list(input())

a -= 1
b -= 1
c -= 1
d -= 1
for i in range(a,max(c,d)-1):
    if s[i] == s[i+1] == "#":
        print("No")
        exit()
count = 0
ma = 0
for i in range(b+1,c):
    if s[i] == ".":
        count += 1
        ma = max(ma,count)
    else:
        count = 0
if ma >= 3:
    print("Yes")
    exit()

s[d] = "#"
check = True

for i in range(a,c-1):
    if s[i] == s[i+1] == "#":
        check = False
        break
if check:
    print("Yes")
    exit()
s[d] = "."
s[b] = "#"
check = True
for i in range(a,c-1):
    if s[i] == s[i+1] == ".":
        print("No")
        exit()
s[b] = "."
s[c] = "#"

for i in range(b,d-1):
    if s[i] == s[i+1] == ".":
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if "##" in S:
    print("No")
elif D < C and ("..." not in S[B-2:]):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

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

if "##" in S:
    print("No")
elif D < C and ("..." not in S[B:]):
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(a,b,c,d,s):
  if '##' in s:
    return False
  if c < d:
    return True
  elif c > d:
    if "..." in s[b-1:d+2]:
      return True
    else:
      return False
  else:
    raise ValueError




def main():
  N,A,B,C,D = map(int,input().split())
  A -= 1
  B -= 1
  C -= 1
  D -= 1
  S = input()
  print("Yes" if solve(A,B,C,D,S) else "No")
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(a,b,c,d,s):
  if '##' in s:
    return False
  if c < d:
    return True
  elif c > d:
    if '...' in s[b-1:max(d+2,len(s))]:
      return True
    else:
      return False
  else:
    raise ValueError




def main():
  N,A,B,C,D = map(int,input().split())
  A -= 1
  B -= 1
  C -= 1
  D -= 1
  S = input()
  print("Yes" if solve(A,B,C,D,S) else "No")
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(a,b,c,d,s):
  if '##' in s:
    return False
  if c < d:
    return True
  elif c > d:
    if '...' in s[b+1:d]:
      return True
    else:
      return False
  else:
    raise ValueError




def main():
  N,A,B,C,D = map(int,input().split())
  A -= 1
  B -= 1
  C -= 1
  D -= 1
  S = input()
  print("Yes" if solve(A,B,C,D,S) else "No")
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(a,b,c,d,s):
  if '##' in s:
    return False
  if c < d:
    return True
  elif d < c:
    if '...' in s[b:d+1]:
      return True
    else:
      return False
  else:
    raise ValueError




def main():
  N,A,B,C,D = map(int,input().split())
  A -= 1
  B -= 1
  C -= 1
  D -= 1
  S = input()
  print("Yes" if solve(A,B,C,D,S) else "No")
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

# @njit
def solve(a,b,c,d,s):
  if '##' in s:
    return False
  if c < d:
    return True
  elif d < c:
    if '...' in s:
      return True
    else:
      return False
  else:
    raise ValueError




def main():
  N,A,B,C,D = map(int,input().split())
  A -= 1
  B -= 1
  C -= 1
  D -= 1
  S = input()
  print("Yes" if solve(A,B,C,D,S) else "No")
  return

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, A, B, C, D = LI()
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = SS()

    ## 移動経路に2連続以上の岩があったらダメ
    if '##' in S[A:C+1] or '##' in S[B:D+1]:
        print('No')
    else:
        ## ふぬけ君を先に移動させればいい
        if C < D:
            print('Yes')
        ## ふぬけ君を飛び越えられる瞬間が存在すればいい
        else:
            # 岩の間のどこかに3以上の隙間があること
            if '...' in S[B:D+1]:
                print('Yes')
            else:
                print('No')

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, A, B, C, D = LI()
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = SS()

    ## 移動経路に2連続以上の岩があったらダメ
    if '##' in S[A:C+1] or '##' in S[B:D+1]:
        print('No')
    else:
        ## ふぬけ君を先に移動させればいい
        if C < D:
            print('Yes')
        ## ふぬけ君を飛び越えられる瞬間が存在すればいい
        else:
            # 岩の間のどこかに3以上の隙間があること
            r = [i for i in range(B - 1, D + 2) if S[i] == '#']
            if S[B:D+1] == '.#.':
                print('No')
            elif len(r) <= 1 or [i for i in range(len(r) - 1) if r[i+1] - r[i] >= 4]:
                print('Yes')
            else:
                print('No')

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, A, B, C, D = LI()
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = SS()

    ## 移動経路に2連続以上の岩があったらダメ
    if '##' in S[A:C+1] or '##' in S[B:D+1]:
        print('No')
    else:
        ## ふぬけ君を先に移動させればいい
        if C < D:
            print('Yes')
        ## ふぬけ君を飛び越えられる瞬間が存在すればいい
        else:
            # 岩の間のどこかに3以上の隙間があること
            r = [i for i in range(B - 1, D + 2) if S[i] == '#']
            if len(r) <= 1 or [i for i in range(len(r) - 1) if r[i+1] - r[i] >= 4]:
                print('Yes')
            else:
                print('No')

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, A, B, C, D = LI()
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = SS()

    ## 移動経路に2連続以上の岩があったらダメ
    if '##' in S[A:C+1] or '##' in S[B:D+1]:
        print('No')
    else:
        ## ふぬけ君を先に移動させればいい
        if C < D:
            print('Yes')
        ## ふぬけ君を飛び越えられる瞬間が存在すればいい
        else:
            # 岩の間のどこかに3以上の隙間があること
            r = [i for i in range(B - 1, D + 2) if S[i] == '#']
            if not r or [i for i in range(len(r) - 1) if r[i+1] - r[i] >= 4]:
                print('Yes')
            else:
                print('No')

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, A, B, C, D = LI()
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    S = SS()

    ## 2連続以上の岩があったらダメ
    if '##' in S:
        print('No')
    else:
        ## ふぬけ君を先に移動させればいい
        if C < D:
            print('Yes')
        ## ふぬけ君を飛び越えられる瞬間が存在すればいい
        else:
            # 岩の間のどこかに3以上の隙間があること
            r = [i for i in range(B - 1, D + 2) if S[i] == '#']
            if not r or [i for i in range(len(r) - 1) if r[i+1] - r[i] >= 4]:
                print('Yes')
            else:
                print('No')

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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-1:D]:
            ans = 'No'
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int,input().split())
S = input()
if C == D:
    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 <= C+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: Wrong Answer

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] == '.' and s[i+1] == '.' and s[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: Wrong Answer

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-1):
        if i + 2 < n:
            if s[i] == '.' and s[i+1] == '.' and s[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: Wrong Answer

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 <= C:
            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: Wrong Answer

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 < 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-1):
        if i + 2 < n:
            if s[i] == '.' and s[i+1] == '.' and s[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: Wrong Answer

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 < 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] == '.' and s[i+1] == '.' and s[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: Wrong Answer

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 < 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] == '.' and s[i+1] == '.' and s[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: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, input().split())
s = input()
count1, count2 = 0, 0
    
for i in range(min(a-1, b-1), max(c, d)):
    if count2 == 2:
        print('No')
        sys.exit()
            
    if s[i] == '#':
        count2 += 1
        count1 = 0
    elif s[i] == '.':
        count1 += 1
        count2 = 0
if c > d:
    count1, count2 = 0, 0
    for i in range(min(a-1, b-1), max(c, d)):
        if count1 == 3:
            print('Yes')
            sys.exit()
        if s[i] == '#':
            count2 += 1
            count1 = 0
        elif s[i] == '.':
            count1 += 1
            count2 = 0

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

Submission status: Wrong Answer

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, b_goal):
    if i < 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] == '.' and s[i+1] == '.' and s[i+2] == '.':
                can_switch = True
if a_goal > b_goal:
    if no_rock_double and can_switch:
        print('Yes')
    else:
        print('No')
else:
    if no_rock_double:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

Solution code:
import sys
n, a, b, c, d = map(int, input().split())
s = input()
count1, count2 = 0, 0
    
for i in range(min(a-1, b-1), max(c, d)):
    if count2 == 2:
        print('No')
        sys.exit()
            
    if s[i] == '#':
        count2 += 1
        count1 = 0
    elif s[i] == '.':
        count1 += 1
        count2 = 0
if c > d:
    for i in range(min(a-1, b-1), max(c, d)):
        if count1 == 3:
            print('Yes')
            sys.exit()
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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, b_goal):
    if i < 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-1):
        if i + 1 < n:
            if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
                can_switch = True
if a_goal > b_goal:
    if no_rock_double and can_switch:
        print('Yes')
    else:
        print('No')
else:
    if no_rock_double:
        print('Yes')
    else:
        print('No')