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:
def main():
    n,a,b,c,d = [int(x) for x in input().split()]
    S = input()
    
    a -= 1
    b -= 1
    c -= 1
    d -= 1

    if a>b:
        a,b,c,d=b,a,d,c
    
    # move a to left
    while a>0:
        if a-2>=0 and S[a-2]=='.':
            a -= 2
        elif a-1>=0 and S[a-1]=='.':
            a -= 1
        else:
            break
    # move b to right
    while b<n:
        if b+2<n and S[b+2]=='.':
            b += 2
        elif b+1<n and S[b+1]=='.':
            b += 1
        else:
            break
    # goal cannot be reached
    if c<a or b<d:
        print 'No'
        sys.exit()

    # move a as much to right as possible
    found_special = False
    while 1:
        if a+1<n and a+1<b and S[a+1]=='.':
            a += 1
        elif a+2<n and a+2<b and S[a+2]=='.':
            a += 2
        else:
            break
        if a-1>=0 and a+1<n and S[a-1]==S[a]==S[a+1]=='.':
            found_special = True
    
    # if they need to jump over eachother, but no gap was found
    if c>d and not found_special:
        print 'No'
        sys.exit()
    
    while a<c:
        if a+1<n and S[a+1]=='.':
            a += 1
        elif a+2<n and S[a+2]=='.':
            a += 2
        else:
            print 'No'
            sys.exit()
            
    while a>c:
        if a-2>=0 and S[a-2]=='.':
            a -= 2
        elif a-1>=0 and S[a-1]=='.':
            a -= 1
        else:
            print 'No'
            sys.exit()
    while b>d:
        if b-2>=0 and S[b-2]=='.':
            b -= 2
        elif b-1>=0 and S[b-1]=='.':
            b -= 1
        else:
            print 'No'
            sys.exit()
    if a!=c or b!=d:
        print 'No'
    else:
        print 'Yes'


######## Python 2 and 3 footer by Pajenegod and c1729

# Note because cf runs old PyPy3 version which doesn't have the sped up
# unicode strings, PyPy3 strings will many times be slower than pypy2.
# There is a way to get around this by using binary strings in PyPy3
# but its syntax is different which makes it kind of a mess to use.

# So on cf, use PyPy2 for best string performance.

py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange

import os, sys
from io import IOBase, BytesIO

BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')

# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

# Read all remaining integers in stdin, type is given by optional argument, this is fast
def readnumbers(zero = 0):
    conv = ord if py2 else lambda x:x
    A = []; numb = zero; sign = 1; i = 0; s = sys.stdin.buffer.read()
    try:
        while True:
            if s[i] >= b'0' [0]:
                numb = 10 * numb + conv(s[i]) - 48
            elif s[i] == b'-' [0]: sign = -1
            elif s[i] != b'\r' [0]:
                A.append(sign*numb)
                numb = zero; sign = 1
            i += 1
    except:pass
    if s and s[-1] >= b'0' [0]:
        A.append(sign*numb)
    return A

if __name__== "__main__":
  main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    A -= 1
    B -= 1
    C -= 1
    D -= 1

    S_original = S
    S = list(S_original)

    flag = False
    
    # case1 Cに先にたどり着くパターン
    S[C] = '#'
    S[B] = '#'

    S = ''.join(S)
    if '##' in S[A+1:C]:
        pass
    elif '##' in S[B+1:D]:
        pass
    else:
        flag = True

    # case2 Dに先にたどり着くパターン
    S = list(S_original)

    S[D] = '#'
    S[A] = '#'

    S = ''.join(S)
    if '##' in S[A+1:C]:
        pass
    elif '##' in S[B+1:D]:
        pass
    else:
        flag = True

    # case 3
    S = list(S_original)

    S = ''.join(S)
    if '...' in S[B:C] or '..' == S[B+1:B+1+2]:
        if '##' in S[A+1:C]:
            pass
        elif '##' in S[B+1:D]:
            pass
        else:
            flag = True

    if flag == True:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)


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=input().strip()

BLOCK=[0]*N
OPEN=[0]*N

for i in range(1,N):
    if S[i]=="#" and S[i-1]=="#":
        BLOCK[i]=1

for i in range(2,N):
    if S[i]==S[i-1]==S[i-2]==".":
        OPEN[i]=1

RIGHT_A=N-1
for i in range(A,N):
    if BLOCK[i]==1:
        RIGHT_A=i
        break

RIGHT_B=N-1
for i in range(B,N):
    if BLOCK[i]==1:
        RIGHT_B=i
        break

if C<=RIGHT_A+1 and D<=RIGHT_B+1:
    if RIGHT_A==RIGHT_B:
        for j in range(B+1,min(min(C,D)+2,N)):
            if OPEN[j]==1:
                print("Yes")
                sys.exit()

        else:
            if C<D:
                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()

def judge(start,goal):
    for i in range(start,goal-1):
        if s[i] == "#" and s[i+1] == "#":
            return 0
    return 1

def full_judge (start,obst,obfin,goal):
    if s[obst] == "." :
        return 1
    for i in range(start-1,goal-2):
        if s[i] == "." and s[i+1] == "." and s[i+2] == ".":
            return 1
    return 0


if c<b:
    if (judge(a,c) and judge(b,d)):
        print("Yes")
    else:
        print("No")
elif c<d:
    if (judge(a,c) and judge(b,d)):
        print("Yes")
    else:
        print("No")
else:
    if judge(b,d) and full_judge(a,b,d,c) and judge(a,c):
        print("Yes")
    else:
        print("No")

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(a-1,c):
        if(s[i]=='#' and s[i+1]=='#'):
            flag=1
            break
    if(flag!=1):
        for i in range(b-1,d):
            #print(flag)
            if s[i]=='#':
                buf=max([span,buf])
                span=0
            else:
                span+=1
        if buf<=2:
            flag=1
        #print(buf)
print('No' if flag==1 else 'Yes')

Submission status: Wrong Answer

Solution code:
def CanKenKen(List,Start,Goal):
    Q=List[Start:Goal+1]
    return all([i=="." or Q[n+1]=="." or n==Goal-Start for n,i in enumerate(Q)])
N,A,B,C,D=map(int,input().split())
A,B,C,D=map(lambda x:x-1 ,[A,B,C,D])#0-indexed
S=list(input())

if A<C<B<D:
    if CanKenKen(S,A,C) and CanKenKen(S,B,D):
        print("Yes")
    else:print("No")
elif A<B<D<C:
    if CanKenKen(S,A,C):
        oikosi=0
        Q=S[B:D+1]
        for n,i in enumerate(Q):
            if i=="." and Q[n+1]=="." and Q[n+2]==".":
                oikosi=1
                break
            if n==D-B-2:break
        if oikosi:print("Yes")
        else:print("No")
    else:print("No")
elif A<B<C<D:
    if CanKenKen(S,A,D):print("Yes")
    else:print("No")

Submission status: Wrong Answer

Solution code:
temp = input()
temp2 = input()

N, A, B, C, D = [int(x) for x in temp.split()]
flag = True
before = -1
 
for x, xi in enumerate(temp2):
    if x<A:# 初めはいらない
        continue
    elif x>D:# 後半もいらない
        break
        
    if xi==".":
        continue
    elif x in [A, B, C, D]:
        flag = False
        break
    else:
        if x-before==1:
            flag = False
            break
        else:
            before = x
    
            
if flag:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
INPUT = input().split()
S = input()     # Nと同じ長さの文字列'.'と'#からなる。'

N = int(INPUT[0])    #マス目（文字列）の長さ
A = int(INPUT[1])    #すぬけ君の最初の位置
B = int(INPUT[2])    #ふぬけ君の最初の位置
C = int(INPUT[3])    #すぬけ君に最終的にいてほしい位置
D = int(INPUT[4])    #ふぬけ君に最終的にいてほしい位置

if "##" in S:
    print("No")
else:
    if C > D:
        if "..." in S:
            print("Yes")
        else:
            print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

Solution code:
s = list(input())[::-1] + [0,0]
N,i = len(s),0
ansl = []
while i < N:
    if s[i] == 'C' and s[i+1] == 'B':
        temp = [0]
        i += 2
        while i < N:
            if s[i] == 'A':
                temp += [1]
                i += 1
            elif s[i] == 'C' and s[i+1] == 'B':
                temp += [0]
                i += 2
            else:
                break
        ansl += [temp]
    else:   i += 1

ans = 0
for c in ansl:
    for i in range(len(c)-1):
        if c[i]==0:    ans += c[i+1:].count(1)

print(ans)

Submission status: Wrong Answer

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

count = [len(s) for s in S[:D+1].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())
A-=1
B-=1
C-=1
D-=1
S=input()
s=[0]*N
stop=[0]*N
space=[0]*N
for i in range(N):
    if S[i]=='#':
        s[i]=1
        if i>0 and s[i-1]==1:
            stop[i]=1
    elif i>1 and s[i-1]==0 and s[i-2]==0:
        space[i]=1
    if i>1:
        stop[i]+=stop[i-1]
        space[i]+=space[i-1]
if stop[C]-stop[A]>0 or stop[D]-stop[B]>0:
    ans=0
elif C<D:
    ans=1
elif space[D+1]-space[B+1]>0:
    ans=1
else:
    ans=0
print(['No','Yes'][ans])

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
 
S = input()
 
S = S + '###'
 
def continuous_rock_search(S):
    for i in range(len(S) - 1):
        if S[i] == '#' and S[i+1] == '#':
            return True
    return False
  
def validation_funuke_move(S, B, D):
    '''
    ふぬけ君が両隣に岩がなくなるまで移動したとき、Dより向こうにはイカないことを確認する。
    True/False and ふぬけの移動後の位置
    '''
    funuke_position = B
    while (B <= D):
        if (S[B-2] == '#' or S[B] == '#'):
            if S[B] == '.' :
                B = B + 1
            else:
                B = B + 2
        elif (S[B-2] == '.' and S[B] == '.'):
            return True, B
    
    return False, -1
  
def KenKenRace(S, A, B, C, D):
    if continuous_rock_search(S):
        return False
    
    if C < D:
        return True
    
    if D < C:
        valid , _ = validation_funuke_move(S, B, D)
        if valid:
            return True
        else:
            return False
          
if KenKenRace(S, A, B, C, D):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def check() :
    if '##' in S[A-1:max(C, D)] :
        return 'NO'

    if C < D or '...' in S[B-1:D] or S[B-2:B+1] == '...' :
        return 'YES'

    return 'NO'
        

print(check())

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:
    for i in range(B+1, D-1):
        if S[i]=='#' and S[i+1]=="#":
            print("No")
            exit(0)
    for i in range(A+1, B-1):
        if S[i]=='#' and S[i+1]=="#":
            print("No")
            exit(0)
    print("Yes")
else:
    flag=False
    for i in range(B+1, D-1):
        if S[i]=='#' and S[i+1]=="#":
            print("No")
            exit(0)
        if i<=D-3 or (i==D-2 and D+1<=N):
            if S[i]=='.' and S[i+1]=='.' and S[i+2]=='.':
                flag=True
    for i in range(A+1, C-1):
        if S[i]=='#' and S[i+1]=="#":
            print("No")
            exit(0)
    print("Yes" if flag else "No")

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)

def intinput(): return map(int,input().split())

def x(s):
    try:
        s.index("##")
    except:
        return True
    else:
        return False

n,a,b,c,d=intinput()
s=input()
if c<d:
    if x(s[a-1:d]):
        print("Yes")
    else:
        print("No")
else:
    try:
        s[a-1:c].index("...")
    except:
        print("No")
    else:
        if x(s[a - 1:c]):
            print("Yes")
        else:
            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(A - 1, D):
    if S[k] == '#' and S[k + 1] == '#':
        print('No')
        exit()

if C < D:
    print('Yes')
else:
    cnt = 0
    for k in range(A - 1, C):
        if S[k] == '.':
            cnt += 1
        else:
            cnt = 0
        if cnt > 2:
            print('Yes')
            exit()
    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 and "..." not in S[b-2:max(c,d)]:
  print('No')
else:
  print("Yes")

Submission status: Wrong Answer

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

ans = True
d = False
for i in range(B,D):
    if(S[i] == "#" and d):
        ans = False
    elif(S[i] == "#"):
        d = True
    else:
        d = False
d = False
for j in range(A,C):
    if(S[i] == "#" and d):
        ans = False
    elif(S[i] == "#"):
        d = True
    else:
        d = False
if(C>D):
    ans = S[B-1:D].count("...")!=0 or S[D-2]=="."

print("Yes" if ans else "No")

Submission status: Wrong Answer

Solution code:
#A問題
N,A,B,C,D = map(int,input().split())
Slist = list(str(input()))
if C < D:
    now = B-1
    Rock = 0
    flag = 0
    for i in range(D-B):
        I = i+now
        if i == 0:
            pass
        else:
            if Slist[I] == "#":
                Rock+=1
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0
    now = A-1
    Rock = 0
    for i in range(C-A):
        I = i+now
        if i == 0:
            pass
        else:
            if Slist[I] == "#":
                Rock+=1
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0

    if flag == 1:
        print("No")
    else:
        print("Yes")
    
else:
    now = B-1
    Rock = 0
    flag = 0
    for i in range(D-B):
        I = i+now
        if i == 0:
            pass
        else:
            if Slist[I] == "#":
                Rock+=1
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0
    now = A-1
    Rock = 0
    mass = 0
    Maxmass = 0
    aflag = 0
    for i in range(C-A):
        I = i+now
        if I == D-1:
            aflag = 1
    
        if i == 0:
            mass+=1
        else:
            if Slist[I] == "#":
                Rock+=1
                if aflag < 2:
                    Maxmass = max(Maxmass,mass)
                    if aflag == 1:
                        aflag = 2
                mass = 0
                if Rock == 2:
                    flag = 1
                    break
            else:
                Rock = 0
                mass+=1

    if Maxmass <= 2:
        flag = 1
    
    if flag == 1:
        print("No")
    else:
        print("Yes")

Submission status: Wrong Answer

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

if Sp.find('##') != -1:
    print('No')
    exit()

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

if Sp[B-1] == '.' and Sp[B+1] == '.':
    print('Yes')
    exit()

if Sp[B+1:B+3] == '..':
    print('Yes')
    exit()

if Sp[B+1:C].find('...') >= 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map( int, input().split())
S = input()
check = "Yes"
for i in range(A-1, B):
    if S[i] == "#" and S[i+1] == "#":
        check = "No"
        break
if check == "Yes":
    for i in range(C-1, D):
        if S[i] == "#" and S[i+1] == "#":
            check = "No"
            break    
if check == "Yes":
    if C < D:
        pass
    else:
        check = "No"
        A -= 1
        B -= 1
        C -= 1
        D -= 1
        t = 0
        for i in range(B-1, D+1):
            if S[i] == ".":
                if t <= 1:
                    t += 1
                elif t >= 2:
                    check = "Yes"
                    break
            else:
                t = 0
print(check)

Submission status: Wrong Answer

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

if not(S[A:C-1].find('##')!=-1 or S[B:D-1].find('##')!=-1):
  if C<D:
    print('Yes')
  elif S[B:D-1].find('...')!=-1:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Wrong Answer

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

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

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

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

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

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

Submission status: Wrong Answer

Solution code:
n,a,b,c,d=map(int,input().split())
s=input()
#ぬかさないケース
if s[a:d].find("##")==-1:
  if c<d:
    print("Yes")
  else:
    if s[b-1:d+1].find("...")==-1:
      print("No")
    else:
      print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
def solve():
	x_max = 0
	x_cnt = 0
	y_max = 0
	y_cnt = 0
	for i in range(N):
		if S[i:i+1]=='.':
			y_max = max(y_max, y_cnt)
			y_cnt = 0
			x_cnt += 1
		if S[i:i+1]=='#':
			x_max = max(x_max, x_cnt)
			x_cnt = 0
			y_cnt += 1

	if y_max>=2:
		print('No')
		return
	
	if C<D or x_max>=3:
		print('Yes')
	else:
		print('No')

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l():
	return list(map(int,input().split()))
def m():
	return map(int,input().split())
def s(x):
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x):
	return " ".join(map(str,x))

n,a,b,c,d = m();
ss = list(input())
if c < d:
	k = s(ss[b-1:d])
	for i in range(len(k)):
		if k[i][0] == "#" and k[i][1] >= 2:
			print("No")
			exit()
	k = s(ss[a-1:c])
	for i in range(len(k)):
		if k[i][0] == "#" and k[i][1] >= 2:
			print("No")
			exit()
	print("Yes")
	exit()
else:
	# c > d
	count = 0
	k = s(ss[b-1:d])
	for i in range(len(k)):
		if k[i][0] == "#" and k[i][1] >= 2:
			print("No")
			exit()
	ss[d-1] = "#"
	k = s(ss[a-1:c])
	for i in range(len(k)):
		if k[i][0] == "#" and k[i][1] >= 2:
			print("No")
			exit()
		if k[i][0] == "." and k[i][1] >= 3:
			print("Yes")
			exit()
	print("No")
	exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: int, B: int, C: int, D: int, S: str):
    if C < D:
        flag_d = False
        for i in range(A+1, D-1):
            if S[i:i+2] == '##':
                flag_d = True
                break

        #flag_c = False
        #for i in range(B+1, D-2):
        #    if S[i:i+3] == '...':
        #        flag_c = True
        #        break

        if flag_d:
            print(NO)
        else:
            print(YES)


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

        flag_c = False
        for i in range(A+1, C-2):
            if S[i:i+3] == '...':
                flag_c = True
                break

        if flag_d:
            print(NO)
        else:
            if flag_c:
                print(YES)
            else:
                print(NO)


    else:
        raise NotImplementedError





    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, A, B, C, D, S)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, A, B, C, D = map(int, input().split())
S = input()
# import re
import sys
# print(S.count("##"))
if S[min(A,B):max(C,D)-1].count("##"):
    print("No")
    sys.exit()
if (A < B) and (C > D):
    if not S[B:D-1].count("..."):
        print("No")
        sys.exit()
if (A > B) and (C < D):
    if not S[A:C-1].count("..."):
        print("No")
        sys.exit()
print("Yes")

Submission status: Wrong Answer

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

    
ans="Yes"
for i in range(1,n):
  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,c-2):
      if s[i]=="." and s[i+1]=="." and s[i+2]==".":
        ans="Yes"
    print(ans)

Submission status: Wrong Answer

Solution code:

import sys
sys.setrecursionlimit(100000000)

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

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

for i in range(len(s)):
    if i == len(s) - 1:
        continue
    else:
        if s[i] == '#' and s[i+1] == '#':
            print("No")
            exit()




def check(s, start, goal, ans):
    if start == goal:
        return 1
    if s[start] == '#':
        return 0
    if start + 1 <= N - 1:
        ans += check(s, start + 1, goal, ans)
    if start + 2 <= N - 1:
        ans += check(s, start + 2, goal, ans)
    return ans

ans = 0
if not check(s, B, D, ans):
    print("No")
    exit()
#s[D] = '#'
if not check(s, A, C, ans):
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

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

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

stone = 0
road = 0
c = False

for i in range(B + 1, D):
    if S[i] == '#':
        stone += 1
        road = 0
        if stone > 1:
            print("No")
            exit()
    else:
        road += 1
        stone = 0
        if road > 2:
            c = True

stone = 0
road = 0

if c:
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                print("No")
                exit()
        else:
            road += 1
            stone = 0
else:
    check = False
    tmp = S[B]
    S[B] = '#'
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                check = True
                break
        else:
            road += 1
            stone = 0
    stone = 0
    road = 0
    S[B] = tmp
    S[D] = '#'
    for i in range(A + 1, C):
        if S[i] == '#':
            stone += 1
            road = 0
            if stone > 1:
                if check:
                    print("No")
                    exit()
        else:
            road += 1
            stone = 0

print("Yes")

Submission status: Wrong Answer

Solution code:
def main():
    inp = input()
    st = inp.split()
    n = int(st[0])
    a = int(st[1])
    b = int(st[2])
    c = int(st[3])
    d = int(st[4])
    inp = input()
    # 2 rocks
    rock_count = 0
    for i in range(a, b):
        if inp[i] == '#':
            rock_count += 1
        elif inp[i] == '.':
            rock_count = 0
        if rock_count == 2:
            print("No")
            return

    max_cd = c if c > d else d
    continuous_count = 0
    nothing_count = 0
    nothing_3 = False
    if inp[b-1] == '.':
        nothing_count += 1
    for i in range(b, max_cd):
        if inp[i] == '#':
            continuous_count += 1
            nothing_count = 0
        elif inp[i] == '.':
            continuous_count = 0
            nothing_count += 1
        if continuous_count == 2:
            print("No")
            return
        if nothing_count == 3 and i < d + 1:
            nothing_3 = True

    # c < d
    if c < d or nothing_3:
        print("Yes")
    else:
        print("No")
    return


if __name__ == '__main__':
    main()

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