Problem p02903 (python)

Fixed submission:
h,w,a,b=map(int,input().split())

lista=[]

for i in range(h):
    lista.append([0]*w)

if (a>w/2)|(b>h/2):
    print("No")

else:
    if h==1:
        for i in range(w-a):
            lista[0][a+i]=1
    elif w==1:
        for i in range(h-b):
            lista[b+i][0]=1

    elif (a==0)&(b==0):
        lista=lista

    else:  
        for i in range(w-a):
            lista[0][a+i]=1
        
           
        if a==0:    
            for i in range(w):
                for j in range(b):
                    lista[j][i]=1 
        elif b==0:    
            for i in range(h):
                for j in range(w-a):
                    lista[i][j+a]=1                         
        else:    
            for i in range(a):
                for j in range(h-b):
                    lista[b+j][i]=1 
            for i in range(b):
                for j in range(w-a):
                    lista[i][a+j]=1


 

    for i in range(h):
        row = ""
        for j in range(w):
            row += str(lista[i][j])
        print(row)

Buggy submission (verdict: Runtime Error):
h,w,a,b=map(int,input().split())

tmp=[0]*w
lista=[]
for i in range(h):
    lista.append([0]*w)
    
if a>w/2 or b>h/2:
    print("No")

elif h==1:
    for i in range(w-a):
        lista[0][a+i]=1
elif w==1:
    for i in range(h-b):
                lista[b+i][0]=1
if a==0 & b==0:
    lista=lista
        
else:  
    for i in range(w-a):
        lista[0][a+i]=1
    
    print(lista)
    if a==0:    
        for i in range(w):
            for j in range(b):
                lista[j][i]=1 

    if b!=0:    
        for i in range(a):
            for j in range(h-b):
                lista[b+j][i]=1 
        for i in range(b):
            for i in range(w-a):
                lista[i][a+j]=1




for i in range(h):
    row = ""
    for j in range(w):
        row += str(lista[i][j])
    print(row)

Buggy submission (verdict: Runtime Error):
h,w,a,b=map(int,input().split())

tmp=[0]*w
lista=[]
for i in range(h):
    lista.append([0]*w)
    
if a>w/2 or b>h/2:
    print("No")

elif h==1:
    for i in range(w-a):
        lista[0][a+i]=1
elif w==1:
    for i in range(h-b):
                lista[b+i][0]=1
else:  
    for i in range(w-a):
        lista[0][a+i]=1
        
    if a==0:    
        for i in range(w):
            for j in range(b):
                lista[j][i]=1 

    if b!=0:    
        for i in range(a):
            for j in range(h-b):
                lista[b+j][i]=1 
        for i in range(b):
            for i in range(w-a):
                lista[i][a+j]=1




for i in range(h):
    row = ""
    for j in range(w):
        row += str(lista[i][j])
    print(row)

Buggy submission (verdict: Runtime Error):
h,w,a,b=map(int,input().split())

tmp=[0]*w
lista=[]
for i in range(h):
    lista.append([0]*w)
    
if a>w/2 or b>h/2:
    print("No")

elif h==1:
    for i in range(w-a):
        lista[0][a+i]=1
elif w==1:
    for i in range(h-b):
                lista[b+i][0]=1
else:  
    for i in range(w-a):
        lista[0][a+i]=1
        
    print(lista)
    if a==0:    
        for i in range(w):
            for j in range(b):
                lista[j][i]=1 

    if b!=0:    
        for i in range(a):
            for j in range(h-b):
                lista[b+j][i]=1 
        for i in range(b):
            for i in range(w-a):
                lista[i][a+j]=1




for i in range(h):
    row = ""
    for j in range(w):
        row += str(lista[i][j])
    print(row)

Buggy submission (verdict: Runtime Error):
h,w,a,b=map(int,input().split())

tmp=[0]*w
lista=[]
for i in range(h):
    lista.append([0]*w)
    
if a>w/2 or b>h/2:
    print("No")

elif h==1:
    for i in range(w-a):
        lista[0][a+i]=1
elif w==1:
    for i in range(h-b):
                lista[b+i][0]=1
else:  
    for i in range(w-a):
        lista[0][a+i]=1
      
     for i in range(a):
        for j in range(h-b):
            lista[b+j][i]=1 
    for i in range(b):
        for i in range(w-a):
            lista[i][a+j]=1




for i in range(h):
    row = ""
    for j in range(w):
        row += str(lista[i][j])
    print(row)

Buggy submission (verdict: Runtime Error):
h,w,a,b=map(int,input().split())

tmp=[0]*w
lista=[]
for i in range(h):
    lista.append([0]*w)
    
if a>w/2 or b>h/2:
    print("No")

elif h==1:
    for i in range(w-a):
        lista[0][a+i]=1
elif w==1:
    for i in range(h-b):
                lista[b+i][0]=1
else:  
    for i in range(w-a):
        lista[0][a+i]=1
    if b!=0:    
        for i in range(a):
            for j in range(h-b):
                lista[b+j][i]=1 
        for i in range(b):
            for i in range(w-a):
                lista[i][a+j]=1




for i in range(h):
    row = ""
    for j in range(w):
        row += str(lista[i][j])
    print(row)

Buggy submission (verdict: Runtime Error):
h,w,a,b=map(int,input().split())

tmp=[0]*w
lista=[]
for i in range(h):
    lista.append([0]*w)
    
if a>w/2 or b>h/2:
    print("No")

elif h==1:
    for i in range(w-a):
        lista[0][a+i]=1
elif w==1:
    for i in range(h-b):
                lista[b+i][0]=1
else:  
    for i in range(w-a):
        lista[0][a+i]=1
    if b!=0:    
        for i in range(a):
            for j in range(h-b):
                lista[b+j][i]=1 
        for i in range(b):
            for i in range(w-a):
                lista[i][a+j]=1


print(lista)

Buggy submission (verdict: Runtime Error):
h,w,a,b=map(int,input().split())

tmp=[0]*w
lista=[]
for i in range(h):
    lista.append([0]*w)
    
if a>w/2 or b>h/2:
    print("No")

elif h==1:
    for i in range(w-a):
        lista[0][a+i]=1
elif w==1:
    for i in range(h-b):
                lista[b+i][0]=1
else:  
    for i in range(w-a):
        lista[0][a+i]=1
    print(lista)
    if b!=0:    
        for i in range(a):
            for j in range(h-b):
                lista[b+j][i]=1
        print(lista)  
        for i in range(b):
            for i in range(w-a):
                lista[i][a+j]=1


print(lista)