Problem p02614 (python)

Fixed submission:
import numpy as np
import copy

H, W, K = map(int, input().split())
if H == 1:
    d = list(map(str, input().split()))
    X = list(d[0])
    black = 0
    for i in range(W):
        if X[i] == "#":
            black += 1

    t = 0
    s = "0" + str(W) + "b"

    #消すバージョン
    if K == 0:
        t += 2**W

    #消さない
    for i in range(2**W):
        black_xx = black
        WW = format(i, s)
        for j in range(W):
            if WW[j] == "1" and X[j] == "#":
                black_xx -= 1
        if black_xx == K:
            t += 1

    print(t)

elif W == 1:
    X = []
    for i in range(H):
        X.append(input())
    black = 0
    for i in range(H):
        if X[i] == "#":
            black += 1

    t = 0
    s = "0" + str(H) + "b"

    #消すバージョン
    if K == 0:
        t += 2**H

    #消さない
    for i in range(2**H):
        black_xx = black
        HH = format(i, s)
        for j in range(H):
            if HH[j] == "1" and X[j] == "#":
                black_xx -= 1
        if black_xx == K:
            t += 1

    print(t)



else:
    d = list(map(str, input().split()))
    X = list(d[0])
    for i in range(H - 1):
        d = list(map(str, input().split()))
        d = list(d[0])
        X = np.vstack((X, d))

    black = 0
    for i in range(X.shape[0]):
        for j in range(X.shape[1]):
            if X[i,j] == "#":
                black += 1

    t = 0
    s1 = "0" + str(H) + "b"
    s2 = "0" + str(W) + "b"
    for i in range(2**H):
        for j in range(2**W):

            XX = copy.copy(X)
            black_xx = black
            HH = format(i, s1)
            WW = format(j, s2)

            for ii in range(H):
                if HH[ii] == "1":
                    for iii in range(W):
                        if XX[ii,iii] == "#":
                            black_xx -= 1
                            XX[ii,iii] = "."
            for jj in range(W):
                if WW[jj] == "1":
                    for jjj in range(H):
                        if XX[jjj,jj] == "#":
                            black_xx -= 1
                            XX[jjj,jj] = "."
            if black_xx == K:
                t += 1

    print(t)

Buggy submission (verdict: Runtime Error):
import numpy as np
import copy

H, W, K = map(int, input().split())
if H == 1:
    print("A")
elif W = 1:
    print("B")
else:
    d = list(map(str, input().split()))
    X = list(d[0])
    for i in range(H - 1):
        d = list(map(str, input().split()))
        d = list(d[0])
        X = np.vstack((X, d))

    black = 0
    for i in range(X.shape[0]):
        for j in range(X.shape[1]):
            if X[i,j] == "#":
                black += 1

    t = 0
    s1 = "0" + str(H) + "b"
    s2 = "0" + str(W) + "b"
    for i in range(2**H):
        for j in range(2**W):

            XX = copy.copy(X)
            black_xx = black
            HH = format(i, s1)
            WW = format(j, s2)

            for ii in range(H):
                if HH[ii] == "1":
                    for iii in range(W):
                        if XX[ii,iii] == "#":
                            black_xx -= 1
                            XX[ii,iii] = "."
            for jj in range(W):
                if WW[jj] == "1":
                    for jjj in range(H):
                        if XX[jjj,jj] == "#":
                            black_xx -= 1
                            XX[jjj,jj] = "."
            if black_xx == K:
                t += 1

    print(t)

Buggy submission (verdict: Runtime Error):
import numpy as np
import copy

H, W, K = map(int, input().split())
d = list(map(str, input().split()))
X = list(d[0])
for i in range(H - 1):
    d = list(map(str, input().split()))
    d = list(d[0])
    X = np.vstack((X, d))

black = 0
for i in range(X.shape[0]):
    for j in range(X.shape[1]):
        if X[i,j] == "#":
            black += 1

t = 0
s1 = "0" + str(H) + "b"
s2 = "0" + str(W) + "b"
for i in range(2**H):
    for j in range(2**W):
        XX = copy.copy(X)
        black_xx = black
        HH = format(i, s1)
        WW = format(j, s2)

        # 行を消す
        for ii in range(H):
            if HH[ii] == "1":
                for iii in range(W):
                    if XX[ii,iii] == "#":
                        black_xx -= 1
                        XX[ii,iii] = "."
        # 列を消す
        for jj in range(W):
            if WW[jj] == "1":
                for jjj in range(H):
                    if XX[jjj,jj] == "#":
                        black_xx -= 1
                        XX[jjj,jj] = "."
        if black_xx == K:
            t += 1

print(t)