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 = map(int, input().split())
li = list(input())

count_dot = 0
count_sharp = 0
max_dot = 0

if(c>d):
  for i in range(n):
    if li[i]=='.':
      count_sharp = 0
      count_dot += 1
    else:
      max_dot = max(max_dot, count_dot)
      count_dot = 0
      count_sharp += 1
      if count_sharp>1:
        break
  max_dot = max(max_dot, count_dot)

  if(count_sharp<=1 and max_dot>2):
    print('Yes')
  else:
    print('No')
else:
  for i in range(n):
    if li[i]=='#':
      count_sharp += 1
      if count_sharp>1:
        break
    else:
      count_shrap = 0
  if(count_sharp<=1):
    print('Yes')
  else:
    print('No')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3

import math
import sys


DEBUG = False


def inp():
    return sys.stdin.readline().rstrip()


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


def has_double(S, x, y):
    for i in range(x, y):
        if S[i] == '#' and S[i + 1] == '#':
            return True
    return False


def solve(N, A, B, C, D, S):
    A -= 1
    B -= 1
    C -= 1
    D -= 1
    if has_double(S, A, C):
        return False
    if has_double(S, B, D):
        return False

    if D < C:
        lb = A
        rb = C
        while True:
            assert S[lb] == '.'
            if lb >= 2 and S[lb - 2] == '.':
                lb -= 2
                continue
            if lb >= 1 and S[lb - 1] == '.':
                lb -= 1
                continue
            break

        while True:
            assert S[rb] == '.'
            if rb < N - 2 and S[rb + 2] == '.':
                rb += 2
                continue
            if rb < N - 1 and S[rb + 1] == '.':
                rb += 1
                continue
            break

        for i in range(lb, rb - 1):
            if S[i] == '.' and S[i + 1] == '.' and S[i + 2] == '.':
                return True

        return False

    return True


def main():
    N, A, B, C, D = [int(e) for e in inp().split()]
    S = inp()
    print('Yes' if solve(N, A, B, C, D, S) else 'No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


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

    if "..." not in s[a-1:c]:
        print("No")
        exit()

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

print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
N, A, B, C, D = map(int, input().split())
S = input()
skip = 0
for i in range(max(C,D)-1):
	if S[i]==S[i+1]=="#":
		print('No')
		sys.exit()
	if B-1 <= i < N-3 and S[i]==S[i+1]==S[i+2]==".":
		skip += 1

if C<D:
	print('Yes')

elif skip > 0:
	print("Yes")
else:
	print('No')

Submission status: Wrong Answer

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

    s.insert(0, '.')

    # C D までに岩が2個あるか
    t = s[min(a,b):max(c,d)]
    st = "".join(t)
    if '##' in st:
        print("No")
        return

    # A B が入れ替わるかどうか
    if (c > d):
        # 入れ替わるスペースがあるか
        u = s[b-1:min(c,d)]
        su = "".join(u)
        if not '...' in su:
            print("No")
            return

    print("Yes")

test()

Submission status: Wrong Answer

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

a, b, c, d = a - 1, b - 1, c - 1, d - 1
if s[c] == '#' or s[d] == '#':
    ans = 'No'
elif s.find('##', b, d + 1) != -1 or s.find('##', a, c + 1) != -1:
    ans = 'No'
elif c < d:
    ans = 'Yes'
elif s[d - 1] == '.' and s[d + 1] != '#':
    ans = 'Yes'
elif s.find('..', b + 1, d) != -1:
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Submission status: Wrong Answer

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

ans = True

if '##' in s:
    ans = False
else:
    if d > c:
        ans = True
    else:
        if '...' in s[a:]:
            ans = True
        else:
            ans = False

if ans is True:
    print ('Yes')
else:
    print ('No')

Submission status: Wrong Answer

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

def scan(a_, c_):
    mae = ''
    for i, l in enumerate(s, 1):
        if a_ > i:
            continue
        if c_ == i:
            return True
        if mae == l == '#':
            return False
        mae = l

def scan2(a_, c_):
    mae = ''
    maemae = ''
    for i, l in enumerate(s, 1):
        if a_ > i:
            continue
        if c_ == i:
            return False
        if mae == maemae == l == '.':
            return True
        maemae = mae
        mae = l

if d > c and scan(a, c) and scan(b, d):
    print('Yes')
elif d < c and scan(a, c) and scan(b, d) and scan2(b, d):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys

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


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

Submission status: Wrong Answer

Solution code:
import sys
import copy

def solve(n, a, b, c, d, s):
    if c < d:
        if b < c:
            width = [(a-1, d)]
        else:
            width = [(a-1, c), (b-1, d)]

        for left, right in width:
            for i in range(left, right):
                if s[i] == "#" and s[i+1] == "#":
                    return "No"
                else:
                    return "Yes"
    else:
        flag = False
        for i in range(a-1, c):
            if s[i] == "#" and s[i+1] == "#":
                return "No"
            if b - 2 <= i <= d - 2 and s[i] == "." and s[i+1] == "." and  s[i+2] == "." :
                flag = True
        return "Yes" if flag else "No"


if __name__ == '__main__':

    n, a, b, c, d = map(int, sys.stdin.readline().strip().split(" "))
    s = sys.stdin.readline().strip()
    print solve(n, a, b, c, d, s)

Submission status: Wrong Answer

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

ans = 0
def aaa(s,g):
    global ans
    if S[s:g].count("##") == 0:
        ans += 1
    
def bbb(s,g):
    global ans
    if S[s:g].count("##") == 0:
        ans += 1
        return(1)
    else:
        return(0)
        
if c < d:
    aaa(b,d)
    aaa(a,c)
else:
    flag = bbb(b,d)
 #   print(ans)
    if flag == 1:
        if S[a:c].count("...") != 0:
            ans += 1
        elif S[a:c].count("##") == 0:
            k1 = S[:b-1] + "#" + S[b:]
            k2 = S[:d-1] + "#" + S[d:]
            if k1[a:c].count("##") == 0 or k2[a:c].count("##") == 0:
                ans += 1
#    print(flag)
  #  print(ans)

if ans == 2:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#coding:utf-8
N,A,B,C,D = map(int,input().split())
S = input()
def isContinuous(S):
    for i in range(len(S)-1):
        if S[i:i+2] == "##":
            return True
    return False
def paint(S):
    P = [0] * len(S)
    for i in range(len(S)):
        if S[i] == "#":
            P[i] = 1
            if i != 0:
                P[i-1] = 1
            if i != (len(S)-1):
                P[i+1] = 1
    return P
if C < D:
    if (not isContinuous(S[A:C])) and (not isContinuous(S[B:D])):
        print ("Yes")
    else:
        print ("No")
else:
    P = paint(S)
    #print (P)
    #print (P[B:D])
    for i in P[B:D]:
        if i == 0:
            print ("Yes")
            exit()
    print ("No")

Submission status: Wrong Answer

Solution code:
import itertools
from sys import stdin
N,A,B,C,D=[int(x) for x in stdin.readline().rstrip().split()]
S=(stdin.readline().rstrip())
lst = [1 if i == "#" else 0 for i in list(S)]
cumsum = itertools.accumulate(lst)
cumsum = [0] + list(cumsum) 

flag = True
flag_oinuki = False
for i in range(0,(len(cumsum) - 2)):
    if cumsum[i+2] - cumsum[i] == 2:
        flag = False
        break
for j in range(0,(len(cumsum) - 3)):
    if cumsum[j] == cumsum[j+3]:
        flag_oinuki = True

if C > D:
    if flag_oinuki and flag:
        print("Yes")
    else:
        print("No")
else:
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = list(map(int,input().split()))
s = input()
check = [[0]*(n+1) for _ in range(n+1)]
check[a][b] = 1

for i in range(a,n+1):
    for j in range(b, n+1):
        # A, Bは同じ場所に入れない
        if i == j:
            continue
        # 岩がある場所には入れない
        if s[i-1] == '#' and s[j-1] == '#':
            continue
        # 遷移元があればtrue
        if check[i-1][j] or check[i-2][j] or check[i][j-1] or check[i][j-2]:
            check[i][j] = 1
        if check[c][d]==1:
            break
print('Yes' if check[c][d]==1 else 'No')

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
p=list(input())
count=0
r1=0
for i in range(b,d-1):
    if p[i-1]=="#" and p[i]=="#" :
        r1=1
        break;
    else:
        r1=0
count=0
r2=0
for j in range(a,c-1):
    if p[j-1]=="#" and p[j]=="#" :
        r2=1
        break;
    else:
        r2=0

for k in range(b,d-2):
    if p[k-1]=='.' and  p[k]=='.' and  p[k+1]=='.' and k<(d-2):
        r4=0
        break;
    else:
        r4=1

        
if r1==0 and r2==0:
    if c<d:
        print("Yes")
    elif r4==0:
        print("Yes")
    else:
        print("No")
        
else:
    print("No")

Submission status: Wrong Answer

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

# 間に＃が連続していなければ通るはず

if not "##" in S[A-1:max([C-1,D-1])]:
    if not "##" in S[B-1:D-1]:
        S = list(S)
        S[D-1] = "#"
        S = ''.join(S)
        if not "##" in S[A-1:C-1] or "..." in S[B-2:C]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Submission status: Wrong Answer

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

    
ans="Yes"
for i in range(a,max(c,d)-1):
  if s[i-1]=="#" and s[i]=="#":
    ans="No"

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

Submission status: Wrong Answer

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

S = []
S.append(-1)
p2 = -1
p = -1
err = False
pathway = False
for s in input():
  if s == '.':
    S.append(0)
    if p2 == 0 and p == 0:
      pathway = True
    p2 = p
    p = 0
  else:
    S.append(1)
    if p == 1:
      err = True
    p2 = p
    p = 1
    
res = err
if err == False:
  if (S[A] == 0) and (S[B] == 0) and (S[C] == 0) or (S[D] == 0):
    if C > D:
      if pathway == True:
        res = True

    else:
      res = True
    
if res == True:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = [int(x) for x in input().split()]
S = input()
cross = False
minG = C
maxG = D

if C > D:
    minG = D
    maxG = C
    cross = True

wall = S.find("##")
even = S.rfind("...")

if cross == False:
    if wall == -1:
        print("Yes")
    elif wall < A or maxG < wall:
        print("Yes")
    elif B < wall and wall < minG:
        print("Yes")
    else:
        print("No")
else:
    if even == -1:
        print("No")
    elif even + 1 < B:
        print("No")
    elif minG < even + 1:
        print("No")
    elif A <= wall and wall <= maxG:
        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 c < d:
    print('Yes')
else:
    i = 0
    while True:
        i = s.find('...', i + 1)
        if b <= i < d:
            print('Yes')
            break
        elif i >= d:
            print('No')
        else:
            pass

Submission status: Wrong Answer

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

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

S = input()

# '#'が2連続あれば移動不可能
S_split = S.split('.')

max_length = 0
for s in S_split:
    if len(s) > max_length:
        max_length = len(s)

if max_length >= 2:
    print('No')
    sys.exit()

# ここまでくればBは必ず目的地に到着可能

# もしC<DだったらAも必ず到着可能
if C < D:
    print('Yes')
    sys.exit()

# もしC>Dだったら、Dの手前が'#'もしくはDの奥が'#'の場合はAはほぼ到達不可能
if S[D-2] == '#' or S[D] == '#':
    # もしS[B-1]からS[D-1]の間に'...'があれば、もしくは[A, B, .]であればAは到達可能
    if '...' in S[B-1:D]:
        print('Yes')
        sys.exit()
    elif A + 1 == B and S[B] == '.':
        print('Yes')
        sys.exit()
    print('No')
    sys.exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def SI(): return input()

N,A,B,C,D=LI()
st=input()

if C < D:
    if st[A:C].find('##') >= 0 or st[B:D].find('##') >= 0:
        print('No')
    else:
        print('Yes')
else:
    # Cの方がおおきいケース 入れ替わる
    if st[A:C].find('##') >= 0:
        print('No')
    else:
        if st[A:D].find('...') >= 0:
            print('Yes')
        else:
            print('No')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = (int(i) for i in input().split())  
s = str(input())
s = s[a-1:]

m = max([c, d])
if n>m:
    n = m
    s = s[:n]
    
if '##' in s:
    print('No')
else:
    if c>d:
        if '...' in s[: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()
cou1 = 0
ans1 = 0
cou2 = 0
ans2 = 0
S2 = S[A:]
if C < D:
    S1 = S[A: D-1]
    for i in S1:
        if i == "#":
            cou1 += 1
        else:
            ans1 = max(ans1, cou1)
            cou1 = 0
    if ans1 < 2:
        print("Yes")
    else:
        print("No")
else:
    for i in range(len(S2)):
        if S2[i] == "#":
            cou1 += 1
            ans2 = max(ans2, cou2)
            cou2 = 0
        else:
            cou2 += 1
            ans1 = max(ans1, cou1)
            cou1 = 0
        if ans2 == 3 and ans1 < 2 and i > C - A:
            print("Yes")
            break
    else:
        print("No")

Submission status: Wrong Answer

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

if d > c:
    flag1 = False
    block = 0
    for i in range(b, len(s)):
        if block == 2:
            flag1 = False
            break
        elif i == d-1:
            flag1 = True
            break
        elif s[i] == ".":
            block = 0
        elif s[i] == "#":
            block += 1

    if flag1 == True:
        s2 = s[:d-1]+'#'+s[d:]
        flag1 = False
        block = 0
        for i in range(a, c + 1):
            if block == 2:
                flag1 = False
                break
            elif i == c-1:
                flag1 = True
                break
            elif s2[i] == ".":
                block = 0
            elif s2[i] == "#":
                block += 1

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



else:
    flag2 = False
    flag3 = False
    temp = 0
    block = 0
    for i in range(b,c-1):
        if temp == 3:
            flag2 = True
            temp = i-1
            break
        elif s[i] == "#":
            temp = 0
        elif s[i] == ".":
            temp += 1

    if flag2 == True:
        flag3 = False
        block = 0
        s1 = s[:temp - 1] + '#' + s[temp:]
        for i in range(a, len(s)):
            if block == 2:
                flag3 = False
                break
            elif i == c-1:
                flag3 = True
                break
            elif s1[i] == ".":
                block = 0
            elif s1[i] == "#":
                block += 1

        if flag3 == True:
            s3 = s1[:c - 1] + '#' + s1[c:]
            flag3 = False
            block = 0
            for i in range(temp + 1, len(s)):
                if block == 2:
                    flag3 = False
                    break
                elif i == c-1:
                    flag3 = True
                    break
                elif s3[i] == ".":
                    block = 0
                elif s3[i] == "#":
                    block += 1

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

Submission status: Wrong Answer

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

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

else:
    S[D - 1] = str("#")
    S[B - 1] = str("#")
    for i in range(B, D - 2, 1):
        if S[i - 1] == "." and S[i] == "." and S[i + 1] == ".":
            t = 1

    for i in range(A - 1, C - 2, 1):
        if S[i] == "#" and S[i + 1] == "#":
            if (i == B - 1 or i + 1 == B - 1) or t:
                f = 1
                continue
            if ((i == D - 1 or i + 1 == D - 1) and f == 0) or t:
                continue
            print("No")
            exit()

print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flag3 = 0
flagno = 0

if c > d:

    for i in range(a,c-2):

        if s[i:i+2] == "##":
            flagno += 1
            break

    if flagno == 0:

        for i in range(b,d-1):
        
            if s[i-2:i+1] == "...":
                flag3 += 1
                break
    
    if flagno == 0 and flag3 > 0:
        print("Yes")

    else:
        print("No")

else:

    for i in range(a,d-2):

        if s[i:i+2] == "##":
            flagno += 1
            break
    
    if flagno == 0:
        print("Yes")

    else:
        print("No")

Submission status: Wrong Answer

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

if '#' not in s:
    print('Yes')
elif '##' in s and  a < s.index('##') < c:
    print('No')
elif '##' in s and  b < s.index('##') < d:
    print('No')
elif c > d:
    if s[d - 2] == '#' or s[d] == '#':
        print('No')
    else:
        print('Yes')
# if c > d:
#     if '...' in s and a < s.index('...') < c:
#         print('Yes')
#     else:
#         print('No')
# elif '#.#' in s and a < s.index('#.#') and s.index('#.#') < c and a < b and c > d:
#     print('No')
# elif '#.#' in s and b < s.index('#.#') and s.index('#.#') < d:
#     print('No')
# elif '#..#' in s and a < b and c > d:
#     print('No')
# elif '#..#' in s and a > b and c < d:
#     print('No')
elif '...' in s:
    print('Yes')
elif c < d:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

        if max(cnt,tmp) < 3:
                result = 'No'
        if result =='Yes':
            for i in range(a,c-1):
                if s[i]=='#'and s[i+1]=='#':
                    result='No'
    else:
        for i in range(b,d):
            if s[i] =='#' and s[i+1]=='#':
                result ='No'
                break
        if result=='Yes':
            for i in range(a,c-1):
                if s[i] =='#' and s[i+1]=='#':
                    result = 'No'
    print(result)

main()

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = list(map(int, input().split()))
S = list(input())
A = A-1
B = B-1
C = C-1
D = D-1
S[A] = 'a'
S[B] = 'b'
a = A
b = B
flag = False
bflag = False
if A > B:
    B, A = (A, B)
    D, C = (C, D)

if B > A and D > C:
    for i in range(N):
        if b == D:
            flag = True
            break
        if S[b+1]=='.':
            S[b+1] = 'b'
            S[b] = '.'
            b += 1
        elif S[b+2]=='.':
            S[b+2] = 'b'
            S[b] = '.'
            b += 2

elif B > A and C > D:
    for i in range(N):
        if b > 1 and b+1 < N:
            if S[b-1] == '.' and S[b+1] == '.':
                bflag = True
                break
        if b + 1 < N:
            if S[b+1] == '.':
                S[b+1] = 'b'
                S[b] = '.'
                b += 1
            elif b + 2 < N:
                if S[b+2] == '.':
                    S[b+2] = 'b'
                    S[b] = '.'
                    b += 2

    if bflag:
        a = a+1
        for i in range(N-a):
            if a == C:
                flag = True
                break
            if S[a+1] == '.':
                S[a+1] = 'a'
                S[a] = '.'
                a += 1
            elif S[a+2] == '.':
                S[a+2] = 'a'
                S[a] = '.'
                a += 2

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

Submission status: Wrong Answer

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


for i in range(N-1):
    if S[i] == "#" and S[i+1] == "#":
        print("No")
        exit()

if C < D:
    print("Yes")
    exit()

if S[B-1] != "#" and S[B] == "." and S[B+1] == ".":
    print("Yes")
    exit()

for i in range(N):
    
    if i+B+2 >= N:
        print("No")
        exit()
        break
    
    if i+B+2 > D:
        print("No")
        exit()
        break
        
    if S[i+B] == "." and S[i+B+1] == "." and S[i+B+2] == ".":
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

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

rock = "#"
S = list()
three_empty = []
two_rocks = []
rock_cnt, empty_cnt = 0, 0

# 通れない２連続岩の場所とABが交差できる３emptyの場所取得
for i, s in enumerate(input().strip(), start=1):
  is_rock = s == rock
  if is_rock:
    if empty_cnt >= 3:
      three_empty.append(i - 1)
    rock_cnt += 1
    empty_cnt = 0
  else:
    if rock_cnt >= 3:
      two_rocks.append(i - 1)
    rock_cnt = 0
    empty_cnt += 1
if rock_cnt >= 3:
  two_rocks.append(i)
if empty_cnt >= 3:
  three_empty.append(i)

flag = True
left = A if A < B else B
right = B if A > B else A
left_rock = 0
right_rock = 200001


for i in two_rocks:
  # 目標の間に岩があるか確認
  if A > i > C or B > i > D:
    flag = False
    break
  # 左と右にいる人から一番近い岩の位置
  if i < left:
    left_rock = i
  elif right_rock != 200001 and right < i:
    right_rock = i

if not flag:
  # 目標との間に2岩があるとき
  print("No")
elif (A > B and C > D) or (A < B and C < D):
  # 木彫との間に2岩がなく、交差が発生しない場合。
  print("Yes")
elif not three_empty:
  # 交差点となる3emptyがない場合
  print("No")
else:
  # 双方の一番近い岩との間に3emptyがあるかどうか 
  flag = False
  for i in three_empty:
    if left_rock < i < right_rock:
      flag = True
      break
  if flag:
    print("Yes")
  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:C]:
	print("No")
elif "##" in S[B-1:D]:
	print("No")
elif D < C:	# A jumps over B
	if not "..." in S[B-1:C]:
		print("No")
	elif S[B-1:D].count("...") < 2:
		if S[D-2:D+1] == "#..":
			print("No")
		else:
			print("Yes")
	else:
		print("Yes")
else:
	print("Yes")

Submission status: Wrong Answer

Solution code:
n, a, b, c, d = map(int, input().split())
s = input()
s_flag = False
can_flag = True
count = 0

for i in range(n):
  if s[i] == '#':
    count = 0
    s_flag = True
    if s_flag:
      can_flag = False
      break
    else:
      s_flag = False
  else:
    s_flag = False
    count += 1
if count > 0 and count <= 2:
  if c >= d:
    can_flag = False

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

Submission status: Wrong Answer

Solution code:
import sys
import copy

def solve(n, a, b, c, d, s):
    if c < d:
        if b < c:
            width = [(a-1, d-1)]
        else:
            width = [(a-1, c-1), (b-1, d-1)]

        for left, right in width:
            for i in range(left, right):
                if s[i] == "#" and s[i+1] == "#":
                    return "No"
                else:
                    return "Yes"
    else:
        flag = False
        for i in range(a-1, c-1):
            if s[i] == "#" and s[i+1] == "#":
                return "No"
            if b - 2 <= i <= d - 2 and s[i] == "." and s[i+1] == "." and  s[i+2] == "." :
                flag = True
        return "Yes" if flag else "No"


if __name__ == '__main__':

    n, a, b, c, d = map(int, sys.stdin.readline().strip().split(" "))
    s = sys.stdin.readline().strip()
    print solve(n, a, b, c, d, s)

Submission status: Wrong Answer

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

dp_1 = [False] * N
count_1 = B - 1
dp_1[count_1] = True
while count_1 <= D - 1:
  if dp_1[count_1] == True:
    if (count_1 + 1) <= N - 1 and s[count_1 + 1] == '.':
      dp_1[count_1 + 1] = True
    if (count_1 + 2) <= N - 1 and s[count_1 + 2] == '.':
      dp_1[count_1 + 2] = True
  count_1 += 1

if dp_1[D - 1] == True:
  dp_2 = [False] * N
  count_2 = A - 1
  dp_2[count_2] = True
  while count_2 <= C - 1:
    if dp_2[count_2] == True:
      if (count_2 + 1) <= N - 1 and s[count_2 + 1] == '.' and (count_2 + 1) != D - 1:
        dp_2[count_2 + 1] = True
      if (count_2 + 2) <= N - 1 and s[count_2 + 2] == '.' and (count_2 + 2) != D - 1:
        dp_2[count_2 + 2] = True
    count_2 += 1
  
  print(dp_1)
  print(dp_2)
  if dp_2[C - 1] == True: 
    print('Yes')
  else: 
    print('No')
else: 
  print('No')

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n, a, b, c, d = map(int, input().split())
s = input()
grid = []
for rock in s:
    grid.append(rock == '#')

if grid[c-1] or grid[d-1]:
    print('No')

max_rock_count = 0
rock_count = 0
if c < d:
    for i in range(a-1, d):
        if grid[i]:
            rock_count += 1
        else:
            rock_count = 0

        max_rock_count = max(max_rock_count, rock_count)

    if max_rock_count >= 2:
        print('No')
    else:
        print('Yes')
elif c > d:
    max_rock_count = 0
    rock_count = 0
    canSkip = False
    for i in range(a-1, c):
        if grid[i]:
            rock_count += 1
        else:
            if b - 1 <= i and i <= c - 2 and not grid[i-1] and not grid[i] and not grid[i+1]:
                if i-1 != d - 1 and i+1 != d - 1:
                    canSkip = True
            rock_count = 0

        max_rock_count = max(max_rock_count, rock_count)

    if max_rock_count <= 1 and canSkip:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

listA=list(map(int,input().split()))

kenken_map = input()

A_init = listA[1]-1
B_init = listA[2]-1
A_goal = listA[3]-1
B_goal = listA[4]-1

kenken_temp_b = kenken_map[B_init:B_goal]
kenken_temp_b_goal = kenken_map[:B_goal] + '#' + kenken_map[B_goal+1:]
kenken_temp = kenken_temp_b_goal[A_init:A_goal]


if '##' in kenken_temp_b:
    print('No')
elif not '##' in kenken_temp:
    print('Yes')
elif '...' in kenken_temp_b:
    print('Yes')
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:C] or "##" in S[B-1:D]:
  print("No")

elif C < D:
  print("Yes")

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