Problem p03017 (python)

Fixed submission:
n, a, b, c ,d = map(int, input().split())
s = input()[:max(c,d)]
 
def main():
    if "##" in s[b:d-2]:
        return "No"
    if "##" in s[a:c-2]:
        return "No"
 
    if c < d:
        return "Yes"
    
    else:
 
        if "..." in s[b-2:d+1]:
            return "Yes"
                
        return "No"
 
print(main())

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int, input().split())
s=input()
v=0
x=0
for i in range(n-2):
    if c<d:
        if i>b and i<d and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break
        elif c>d:
        if  i>=b-1 and i<d+1 and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.' :
            x=1
            break
if x==0 and c>d:
    print('No')
if x==1:
    for i in range(n-2):
        if i>b and i<c and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break
    if v==0 and x==1:
        print('Yes')
if c<d and v==0:
    print('Yes')

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int, input().split())
s=input()
v=0
x=0
for i in range(n-2):
    if c<d:
        if i>b and i<d and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break
 
    
    elif c>d:
        if  i>=b-1 and i<d+1 and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.' :
            x=1
            break
if x==0:
    print('No')
            
if x==1:
    for i in range(n-2):
        if i>b and i<c and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break
    if v==0:
        print('Yes')
if c<d and v==0:
    print('Yes')
n,a,b,c,d=map(int, input().split())
s=input()
v=0
x=0
for i in range(n-2):
    if c<d:
        if i>b and i<d and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break

    
    elif c>d:
        if  i>=b-1 and i<d+1 and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.' :
            x=1
            break
if x==0 and c>d:
    print('No')
            
if x==1:
    for i in range(n-2):
        if i>b and i<c and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break
    if v==0 and x==1:
        print('Yes')
if c<d and v==0:
    print('Yes')

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int, input().split())
s=input()
v=0
x=0
for i in range(n-2):
    if c<d:
        if i>b and i<d and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break

    
    elif c>d:
        if  i>=b-1 and i<d+1 and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.' :
            x=1
            break
if c>d and x==0:
    print('No')
            
if x==1:
    for i in range(n-2):
        if i>b and i<c and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break
    if v==0:

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int, input().split())
s=input()
v=0
for i in range(n-2):
    if c<d:
        if i>a and i<d and s[i]=='#' and s[i+1]=='#':
            print('No')
            v+=1
            break

    
    elif c>d:
        if i>b and i<c and s[i]=='#' and s[i+1]=='#':
            v+=1
            print('No')
            break
        
        
if c<d and v==0:
    print('Yes')
    
if v==0 and c>d and i>=b-1 and i<d+1 and s[i]=='.' and  s[i+1]=='.' and s[i+2]=='.':
    print('Yes')
        break
if V==0:
    print('No')