Problem: 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.

Submission attempts (in order):
#!/usr/bin/env python
 
import sys
import re
 
_,a,b,c,d = [ int(x)-1 for x in sys.stdin.readline().split() ]
m = sys.stdin.readline().strip()
#
if c>d:
    if m[b-1:d+2].find("...")<0:
        print( "No" )
        exit()
else:
    # b -> d
    if m[b+1:d].find("##")<0:
        print( "No" )
        exit()
    #
    # a -> c
    if m[a+1:c].find("##")<0:
        print( "No" )
        exit()

print( "Yes" )


#!/usr/bin/env python

import sys
import re

_,a,b,c,d = [ int(x)-1 for x in sys.stdin.readline().split() ]
m = sys.stdin.readline().strip()
if m[c]!="." or m[d]!=".":
    print( "NO" )
    exit()
#
loc= []
for match in re.finditer( "##",m ): loc.append( match.start() )
if c>d:
    if m[b+1:d+1].find("..")<0:
        print( "NO" )
        exit()
#

flag= False
ii= b+1
jj= d-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
if flag:
    print( "NO" )
    exit()
#

ii= a+1
jj= c-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
#
if flag:
    print( "NO" )
    exit()
#
print( "YES" )


#!/usr/bin/env python

import sys
import re

_,a,b,c,d = [ int(x)-1 for x in sys.stdin.readline().split() ]
m = sys.stdin.readline().strip()
#
loc= []
for match in re.finditer( "##",m ): loc.append( match.start() )
if c>d:
    if m[b-1:b+2]!="..." and m[b+1:d+1].find("..")<0:
        print( "NO" )
        exit()
#

flag= False
ii= b+1
jj= d-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
if flag:
    print( "NO" )
    exit()
#

ii= a+1
jj= c-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
#
if flag:
    print( "NO" )
    exit()
#
print( "YES" )


#!/usr/bin/env python

import sys
import re

s= sys.stdin.readline().strip()
s= s.replace("BC","D")
s= re.sub("[BC]+"," ",s).split()

t= 0
for seg in s:
    while True:
        i=seg.find("D")
        if i<=0: break
        a= len(seg[:i])
        if a==0: continue
        #
        d= 1
        for j in range(i+1,len(seg)):
            if seg[j]!="D": break
            d+= 1
        t+= a*d
        seg= ("A"*a) + seg[i+d:]
#
print( t )


#!/usr/bin/env python
 
import sys
import re
 
_,a,b,c,d = [ int(x)-1 for x in sys.stdin.readline().split() ]
m = sys.stdin.readline().strip()
#
if c>d:
    if m[b-1:d+2].find("...")<0:
        print( "No" )
        exit()
else:
    # b -> d
    if m[b+1:d].find("##")>=0:
        print( "No" )
        exit()
    #
    # a -> c
    if m[a+1:c].find("##")>=0:
        print( "No" )
        exit()

print( "Yes" )


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Wrong Answer

Accepted