Problem p03017 (python)

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

main()

Buggy submission (verdict: Runtime Error):
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]=='#':
                raise NameError
                break
            if s[i]=='.':
                tmp +=1
            else:
                if cnt < tmp:
                    cnt = tmp
                    tmp =0

        if max(cnt,tmp) < 3:
                raise NameError
        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-1):
            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()

Buggy submission (verdict: Runtime Error):
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:
                raise NameError
        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-1):
            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()

Buggy submission (verdict: Runtime Error):
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:
                return raise(NameError)
        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-1):
            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()