Problem:


Score : 400 points

Problem Statement

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

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

You can repeat the following operation any number of times:

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

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

Determine whether this is possible.

Constraints

4 \leq N \leq 200\ 000

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

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

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

A, B, C and D are all different.

A < B

A < C

B < D

Input

Input is given from Standard Input in the following format:

N A B C D
S

Output

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

Sample Input 1

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

Sample Output 1

Yes

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

A#B.#..

A#.B#..

.#AB#..

.#A.#B.

.#.A#B.

.#.A#.B

.#..#AB

Sample Input 2

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

Sample Output 2

No

Sample Input 3

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

Sample Output 3

Yes



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


Sample output:
Yes

Submission status: Wrong Answer

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


# ワーシャルフロイド (任意の2頂点の対に対して最短経路を求める)
# 計算量n^3 (nは頂点の数)
def warshall_floyd(d, n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定



# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
n, a, b, c, d = map(int, input().split())
a -= 1
b -= 1
c -= 1
d -= 1
s = input()


def func1(start, goal):
    for i in range(start, goal):
        if s[i] == "#" and s[i + 1] == "#":
            return False
    return True

def func2(start, goal):
    for i in range(start + 1, goal):
        if s[i - 1] == "." and s[i] == "." and s[i + 1] == ".":
            return True
    return False

if not (func1(a, c) and func1(b, d)):
    print("No")
    sys.exit()

if c < d:
    print("Yes")
else:
    if func2(b, d):
        print("Yes")
    else:
        print("No")
        # print("he")

Submission status: Wrong Answer

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

if A<B<C<D:
    a=True
    for i in range(A-1,D-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        print("Yes")
elif A<C<B<D:
    a=True
    for i in range(A-1,C-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        for i in range(B-1,D-2):
            if S[i]==S[i+1]=="#":
                print("No")
                a=False
                break
    if a==True:
        print("Yes")
elif A<B<D<C:
    a=True
    for i in range(A-1,C-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        for i in range(B-2,D-2+1):
            if S[i]==S[i+1]==S[i+2]:
                a=False
                break
    if a==False:
        print("Yes")
    elif a==True:
        print("No")

Submission status: Wrong Answer

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

if A<B<C<D:
    a=True
    for i in range(A-1,D-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        print("Yes")
elif A<C<B<D:
    a=True
    for i in range(A-1,C-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        for i in range(B-1,D-2):
            if S[i]==S[i+1]=="#":
                print("No")
                a=False
                break
    if a==True:
        print("Yes")
elif A<B<D<C:
    a=True
    for i in range(A-1,C-2):
        if S[i]==S[i+1]=="#":
            print("No")
            a=False
            break
    if a==True:
        for i in range(B-2,D-2):
            if S[i]==S[i+1]==S[i+2]:
                a=False
                break
    if a==False:
        print("Yes")
    elif a==True:
        print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = str(input())
if '##' in s[a:c] or '##' in s[b:d]:
    print('No')
    exit()
if c > d and '...' not in s[b:d + 3]:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = str(input())
if '##' in s[a:c] or '##' in s[b:d]:
    print('No')
    exit()
if c > d and '...' not in s[b:d + 2]:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = str(input())
if '##' in s[a:c] or '##' in s[b:d]:
    print('No')
elif c > d and '...' not in s[b:d + 2]:
    print('No')
else:
    print('Yes')

Submission status: Wrong Answer

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

if c < d:
    print("Yes" if s[a:d-1].count("##") == 0 else "No")
else:
    print("Yes" if s[a:c-1].count("##") ==
          0 and s[b:d-1].count("...") > 0 else "No")

Submission status: Wrong Answer

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

if c < d:
    print("Yes" if s[a:d-2].count("##") == 0 else "No")
else:
    print("Yes" if s[a:c-2].count("##") ==
          0 and s[b:d-2].count("...") > 0 else "No")

Submission status: Wrong Answer

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

if c < d:
    print("Yes" if s[:d-2].count("##") == 0 else "No")
else:
    print("Yes" if s[:c-2].count("##") ==
          0 and s[:d-2].count("...") > 0 else "No")

Submission status: Wrong Answer

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

if c < d:
    print("Yes" if s[:d].count("##") == 0 else "No")
else:
    print("Yes" if s[:c].count("##") == 0 and s[:d].count("...") > 0 else "No")

Submission status: Wrong Answer

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

if c < d:
    print("Yes" if s.count("##") == 0 else "No")
else:
    print("Yes" if s.count("##") == 0 and s.count("...") > 0 else "No")

Submission status: Wrong Answer

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

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


if c == d:
    print("No")
    exit()
elif c < b:
    start = a-1
    end = c-1

    sharp_count = 0
    for i in range(start+1, (end-1)+1):
        if s[i] == "#" and s[i] == s[i+1]:
            print("No")
            exit()

    start = b-1
    end = d-1

    sharp_count = 0
    for i in range(start+1, (end-1)+1):
        if s[i] == "#" and s[i] == s[i+1]:
            print("No")
            exit()
elif c < d:
    start = a-1
    end = d-1

    sharp_count = 0
    for i in range(start+1, (end-1)+1):
        if s[i] == "#" and s[i] == s[i+1]:
            print("No")
            exit()
elif d < c:
    start = a-1
    end = c-1

    sharp_count = 0
    for i in range(start+1, (end-1)+1):
        if s[i] == "#" and s[i] == s[i+1]:
            print("No")
            exit()

    start = b-1
    end = d-1
    dot_count = 0
    count = 0
    for i in range(start-1, (end+1)+1):
        if s[i] == ".":
            count += 1
        else:
            dot_count = max(dot_count, count)
            count = 0
    if dot_count <= 2:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

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


if c == d:
    print("No")
    exit()
elif c < b:
    start = a-1
    end = b-1

    sharp_count = 0
    for i in range(start+1, (end-1)+1):
        if s[i] == "#" and s[i] == s[i+1]:
            print("No")
            exit()

    start = b-1
    end = c-1

    sharp_count = 0
    for i in range(start+1, (end-1)+1):
        if s[i] == "#" and s[i] == s[i+1]:
            print("No")
            exit()
elif c < d:
    start = a-1
    end = d-1

    sharp_count = 0
    for i in range(start+1, (end-1)+1):
        if s[i] == "#" and s[i] == s[i+1]:
            print("No")
            exit()
elif d < c:
    start = a-1
    end = c-1

    sharp_count = 0
    for i in range(start+1, (end-1)+1):
        if s[i] == "#" and s[i] == s[i+1]:
            print("No")
            exit()

    start = b-1
    end = d-1
    dot_count = 0
    count = 0
    for i in range(start-1, (end+1)+1):
        if s[i] == ".":
            count += 1
        else:
            dot_count = max(dot_count, count)
            count = 0
    if dot_count <= 2:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

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

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


if c == d:
    print("No")
    exit()

elif c < d:
    start = a-1
    end = d-1

    sharp_count = 0
    for i in range(start+1, (end-1)+1):
        if s[i] == "#" and s[i] == s[i+1]:
            print("No")
            exit()
elif d < c:
    start = a-1
    end = c-1

    sharp_count = 0
    for i in range(start+1, (end-1)+1):
        if s[i] == "#" and s[i] == s[i+1]:
            print("No")
            exit()

    start = b-1
    end = d-1
    dot_count = 0
    count = 0
    for i in range(start-1, (end+1)+1):
        if s[i] == ".":
            count += 1
        else:
            dot_count = max(dot_count, count)
            count = 0
    if dot_count <= 2:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
S = s[:max(c,d)]
print(S)
l = len(S)
C = True
D = False
for i in range(l-1):
  if i >= min(a,b) and S[i]=='#' and S[i+1]=='#':
    C = False
    break
  if c > d and d > i >= max(a,b)-1:
    if S[i-1]=='.' and S[i]=='.' and S[i+1]=='.':
      D = True
      
if not C:
  print('No')
elif C and not D:
  if c < d:
    print('Yes')
  else:
    print('No')
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
S = s[min(a,b):max(c,d)]

l = len(S)
C = True
D = False
for i in range(l-1):
  if S[i]=='#' and S[i+1]=='#':
    C = False
    break
  if d > i > 0:
    if S[i-1]=='.' and S[i]=='.' and S[i+1]=='.':
      D = True
      
if not C:
  print('No')
elif C and not D:
  if c < d:
    print('Yes')
  else:
    print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

l = len(S)
C = True
D = False
for i in range(l-1):
  if S[i]=='#' and S[i+1]=='#':
    C = False
    break
  if c > d and  d > i > 0:
    if S[i-1]=='.' and S[i]=='.' and S[i+1]=='.':
      D = True
      
if not C:
  print('No')
elif C and not D:
  if c < d:
    print('Yes')
  else:
    print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

l = len(S)
C = True
D = False
for i in range(l-1):
  if S[i]=='#' and S[i+1]=='#':
    C = False
    break
  if d > i > 0:
    if S[i-1]=='.' and S[i]=='.' and S[i+1]=='.':
      D = True
      
if not C:
  print('No')
elif C and not D:
  if c < d:
    print('Yes')
  else:
    print('No')
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
n,a,b,c,d = map(int,input().split())
s = input()
S = s[:max(c,d)]
l = len(S)
C = True
D = False
for i in range(l-1):
  if S[i]=='#' and S[i+1]=='#':
    C = False
    break
  if i > 0:
    if S[i-1]=='.' and S[i]=='.' and S[i+1]=='.':
      D = True
      
if not C:
  print('No')
elif C and not D:
  if c < d:
    print('Yes')
  else:
    print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

s=input()

if c<d or c<b:
    #先にbをdに運んでから、aをCに運べばいい
    if s[b:d+1].count("##")==0 and s[a:c+1].count("##")==0:
        print("Yes")
    else:
        print("No") 
else:
    if s[b:d+1].count("...")==0:
        print("No")
    else:
        if s[b:d+1].count("##")==0 and s[a:c+1].count("##")==0:
            print("Yes")
        else:
            print("No")

Submission status: Wrong Answer

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

bef = ''
row_dot_max = 0
count = 0
for i, s in enumerate(S):
  if bef == '#' and s == '#' and i > A and i <= max(C,D)-2:
    print('No')
    exit()
  
  if s == '.' and i >= B-2 and i!=min(C,D)-1:
    count += 1
  else:
    row_dot_max = max(row_dot_max, count)
    count = 0
  bef = s

row_dot_max = max(row_dot_max, count)
if C > D:
  if row_dot_max >= 3:
    print('Yes')
  else:
    print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

bef = ''
row_dot_max = 0
count = 0
for i, s in enumerate(S):
  if bef == '#' and s == '#' and i > A and i <= max(C,D)-2:
    print('No')
    exit()
  
  if s == '.' and i >= B-2:
    count += 1
  else:
    row_dot_max = max(row_dot_max, count)
    count = 0
  bef = s

row_dot_max = max(row_dot_max, count)
if C > D:
  if row_dot_max >= 3:
    print('Yes')
  else:
    print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

bef = ''
row_dot_max = 0
count = 0
for i, s in enumerate(S):
  if bef == '#' and s == '#' and i >= A-1 and i <= max(C,D)-2:
    print('No')
    exit()
  
  if s == '.' and i >= B-2:
    count += 1
  else:
    row_dot_max = max(row_dot_max, count)
    count = 0
  bef = s
  
if C > D:
  if row_dot_max >= 3:
    print('Yes')
  else:
    print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

bef = ''
row_dot_max = 0
count = 0
for i, s in enumerate(S):
  if bef == '#' and s == '#' and i >= A-1:
    print('No')
    exit()
  
  if s == '.' and i >= B-2:
    count += 1
  else:
    row_dot_max = max(row_dot_max, count)
    count = 0
  bef = s
  
if C > D:
  if row_dot_max >= 3:
    print('Yes')
  else:
    print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

bef = ''
row_dot_max = 0
count = 0
for i, s in enumerate(S):
  if bef == '#' and s == '#' and i <= A-1:
    print('No')
    exit()
  
  if s == '.' and i >= B-2:
    count += 1
  else:
    row_dot_max = max(row_dot_max, count)
    count = 0
  bef = s
  
if C > D:
  if row_dot_max >= 3:
    print('Yes')
  else:
    print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

bef = ''
row_dot_max = 0
count = 0
for i, s in enumerate(S):
  if bef == '#' and s == '#' and i <= A-1:
    print('No')
    exit()
  
  if s == '.':
    count += 1
  else:
    row_dot_max = max(row_dot_max, count)
    count = 0
  bef = s
  
if C > D:
  if row_dot_max >= 3:
    print('Yes')
  else:
    print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

ans = 'Yes'
if '##' in s[a-1:c]:
  ans = 'No'  
if '##' in s[b-1:d]:
  ans = 'No'
  
if c > d:
  if '...' not in s[b-2:d]:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

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

ans = 'Yes'
if '##' in s[a-1:c]:
  ans = 'No'  
if '##' in s[b-1:d]:
  ans = 'No'
  
if c > d:
  if '...' not in s[b-1:d]:
    ans = 'No'

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B, C, D = list(map(int, input().split(' ')))
    S = input()
    if C == D:
        print('No')
    elif C < D:
        for s in [S[(A-1):C], S[(B-1):D]]:
            for i in range(len(s) - 1):
                if s[i:(i+2)] == '##':
                    print('No')
                    return
        print('Yes')
    else:
        # A B D C
        s = S[(A-1):C]
        for i in range(len(s) - 1):
            if s[i:(i + 2)] == '##':
                print('No')
                return
        s = S[(B-2):D]
        ok = False
        for i in range(len(s) - 2):
            if s[i:(i+3)] == '...':
                ok = True
                break
        print('Yes' if ok else 'No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B, C, D = list(map(int, input().split(' ')))
    S = input()
    if C == D:
        print('No')
    else:
        for s in [S[(A-1):C], S[(B-1):D]]:
            for i in range(len(s) - 1):
                if s[i:(i+2)] == '##':
                    print('No')
                    return
        if C < D:
            # A B C D
            print('Yes')
        else:
            # A B D C
            s = S[(B-2):D]
            ok = False
            for i in range(len(s) - 2):
                if s[i:(i+3)] == '...':
                    ok = True
                    break
            print('Yes' if ok else 'No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

# A < B < D, A < B < C
# A < D, B < C の間に # が2マス連続にあったらNo
# さらに D < C なら すぬけくんとふぬけくんが入れ替わる必要がある。
# すなわち3マス連続...が続いている必要がある(#が2マス連続ないことも注意)

left = A

if C < D:
    right = D
else:
    right = C
    idx = []
    for i in range(B - 1, D - 1):
        if S[i] == '.' and S[i + 1] == '.' and S[i + 2] == '.':
            idx.append(i)
    if not idx:
        print('No')
        exit()
    # print('idx', idx)
    # print('idx', S[idx[0]:idx[0] + 10])
# print('N, A, B, C, D', N, A, B, C, D)
T = S[left - 1:right + 1]
# print('T', T)
for i in range(len(T) - 1):
    if T[i] == '#' and T[i + 1] == '#':
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

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

# A < B < D, A < B < C
# A < D, B < C の間に # が2マス連続にあったらNo
# さらに D < C なら すぬけくんとふぬけくんが入れ替わる必要がある。
# すなわち3マス連続...が続いている必要がある(#が2マス連続ないことも注意)

left = A

if C < D:
    right = D
else:
    right = C
    idx = []
    for i in range(B - 1, C - 1):
        if S[i] == '.' and S[i + 1] == '.' and S[i + 2] == '.':
            idx.append(i)
    if not idx:
        print('No')
        exit()
    # print('idx', idx)
    # print('idx', S[idx[0]:idx[0] + 10])
# print('N, A, B, C, D', N, A, B, C, D)
T = S[left - 1:right + 1]
# print('T', T)
for i in range(len(T) - 1):
    if T[i] == '#' and T[i + 1] == '#':
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

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

# A < B < D, A < B < C
# A < D, B < C の間に # が2マス連続にあったらNo
# さらに D < C なら すぬけくんとふぬけくんが入れ替わる必要がある。
# すなわち3マス連続...が続いている必要がある(#が2マス連続ないことも注意)

left = A

if C < D:
    right = D
else:
    right = C
    idx = []
    for i in range(B - 1, C + 1):
        if S[i] == '.' and S[i + 1] == '.' and S[i + 2] == '.':
            idx.append(i)
    if not idx:
        print('No')
        exit()
    # print('idx', idx)
    # print('idx', S[idx[0]:idx[0] + 10])
# print('N, A, B, C, D', N, A, B, C, D)
T = S[left - 1:right + 1]
# print('T', T)
for i in range(len(T) - 1):
    if T[i] == '#' and T[i + 1] == '#':
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

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

# A < B < D, A < B < C
# A < D, B < C の間に # が2マス連続にあったらNo
# さらに D < C なら すぬけくんとふぬけくんが入れ替わる必要がある。
# すなわち3マス連続...が続いている必要がある(#が2マス連続ないことも注意)

left = A

if C < D:
    right = D
else:
    right = C
    idx = []
    for i in range(A - 1, D + 1):
        if S[i] == '.' and S[i + 1] == '.' and S[i + 2] == '.':
            idx.append(i)
    if not idx:
        print('No')
        exit()

# print('N, A, B, C, D', N, A, B, C, D)
T = S[left - 1:right + 1]
# print('T', T)
for i in range(len(T) - 1):
    if T[i] == '#' and T[i + 1] == '#':
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

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

#<##>が存在すると飛べないのでNG
#c>dの場合には、途中でaがbを追い抜く必要がある。そのスペース=<...>が
#あるか判定
if re.search(r'##',s[a:max(b,d)+1]):
    print('No')
else:
    if c>d:
        if (re.search(r'\.{3,}',s[a:c+1])):
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

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

if re.search('##',s[a-2:max(b,d)-1]) is None:
    if c>d and (re.search(r'\.{3,}',s[b-3:d]) is None):
        print('No');exit()
    print('Yes');exit()
print('No')

Submission status: Wrong Answer

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

if re.search('##',s[a:max(b,d)+1]) is None:
    if c>d and (re.search(r'\.{3,}',s[b-3:d]) is None):
        print('No');exit()
    print('Yes');exit()
print('No')

Submission status: Wrong Answer

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

if re.search('##',s[a:max(b,d)+1]) is None:
    if c>d and (re.search(r'\.{3,}',s[b-1:d]) is None):
        print('No');exit()
    print('Yes');exit()
print('No')

Submission status: Wrong Answer

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

if re.search('##',s[a:max(b,d)+1]) is None:
    if c>d and (re.search(r'\.{3,}',s[b:d+1]) is None):
        print('No');exit()
    print('Yes');exit()
print('No')

Submission status: Wrong Answer

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

if not re.search('##',s[a:max(b,d)+1]):
    if c>d and (not re.search(r'\.{3,}',s[b:d+1])):
        print('No');exit()
    print('Yes');exit()
print('No')

Submission status: Wrong Answer

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

if not re.match('##',s[a:max(b,d)+1]):
    s = s[:d]+'#'+s[d+1:]
    if (not re.search('##',s[a:c+1])) or (re.search(r'\.{3,}',s[a:c+1])):
        print('Yes');exit()
print('No')

Submission status: Wrong Answer

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

"""
基本的にはシャープが2連続するとだめ
ただし，片方が間に必ず入っている場合は，...が三連続するところがないとダメ
"""

if A<B and C>D:
    for i in range(B,D-1):
        if S[i:i+3] == [".", ".", "."]:
            print("Yes")
            exit()
    print("No")
    exit()
elif A>B and C<D:
    for i in range(A,C-1):
        if S[i:i+3] == [".", ".", "."]:
            print("Yes")
            exit()
    print("No")
    exit()
else:
    for i in range(min(A,B)-1, max(C,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())

"""
基本的にはシャープが2連続するとだめ
ただし，片方が間に必ず入っている場合は，...が三連続するところがないとダメ
"""

if A<B and C>D:
    for i in range(B,D-1):
        if S[i:i+3] == [".", ".", "."]:
            print("Yes")
            exit()
    print("No")
    exit()
elif A>B and C<D:
    for i in range(A,C-1):
        if S[i:i+3] == [".", ".", "."]:
            print("Yes")
            exit()
    print("No")
    exit()
else:
    for i in range(min(A,B), max(C,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,b,c,d = map(lambda x:x-1,[a,b,c,d])

def dp_check(dp,x,y):
    dp[x]=0
    for i in range(x,y+1):
        if s[i]=='#':
            continue
        if i+1<=n-1 and dp[i]!=-1:
            if s[i+1]!='#':
                dp[i+1] = dp[i] + 1
        if i+2<=n-1 and dp[i]!=-1:
            if s[i+2]!='#':
                dp[i+2] = dp[i] + 1
    
    return True if dp[y]!=-1 else False

dp_a = [-1]*n
dp_b = [-1]*n

if dp_check(dp_b,b,d):
    s[d]='#'
    if dp_check(dp_a,a,c):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

def dp_check(dp,x,y):
    dp[x]=0
    for i in range(x,y+1):
        if s[i]=='#':
            continue
        if i+1<=n-1:
            if s[i+1]!='#':
                dp[i+1] = dp[i] + 1
        if i+2<=n-1:
            if s[i+2]!='#':
                dp[i+2] = dp[i] + 1
    
    return True if dp[y]!=-1 else False

dp_a = [-1]*n
dp_b = [-1]*n

if dp_check(dp_b,b,d):
    s[d]='#'
    if dp_check(dp_a,a,c):
        print('Yes')
    else:
        print('No')