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:
I=lambda:map(int,input().split())
N,A,B,C,D=I()
S=input()
cross=True if C-A-D+B==0 or 0<=(B-A)/(C-A-D+B)<=1 else False
if not(cross):
    ac = [i for i in range(min(A,C)-1,max(A,C)) if S[i]=='#']
    bd = [i for i in range(min(B,D)-1,max(B,D)) if S[i]=='#']
    f=True
    for i in range(len(ac)-1):
        if ac[i]+1==ac[i+1]:f=False
    for i in range(len(bd)-1):
        if bd[i]+1==bd[i+1]:f=False
    print('Yes' if f else 'No')
else:
    ac = [i for i in range(min(A,C)-1,max(A,C)) if S[i]=='#']
    bd = [i for i in range(min(B,D)-1,max(B,D)) if S[i]=='#']
    ins = False
    for i in range(len(ac)-1):
        if ac[i+1]-ac[i]>=4 and (min(B,D)<=ac[i]+2<=max(B,D) or min(B,D)<=ac[i+1]-2<=max(B,D)):
            ac = ac[:i+1]+[ac[i]+2]+ac[i+1:]
            ins=True
    if not(ins):
        for i in range(len(bd)-1):
            if bd[i+1]-bd[i]>=4 and (min(A,C)<=bd[i]+2<=max(A,C) or min(A,C)<=bd[i+1]-2<=max(A,C)):
                bd = bd[:i+1]+[bd[i]+2]+bd[i+1:]
                ins=True
    if not(ins):
        print('No')
    else:
        f=True
        for i in range(len(ac)-1):
            if ac[i]+1==ac[i+1]:f=False
        for i in range(len(bd)-1):
            if bd[i]+1==bd[i+1]:f=False
        print('Yes' if f else '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')
#    sys.exit()
elif '...' in s:
    print('YES')
elif c < d:
    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()
def Solve():
    if '##' in S[B:D-1] or '##' in S[A:C-1]:#道中に石が2つ並んでたらその時点でアウト
        return 'No'
    if C<D:
        return 'No'
    if '...' in S[B-1:D]:
        return 'Yes'
    else:
        return 'No'
    
print(Solve())

Submission status: Wrong Answer

Solution code:
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 

N, A, B, C, D = [ int(x) for x in input().split() ]
A -= 1
B -= 1
C -= 1
D -= 1
S = input() + "#"

A_blocker = False
B_blocker = False
pass_point = False

A_load = S[A:C]
B_load = S[B:D]
pass_load = S[B-1:D+1]
if '##' in A_load:
    A_blocker = True
if '##' in B_load:
    B_blocker = True
if '...' in pass_load:
    pass_point = True

if D < C:
    if not A_blocker and not B_blocker and pass_point:
        print ("Yes")
    else:
        print ("No")
else:
    if not A_blocker and not B_blocker:
        print ("Yes")
    else:
        print ("No")

Submission status: Wrong Answer

Solution code:
def available(start, end, S, step=None):
    if step is not None:    #   追い越し処理
        S = S[:step] + "#" + S[step+1:]
    for i in range(start-1, end-1):
        if S[i] == "#" and S[i+1] == "#":
            return False
    return True
    
def overtake(start, end, S):
    for i in range(start-1, end-1):
        if S[i-1] == "." and S[i] == "." and S[i+1] == ".":
            step = i
            return True, step
    return False, None

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

if D > C:   #   追い越しが不要な時
    if available(A, C, S) and available(B, D, S):
        print("Yes")
    else:
        print("No")
else:   #   追い越しが必要な時
    judge, step = overtake(B, D, S)
    if judge:   #   追い越しが可能な時
        if available(A, C, S, step=step) and available(B, D, S):
            print("Yes")
        else:
            print("No")
    else:   #   追い越しができない時
        print("No")

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop
import re
from collections import deque
import sys
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_invs(n, mod=DIV):
    inv = [0]*(n+1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, n+1):
        inv[i] = (-(mod//i)*inv[mod % i]) % mod
    return inv


N,A,B,C,D = ints_raw()
S = input()
#N = int_raw()


def main():
    ans = 0
    if D==C:
        return "No"
    if S[D-1]=="#" or S[C-1]=="#":
        return "No"
    if "##" in S[A:max(B, D)]:
        return "No"
    if D>C:
        return "Yes"
    else:
        if "..." in S[B-2:max(D+1,N)]:
            return "Yes"
        if (B-A ==1) and S[B]==".":
            return "Yes"
        return "No" 
    return ans


print(main())

Submission status: Wrong Answer

Solution code:
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,A,B,C,D = Is()
s = S()
if C < D:
    if "##" in s[A-1:D]:
        print("No")
    else:
        print("Yes")
else:
    if "..." in s[B-2:C] and "##" not in s[A-1:C]:
        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:max(c,d)] :
    print("No")
elif c < d:
    print("Yes")
else:
    if s[b-1] == "." and s[b+1] == ".":
        print("Yes")
    elif "..." in s[b:c+1]:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

def readInt():
    return int(input())

def readList():
    return list(input().split())

def readListI():
    return list(map(int, input().split()))

def check(s, x_from, x_to):
    for x in range(x_from, x_to):
        can_jump = False
        for dx in range(0, 2):
            if s[x+dx] == '.':
                can_jump = True
                break
        if not can_jump:
            return False
    return True


def main():
    n, a, b, c, d = readListI()
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = input()

    if c > d:
        # 抜く必要があり、...がb-1<=x<=dにないといけないのでその判定をする
        can_swap = False
        for x in range(b-1, d-1):
            can_swap_here = True
            for dx in range(0, 3):
                if s[x+dx] == '#':
                    can_swap_here = False
                    break
            if can_swap_here:
                can_swap = True
                break
        if not can_swap:
            print("No")
            return

    # それぞれがたどりつけるか (##がないか) を調べれば良い
    if not check(s, a, c):
        print("No")
        return
    if not check(s, b, d):
        print("No")
        return
    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

flag = True
# B -> D
s_bd = s[b:d-1]
for i in range(len(s_bd)-1):
    if s_bd[i:i+2] == "##":
        flag = False
        break
# A -> C
s_ac = s[a:c-1]
if flag:
    for i in range(len(s_ac)-1):
        if s_ac[i:i+2] == "##":
            flag = False
            break
print(s_ac)
print(s_bd)

# Bのせいで通れ無い
has_ddd = False
if flag and s_bd[-1] == "#":
    for i in range(len(s_bd)-2):
        if s_bd[i:i+3] == "...":
            has_ddd = True
    if not has_ddd:
        flag = False

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

Submission status: Wrong Answer

Solution code:
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
# n = int(input())
# A = list(map(int, input().split()))
n, a, b, c, d  = map(int, input().split())
a = a-1
b = b-1
c = c-1
d = d-1
s2 = input()
s = list(s2)

if '...' in s2[b:c] and not ('##' in s2[a:d]):
    print('Yes')
    exit()


if all(s[i] == '.' or s[i+1] == '.' for i in range(b,d)):
    s[d] = '#'
    if all(s[i] == '.' or s[i+1] == '.' for i in range(a,c)):
        print('Yes')
        exit()

print('No')

Submission status: Wrong Answer

Solution code:
N,A,B,C,D = map(int, raw_input().split())
S = raw_input()
i = 1
flagskip = 0
flagerror = 0
flags = 0
flagstop = 0
flagstop2 = 0
for c in S:
	if(flagstop2 == 1):
		if(c =='#'):
			flagstop += 1
		flagstop2 = 0
	if(i <= A):
		i += 1
		continue
	elif(i == B or (i == D and D < C)):
		if c == '#':
			flagerror = 1
			break
		if(flags == 1):
			flagstop += 1
		else:
			flagstop2 = 1
	elif(i == A or i == C or i == D):
		if c == '#':
			flagerror = 1
			break
	if(c == '#'):
		if(flags == 1):
			flagerror = 1
			break
		flags = 1
	else:
		if(flagskip == 1):
			flagskip = 2
		elif(flags == 0 and flagskip == 0 and i > B and i < D):
			flagskip = 1
		flags = 0
	i += 1
if(flagstop == 2 and D < C and flagskip < 2):
	flagerror = 1
if(flagerror == 0):
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
def ok(p,q,s):
    return s[p-1:q].count("##")==0
if a<c<b<d:
    if ok(a,c,s) and ok(b,d,s):
        print("Yes")
    else:
        print("No")
elif a<b<c<d:
    if ok(a,c,s) and ok(b,d,s):
        print("Yes")
    else:
        print("No")
elif a<b<d<c:
    if ok(b,d,s):
        s=s[:b-1]+"#"+s[b:]
        if ok(a,c,s):
            print("Yes")
        else:
            s=s[:b-1]+"."+s[b:]
            if s[b-1:d].count("...")>0:
                print("Yes")
            else:
                print("No")
    else:
        print("No")
else:
    a/=0

Submission status: Wrong Answer

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

S = list(input().split()[0])

result = "YES"

if C < D:
    for i in range(B, D - 1):
        #2つ連続
        if S[i] == "#" and S[i + 1] == "#":
                result = "NO"
else:
    for i in range(B, C - 1):
        #２つ連続
        if S[i] == "#" and S[i + 1] == "#":
                result = "NO"
    for i in range(B, C - 2):
        if S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
            result = "YES"


print(result)

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
flag=0
span=0
buf=-5
if(c<d):
    for i in range(a-1,d):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
else:
    for i in range(b-1,d):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
        elif s[i]=='#':
            buf=max([span,buf])
            span=0
        else:
            span+=1
    if buf<=2:
        flag=1
        #print(buf)
    for i in range(a-1,d):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
print('No' if flag==1 else 'Yes')

Submission status: Wrong Answer

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

A -= 1
B -= 1

if C < B:
    # A ~ C に行けるか
    # B ~ D に行けるか
    count_x = 0
    ans = True
    for i in range(A, C):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_x = 0
        for i in range(B, D):
            if S[i] == "#":
                count_x += 1
            else:
                count_x = 0
            if count_x > 1:
                ans = False
                break
    if ans:
        print("Yes")
    else:
        print("No")
elif C < D:
    # B ~ D に行けるか
    # A ~ C に行けるか
    count_x = 0
    ans = True
    for i in range(B, D):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_x = 0
        for i in range(A, C):
            if S[i] == "#":
                count_x += 1
            else:
                count_x = 0
            if count_x > 1:
                ans = False
                break
    if ans:
        print("Yes")
    else:
        print("No")
else:
    # A ~ Cに行けるか
    # AがBを超えれるか
    # (B~Dに3つ以上の連続空きがある)
    count_x = 0
    ans = True
    for i in range(A, C):
        if S[i] == "#":
            count_x += 1
        else:
            count_x = 0
        if count_x > 1:
            ans = False
            break
    if ans:
        count_o = 0
        ans = False
        for i in range(B, D+1):
            if S[i] == "#":
                count_o = 0
            else:
                count_o += 1
            if count_o > 2:
                ans = True
                break
    if ans:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a, b, c, d = LI_()
    s = S()
    flg = False
    if a + 1 == b and b + 1 == d and c  == d+1:
        print("No")
        return
    if c > d:
        for i in range(b,d):
            if s[i] == "." and s[i + 1] == "." and s[i - 1] == ".":
                flg = i
                break
        if not flg:
            print("No")
            return
    for i in range(a+1, max(c,d)-1):
        if s[i] == "#" and s[i + 1] == "#":
            print("No")
            return
    print("Yes")
    
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()

Submission status: Wrong Answer

Solution code:
import sys

fin = sys.stdin.readline
N, A, B, C, D = [int(elem) for elem in fin().split()]
cell_list = fin().split()[0]

init_max = max(A, B)
init_min = min(A, B)
end_max = max(C, D)
end_min = min(C, D)

after_min_cells = cell_list[init_min:end_max-1]
after_max_cells = cell_list[init_max:end_min-1]
# 途中に#が2つ連続しないか
if '##' in after_min_cells:
    result = 'No'
# 入れ替えが必要かどうか
elif (A-B) * (C-D) < 0:
    # 途中に.が3つ連続するかどうか（＝入れ替えが可能かどうか）
    if '...' in after_max_cells:
        result = 'Yes'
    else:
        result = 'No'
else:
    result = 'Yes'

print(result)

Submission status: Wrong Answer

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

a = A - 1
b = B - 1
c = C - 1
d = D - 1
n = N - 1

is_able = False

while True:
  if (a+1) <= n and S[a+1] == "." and (a+1) != b:
    a += 1
  elif (a+2) <= n and S[a+2] == "." and (a+2) != b:
    a += 2
  elif (b+1) <= n and S[b+1] == "." and (b+1) != a:
    b += 1
  elif (b+2) <= n and S[b+2] == "." and (b+2) != a:
    b += 2
  else:
    is_able = False
    break
    
  if a == c and b == d:
    is_able = True
    break
    
if is_able:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
S = S[:C+1]
r_count = [len(s) for s in S.split('.') if len(s) > 1]
if r_count != []:
    print('No')
    exit()
if C < D:
    print('Yes')
    exit()

count = [len(s) for s in S.split('#') if len(s) > 2]
print('Yes' if len(count) > 0 else 'No')

Submission status: Wrong Answer

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

import sys
if B > C:
    isi = 0
    cnt = 0
    for j in range(A-1,C):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    for j in range(B-1,D):
        i = S[j]
        if i == '.':
            cnt = 0
        elif i == '#':
            cnt += 1
            isi = max(isi,cnt)
    if isi <= 1:
        print('Yes')
    else:
        print('No')
    sys.exit()


aki = 0
isi = 0
cnt = 0
for j in range(min(A,B)-1,max(C,D)):
    i = S[j]
    if i == '.':
        cnt = 0
    elif i == '#':
        cnt += 1
        isi = max(isi,cnt)
        
cnt = 0
for j in range(max(0,max(A,B)-2),max(C,D)):
    i = S[j]
    if i == '#':
        cnt = 0
    elif i == '.':
        cnt += 1
        aki = max(aki,cnt)
        

if C > D:
    if aki >= 3 and isi <= 1:
        print('Yes')
    else:
        print('No')
else:
    if isi <= 1:
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

if((a-b)*(c-d)>0):
	print('Yes')
else:
	if(max([len(item) for item in s.split('#')])>2):
		print('Yes')
	else:
		print('No')

Submission status: Wrong Answer

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

if c > b:
  if c < d:
    if "##" in s[a:d]:
      print('No')
    else:
      print('Yes')
  else:
    if (('##' in s[a:c]) or not('...' in s[b:d])):
      print('No')
    else:
      print('Yes')
else:
  if (('##' in s[a:c]) or ('##' in s[b:d])):
    print('No')
  else:
    print('Yes')

Submission status: Wrong Answer

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

if (a<b and c<d) or (a>b and c>d):
    if '##' in s[min(a,b)-1:max(c,d)]:
        print('No')
    else:
        print('Yes')

else:
    if '...' in s[min(a,b)-1:max(c,d)]:
        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")
elif C<D:
    if "##" in S[A-1:C] or "##" in S[B-1:D]:
        print("No")
    else:
        print("Yes")
else:
    s = S.split("##")
    l=-2
    i=-2
    for ss in s:
        i += 2
        l += 2+len(ss)
        if l >= A:break
        i = l
    if ("..." in ss) and len(ss) >= C+i:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

if S.count('##') > 0:
    print('No')
else:
    if change.count('...') > 0:
        print('Yes')
    elif C < D:
        print('Yes')
    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 - 1, max(C, D)):
  if i >= A and S[i] == "#" and S[i - 1] == "#":
    ans = "No"
    break

#途中で追い越しが必要な場合
if D < C:
  #岩無しが何個続いてるかカウント
  cnt = 0
  tmp = 0
  for i in range(A - 1, D):#BがDに到着するまでに追い越す
    if S[i] == ".":
      tmp += 1
    else:
      cnt = max(cnt, tmp)
      tmp = 0
  cnt = max(cnt, tmp)
  #岩無しのスペースが3個続かなきゃダメ
  if cnt < 3:
    ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5)


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def SI(): return input()


def main():
    N, A, B, C, D = LI()
    S = SI()

    M = [0 for _ in range(A-1)]
    a = 0
    for s in S[A-1:max(C, D)]:
        if s == ".":
            a = 0
            M.append(0)
        else:
            if a == 1:
                print("No")
                return
            a = 1
            M.append(1)
    if D > C:
        print("Yes")
        return
    a = 0
    for m in M[B:D]:
        if m == 0:
            a += 1
        else:
            a = 0
        if a == 3:
            print("Yes")
            return
    if M[B-2] == 0 and M[B] == 0:
        print("Yes")
        return
    if M[D-2] == 0 and M[D] == 0:
        print("Yes")
        return
    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=input()
l=[0]*N
r=[0]*N
stack=[A]
dx=[1,2]
while(stack):
    x=stack.pop()
    l[x]=1
    for d in dx:
        X=x+d
        if X<0 or N<=X or l[X]==1 or S[X]=="#":
            continue
        stack.append(X)
stack=[B]
dx=[1,2]
while(stack):
    x=stack.pop()
    r[x]=1
    for d in dx:
        X=x+d
        if X<0 or N<=X or r[X]==1 or S[X]=="#":
            continue
        stack.append(X)
if C>D:
    t=False
    for i in range(N-3):
        if S[i:i+3]=="..." and l[i]==1 and r[i+1]==1:
            t=True
            break
    if t:
        if l[C]==1 and r[D]==1:
            print("Yes")
            quit()
    print("No")
else:
    if l[C]==1 and r[D]==1:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n, a, b, c, d = LI_()
    s = S()
    flg = False
    if a + 1 == b and b + 1 == c and c + 1 == d:
        print("No")
        return
    if c > d:
        for i in range(b,d):
            if s[i] == "." and s[i + 1] == "." and s[i - 1] == ".":
                flg = i
                break
        if not flg:
            print("No")
            return
    for i in range(a+1, max(c,d)-1):
        if s[i] == "#" and s[i + 1] == "#":
            print("No")
            return
    print("Yes")
    
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()

Submission status: Wrong Answer

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

def jumpto(s, g, road):
    if road[s-1] == "#" or road[g-1] == "#":
        return False
    now = g
    while now > s + 2:
        if road[now - 2] == ".":
            now -= 2
            continue
        if road[now - 1] == ".":
            now -= 1
            continue
        return False

    return True


if jumpto(B, D, S):
    if D == len(S):
        S = S[:D] + "#"
    else:
        S = S[:D]+"#"+S[D+1:]

    if jumpto(A, C, S):
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
from sys import stdin, exit

N, A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]
S = stdin.readline().rstrip()
for k in range(len(S)):
    if S[k] == '#' and S[k + 1] == '#':
        print('No')
        exit()

if C < D:
    print('Yes')
else:
    cnt = 0
    for k in range(A, D):
        if S[k] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt > 2:
            print('Yes')
            exit()
    print('No')

Submission status: Wrong Answer

Solution code:
import numpy as np

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

changable = False
if "..." in S[B:min([C-1, D-1])]:
    changable = True

if not "##" in S[B:]:
    S = S[:D-1] + "#" + S[D:]
    if not "##" in S[A:]:
        ans = "Yes"
    else:
        ans = "No"
else:
    ans = "No"

S = s
if ans is "No":
    if changable:
        if not "##" in S[A:]:
            S = S[:C-1] + "#" + S[C:]
            if not "##" in S[B:]:
                ans = "Yes"
            else:
                ans = "No"
        else:
            ans = "No"
print(ans)

Submission status: Wrong Answer

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

nRock = len(rock)

# renzoku
for i in range(nRock-1):
	if rock[i+1] - rock[i] == 1:
		if A < rock[i] or B < rock[i]:
			print("No")
			exit()

# A ... B ... C ... D
if C < D:
	print("Yes")
	exit()

# A ... B ...#.....#... D ... C
for i in range(nRock):
	if i == 0:
		if rock[i] >= 4:
			if B < rock[i]-1:
				print("Yes")
				exit()
		continue
	if rock[i] - rock[i-1] > 3:
		if B < rock[i-1]-1:
			if D == rock[i-1]+1:
				print("No")
				exit()
			else:
				print("Yes")
				exit()
print("No")

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bisectL

N, A, B, C, D = map(int, input().split())
S = input()
walls = []
prev = ''
for i, c in enumerate(S):
  if prev == '#' and c == '#':
    walls.append(i)
  prev = c

if bisectL(walls, A-1) == bisectL(walls, C-1) and bisectL(walls, B-1) == bisectL(walls, D-1):
  if C < D:
    print('Yes')
    exit()
  else:
    if '...' in S[B-1:D]:
      print('Yes')
      exit()
print('No')

Submission status: Wrong Answer

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

i=0
j=0
gg=0
nnt=0
if c<d:
    i=a-1
    while i!=n:
        if s[i]=="#":
            j=j+1
        else:
            j=0
        if j==2:
            nnt=1
            break
        i=i+1

else:
    i=b-1
    nnt=1
    while i!=n:

        if s[i]==".":
            gg=gg+1
        else:
            gg=0
        if gg==3:
            nnt=0
            break
            
            
        if s[i]=="#":
            j=j+1
        else:
            j=0
        if j==2:
            nnt=1
            break
        
        i=i+1
if nnt==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()
S = list(S)

result = "Yes"
onon = True

if C < D:
    for i in range(len(S)-1):
        if S[i] == "#" and S[i + 1] == "#":
            result =  "No"
else:
    result = "No"
    for i in range(len(S)-1):
        if S[i] == "#" and S[i + 1] == "#":
            onon = False
    if onon:
        for i in range(len(S)-2):
            if S[i] == "." and S[i + 1] == "."and S[i + 2] == ".":
                result = "Yes"


print(result)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import math
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column

# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']




def main():
    N, A, B, C, D = list(map(int,input().split()))
    S= str(input())
    # print(S[2:5])-> [2]~[4]
    if C>D:
        if '##' in S[A:C]:
            print("No")
        elif "..." in S[B-2:C]:
            print("Yes")
        else:
            print("No")
    else:
        if '##' in S[A:D]:
            print("No")
        else:
            print("Yes")
    # elif C>D and  ("..." in S[B-2:])
    # print(S[B-2:])
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
import numpy as np
# n = int(input())
# a, b = map(int, input().split())
# int_list = list(map(int, input().split()))
# l = list(input().split())

def solve():
    n, a, b, c, d = map(int, input().split())
    # stringのindexとして扱う
    a = a - 1
    b = b - 1
    c = c - 1
    d = d - 1
    s = input()

    # aからCの間、bからdの間までの二連岩の存在確認
    if s[a:c+1].find("##") > -1 or s[b:d+1].find("##") > -1:
        print("No")
    else:
        # 二連岩がない場合は、ABDCの飛び越えパターンだけが問題になる
        if b < d and d < c:
            # 飛び越え不可能な場合はNOになる
            # bからdの間で飛び越える必要があり、...があると飛び越えできる
            # bスタートではなく、b-1からかぞえて...があればよい
            if s[b-1:d+1].find("...") > -1:
                print("Yes")
            else:
                print("No")
        else:
            print("Yes")
solve()

Submission status: Wrong Answer

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

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

ans = ans_cand = 'No'
cnt_o = cnt_x = 0
for pos in range(A - 1, max(C, D)):
    Si = S[pos]
    if Si == '#':
        cnt_o = 0
        cnt_x += 1
        if cnt_x > 1: break
    else:
        cnt_x = 0
        if pos < (B - 1) or D - 1 <= pos : continue
        cnt_o += 1
        if cnt_o > 2: ans_cand = 'Yes'
else:
    if C < D:
        ans = 'Yes'
    else:
        ans = ans_cand

print(ans)

Submission status: Wrong Answer

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

if not '##' in S[A:D]:
    if D<C:
        if '...' in S[B:C]:
            print('Yes')
        else:
            print('No')
    else:
        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 :
    print("No")
    quit()

if C > D:
    if '...' not in S[B:]:
        print("No")
        quit()


print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import re
N, A, B, C, D = map(int, input().split())
S = input().replace('.', 'x')

if C < D:
    if len(re.findall('##', S[A:C])) != 0:
        print('No')
    elif len(re.findall('##', S[B:D])) != 0:
        print('No')
    else:
        print('Yes')
else:
    if len(re.findall('##', S[A:C])) != 0:
        print('No')
    elif len(re.findall('xxx', S[B:D])) == 0:
        print('No')
    else:
        print('Yes')

Submission status: Wrong Answer

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

A -= 1
B -= 1
C -= 1
D -= 1

def check():
	for i in range(A, C - 1):
		if S[i] == S[i + 1] == "#":
			return False

	for i in range(B, D - 1):
		if S[i] == S[i + 1] == "#":
			return False
	
	if D < C:
		for i in range(B, D):
			if S[i - 1] == S[i] == S[i + 1] == ".":
				return True
		return False
	else:
		return True

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