Problem:


Score : 300 points

Problem Statement

We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.

Consider doing the following operation:

Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.

You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.

Constraints

1 \leq H, W \leq 6

1 \leq K \leq HW

c_{i,j} is . or #.

Input

Input is given from Standard Input in the following format:

H W K
c_{1,1}c_{1,2}...c_{1,W}
c_{2,1}c_{2,2}...c_{2,W}
:
c_{H,1}c_{H,2}...c_{H,W}

Output

Print an integer representing the number of choices of rows and columns satisfying the condition.

Sample Input 1

2 3 2
..#
###

Sample Output 1

5

Five choices below satisfy the condition.

The 1-st row and 1-st column

The 1-st row and 2-nd column

The 1-st row and 3-rd column

The 1-st and 2-nd column

The 3-rd column

Sample Input 2

2 3 4
..#
###

Sample Output 2

1

One choice, which is choosing nothing, satisfies the condition.

Sample Input 3

2 2 3
##
##

Sample Output 3

0

Sample Input 4

6 6 8
..##..
.#..#.
#....#
######
#....#
#....#

Sample Output 4

208



Sample input:
2 3 2
..#
###


Sample output:
5

Submission status: Runtime Error

Solution code:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    j -= 1
  ans = max(ans, i + j)
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

h,w,k=map(int,input().split())
a=[input() for _ in range(h)]
b=[]
for i in a:
    b+=[[1 if j=="#" else 0 for j in i]]
c=np.array(b)
print(c)
ans=0
for i in range(2**(h*w)):
    for j in range(h*w):
        d=c.copy()
        if ((i>>j)&1):
            if j<=h:
                d[j]=0
            else:
                d[:,j-h]=0
        if np.sum(d)==k:
            ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
import itertools

h, w, k = map(int,input().split())
c = []
h_list = []
h_del = []#各列で#を消せる数
w_list = []

sharp = 0
count = 0
for i in range(h):
  cc = list(input())
  sharp = sharp + cc.count('#')
  c.append(cc)

if k > sharp:
  print(0)
  exit()

#消える数、位置
for i in range(h):
  buf = []
  buf.append(c[i].count('#'))
  h_del.append(buf[0])
  buf.append([j for j, x in enumerate(c[i]) if x == '#'])
  h_list.append(buf)

#＃がない列の数
non_s = 0
for i in range(w):
  w_h = []
  for j in range(h):
    w_h.append(c[j][i])
  if w_h.count('#') == 0:
    non_s = non_s + 1

h_num_list = []
for i in range(h):
  h_num_list.append(i)
w_num_list = []
for i in range(h):
  w_num_list.append(i)

dot_block = []#差し替え用配列
for i in range(w):
  dot_block.append(".")
  
#横だけまず全通り消してみる
for i in range(h):#選ぶ列の数
  for x in itertools.combinations(h_num_list, i+1):#列の選び型
    should_del = sharp -k
    buf_c = c#配列をコピー
    del_num = 0
    for a in x:#実際に消す
      del_num = del_num + h_del[a]
      buf_c[a] = dot_block
    if del_num == should_del:
      count = count + 1 + non_s
      continue
    elif del_num > should_del:
      continue
    should_del = should_del - del_num
    
    w_del = []#各行で＃を消せる数
    #縦も消し始める
    for f in range(w):
      w_h = []
      for g in range(h):
        w_h.append(buf_c[g][f])
      w_del.append(w_h.count('#'))
      for y in itertools.combinations(w_num_list, f+1):#列の選び型
        
        del__num = 0
        for b in y:#実際に消す
          del__num = del__num + w_del[b]
        if del_num == should_del:
          count = count + 1
          continue
        elif del_num > should_del:
          continue

        
        
        
        
print(count)

Submission status: Runtime Error

Solution code:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
    
ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

h, w, k = map(int, readline().split())
A = [list(input()) for i in range(h)]
arr_A = np.array(A)


##それぞれの行列にある黒の数
changed = np.where(arr_A=='.',0,1)

##合計 print(np.sum(changed)) 

tate = np.sum(changed, axis=0)##たてごと
yoko = np.sum(changed, axis=1)##横ごと

pare = []
pare.extend(tate)
pare.extend(yoko)


##組み合わせを作る

import itertools
for a, _ in enumerate(pare, 1):    
    for b in itertools.permutations(pare, r=a):  # rには1、2、3と渡される
      

ans = 0
if sum(b) =< k:
  ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
H,W,K = [int(a) for a in input().split()]
color = []
for h in range(H):
  color.append(input())
cnt = 0
for i in range(W+1):
  for j in range(H+1):
    tmp = 0
    for k in range(W+1):
      for l in range(H+1):
        if color[k][j] == '#':
          tmp+=1
    if tmp==K: cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
import numpy as np
H,W,K = map(int,input().split())
c = [input().split() for l in range(H)]

def count_mat():
  c1 = c.count("#")
  return c1
 
num = 0
while c1 > K:
  for i in range(H)
  for j in range(W)
  c = np.delete(c, i, j)
  num += 1
  
  print(num)

Submission status: Runtime Error

Solution code:
from copy import deepcopy
from itertools import chain
def main():
    h,w,k=map(int,input().split())
    C=[]
    Copy=[]
    for i in range(h):
        C.append(list(input()))
    hw=3600
    jh=0
    al=[]
    for i in range(hw):
        Copy=deepcopy(C)
        for j in range(len(str(bin(i)))-2):
            if (i>>j)&1:
                if j>h-1:
                    jh=j-h
                    for K in range(h):
                        Copy[K][jh]="%"
                else:
                    for K in range(w):
                        Copy[j][K]="%"
        al.append("".join(list(chain.from_iterable(Copy))))
    xx=list(set(al))
    c=0
    for i in range(len(xx)):
        if xx[i].count("#")==k:
            c+=1
    print(c)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import itertools

def row_red(R,FR):
    if not FR:
        return R
    for fr in FR:
        R[fr] = [[0]*len(R[fr])]
    return R

def col_red(R,FC):
    if not FR:
        return R
    for fc in FC:
        for h in range(len(R)):
            print(h)
            R[h][fc] = 0
    return R

def comb(item):
    A = []
    n = len(item)
    for i in range(2 ** n):
        bag = []
        for j in range(n):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                bag.append(item[j])  # フラグが立っていたら bag に果物を詰める
        A.append(bag)
    return A
H,W,K = [int(x) for x in input().split()]
r = [[0]*W for i in range(H)]
for i in range(H):
    row = input()
    for j,k in zip(list(row),range(W)):
        if j == "#":
            r[i][k] = 1
        else:
            pass

Row = comb(range(H))
Col = comb(range(W))
count = 0

for x in Row:
    tmp = row_red(r,x)
    for y in Col:
        tmp2 = col_red(tmp,y)
        if sum(tmp2) == K:
            count += 1

print(count)

Submission status: Runtime Error

Solution code:

import itertools

hv = ["..#", "###", ".#."]

num_row, num_column, black_threshold = map(int, input().split())

accept_counter = 0

for i in range(len(hv)):
    if i == 0:
        pass
    elif i < len(hv):
        print("calc combnations ...")
        n_hvs = list(itertools.combinations(hv, i))
        for loc_n_hv in n_hvs:
            black_counter = 0
            for row in loc_n_hv:
                black_counter += row.count('#')
            if black_counter == black_threshold:
                accept_counter += 1
            if black_counter >= black_threshold:
                fill_column_and_count_black(loc_n_hv)

print(accept_counter)



def fill_column_and_count_black(hv):
    global accept_counter
    for index in num_row:
        black_counter = 0
        for row in hv:
            n_row = row[0:index] + row[index+1:]
            black_counter += n_row.count('#')
        if black_counter == black_threshold:
            accept_counter += 1

Submission status: Runtime Error

Solution code:
import sys
from itertools import combinations
#DEBUG = True
DEBUG = False
if DEBUG:
    f=open("202007_1st/C_input.txt")
else:
    f=sys.stdin
WHITE='.'
BLACK='#'
def count_black(H_index,W_index):
    count_tmp=0
    for H_entries in H_index:
        for _ in H_entries:
            if _==H_index:
                continue
            for W_entries in W_index:
                for __ in W_entries:
                    if __==W_index:
                        continue
                if S[_][__]==BLACK:
                    count_tmp+=1
    return count_tmp
ans=0
H,W,K=map(int,f.readline().split())
S=[f.readline().strip() for _ in range(H)]
H_indices=[_ for _ in range(0,H)]
W_indices=[_ for _ in range(0,W)]
combi_list_H=[(-1)]
combi_list_W=[(-1)]
for _ in range(1,H):
    combi_list_H.extend(list(combinations(H_indices,_)))
for _ in range(1,W):
    combi_list_W.extend(list(combinations(W_indices,_)))
for _ in combi_list_H:
    for __ in combi_list_W:
        if count_black(_,__)==5:
            ans+=1
print(ans)
f.close()

Submission status: Runtime Error

Solution code:
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

h, w, k = map(int, readline().split())
A = [list(input()) for i in range(h)]
arr_A = np.array(A)


##それぞれの行列にある黒の数
changed = np.where(arr_A=='.',0,1)
print(changed)

##合計 print(np.sum(changed)) 

tate = np.sum(changed, axis=0)##たてごと
yoko = np.sum(changed, axis=1)##横ごと

pare = []
pare.extend(tate)
pare.extend(yoko)

print(pare)
##組み合わせを作る

import itertools
for a, _ in enumerate(pare, 1):    
    for b in itertools.permutations(pare, r=a):  # rには1、2、3と渡される
        print(b)

ans = 0
if sum(b) =< k:
  ans += 1
  
  
print(ans)

Submission status: Runtime Error

Solution code:
H,W,K=map(int,input().split())
info=[]
hinfo=[]
for i in range(H):
  l=input()
  c=collections.Counter(l)
  hinfo.append(c["#"])
  info.append(l)
vinfo=[]
for i in range(W):
  count=0
  for j in range(H):
    if info[j][i]=="#":
      count+=1
  vinfo.append(count)
S=sum(hinfo)
D=S-K
if D==0:
  print(1)
  exit()
else:
  #行のみ
  count=0
  for i in range(H):
    for j in range(i,H):
      s=sum(hinfo[i:j+1])
      if s>D:
        break
      elif s==D:
        count+=1
  #列のみ
  for i in range(W):
    for j in range(i,W):
      s=sum(vinfo[i:j+1])
      if s>D:
        break
      elif s==D:
        count+=1
  #行と列
  for i_1 in range(H):
    for j_1 in range(i,H):
      for i_2 in range(W):
        for j_2 in range(i,W):
          s=sum(hinfo[i_1:j_1+1])+sum(vinfo[i_2:j_2+1])-(j_1-i_1)*(j_2-i_2)
          if s>D:
            break
          elif s==D:
            count+=1
print(count)

Submission status: Runtime Error

Solution code:
h, w, k = map(int, input().split())
hw = []
for i in range(h):
    hw.append(list(map(str, input().split())))

def check(hw, h, w):
    s = 0
    for i in range(h):
        for j in range(w):
            if hw[i][0][j] == '#':
                s += 1
    return s

hl = []
for i in range(2**h):
    num = list(format(i, 'b'))
    p = []
    if len(num) < h:
        p = ['0' for j in range(h - len(num))]
    hl.append(p + num)

wl = []
for i in range(2**w):
    num = list(format(i, 'b'))
    p = []
    if len(num) < w:
        p = ['0' for j in range(w - len(num))]
    wl.append(p + num)

s = 0
for i in range(len(hl)):
    for j in range(len(wl)):
        cp = hw.copy()
        for m in range(h):
            for l in range(w):
                if (hl[l] == '1') | (wl[m] == '1'):
                    cp[m][l] == 'r'
        r = check(cp, h, w)
        if r == k:
            s += 1

print(s)

Submission status: Runtime Error

Solution code:
h,v,k = map(int,input().split())
ini_state = [list(input()) for i in range(h)] 
state = [i for i in ini_state]
other = [['.', '.', '#'], ['#', '#', '#']]

count = 0
for r in range(h):
  for c in range(v):
    nr, nc = r, c
    for j in range(v):
      state[nr][j] = "r"
    for i in range(h):
      state[i][nc] = "r"
    ini = "".join(str(num) for sta in state for num in sta)
    state.clear()
    state =  [['.', '.', '#'], ['#', '#', '#']]
    if ini.count("#") == k:
      count += 1
  state = [['.', '.', '#'], ['#', '#', '#']]
print(count+2)

Submission status: Runtime Error

Solution code:
import copy
h,w,k=map(int,input().split())
la=[]
res=0
for i in range(h):
    li=[]
    a=input()
    for i in range(w):
        if a[i]==".":li+=[0]
        else:li+=[1]
    la+=[li]
for i in range(h):
    li=copy.copy(la)
    li[i]=[0]*w
    for j in range(w):
        for l in range(0,h):
            lu = copy.copy(li)
            lu[l][j]=0
        if sum(lu)==2:res+=1
print(res)

Submission status: Runtime Error

Solution code:
import sys
import copy
import numpy as np
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline

if __name__ == '__main__':
#  cnt=0
  def dfs(C,t,hw,i):
    global k
    global h
    global w
    #print(t,k)
    #print(C)
    if t==k:
      return 1
    elif t<k:
      return 0
    if hw=='w' and i==w:
      return 0
    C1=copy.copy(C)
    C2=copy.copy(C)
    if hw=='h':
      #print(i,C1,np.zeros((1,w)))
      C1[i]=np.zeros((1,w))
      #print(C1)
      #exit(0)
      hw='w' if i==h-1 else 'h'
      i=0 if hw=='w' else i+1
      return dfs(C1,np.sum(C1),hw,i)+dfs(C2,np.sum(C2),hw,i)
    else:
      #print(C1)
      #C1[:][i]=np.zeros((h,1))
      for j in range(h):
        #tmp=C1[j]
        C1[j][i]=0
      #print(C1)
      #exit(0)
      i+=1
      return dfs(C1,np.sum(C1),hw,i)+dfs(C2,np.sum(C2),hw,i)

#  C=[[0 for _ in range(6)] for _ in range(6)]
  h,w,k=map(int,input().strip("\n").split())
  C=np.zeros((h,w))
  #print(C)
  for i in range(h):
    s=[1 if c=='#' else 0 for c in input().strip("\n")]
    #print(s)
    C[i]=np.array(s)
  #sprint(np.sum(C))
  print(dfs(copy.copy(C),np.sum(C),'h',0))

Submission status: Runtime Error

Solution code:
import numpy as np

h,w,k = map(int, input().split()) 
str_list = [list(input().split()) for _ in range(h)]

str_arr = np.array(str_list)

bl = str_list.count('#')

n = k - bl

t = 0
def cases(str_arr):
    for i in range(h):
        for j in range(w):
            str_arr[j]=[0] * h
            str_arr[i,:]=[0] * w
            
            if np.count_nonzero(str_arr) == k:
                t += 1
                str_arr = np.array(str_list)
            else:
                str_arr = np.array(str_list)
        

if n == 0:
    print(1)

else:
    print(cases(str_arr))

Submission status: Runtime Error

Solution code:
H,W,K = map(int,input().split())
C = [0]*H

for i in range(H):
    C[i] = list(str(input()))
    

    
def gyotsubushi(n,E):
    if I[n] == 1:
        E[n] = ['R']*W
        #print('GYO')
        
def retsutsubushi(n,E):
    if J[n] == 1:
        for i in range(H):
            E[i][n] = 'R'
            
def ango(lis):
    num = 1
    summ = 0
    for i in range(H+W):
        summ += lis[i]*num
        num *= 2
    return(summ)
    
            
stock = []
counter = 0
import copy
for i0 in range(2):
    for i1 in range(2):
        for i2 in range(2):
            for i3 in range(2):
                for i4 in range(2):
                    for i5 in range(2):
                        for j0 in range(2):
                            for j1 in range(2):
                                for j2 in range(2):
                                    for j3 in range(2):
                                        for j4 in range(2):
                                            for j5 in range(2):
                                                preI = [i0,i1,i2,i3,i4,i5]
                                                preJ = [j0,j1,j2,j3,j4,j5]
                                                I = preI[0:H]
                                                J = preJ[0:W]
                                                
                                                if I+j in stock:
                                                    break
                                                stock.append(I+J)
                                                D = copy.deepcopy(C)
                                                
                                                for i in range(H):
                                                    gyotsubushi(i,D)
                                                for j in range(W):
                                                    retsutsubushi(j,D)
                                               
                                                count = 0
                                                for i in range(H):
                                                    for j in range(W):
                                                        if D[i][j] == '#':
                                                            count += 1
                                                            
                                                if count == K:
                                                    counter += 1

    
print(counter)

Submission status: Runtime Error

Solution code:
h,w,k = map(int, input().split())
c = [list(input()) for _ in range(h)]
kaito = 0

def kako(a,b):
    global h,w
    d = [0]*(h - len(a))
    e = [0]*(w - len(b))
    d.append(a)
    e.append(b)
    a = d
    b =e

def hantei(a,b):
    global k,kaito,h,w
    ans = 0
    for i in range(h):
        for j in range(w):
            if a[i] == '1' and b[j] == '1' and c[i][j] == '#':
                ans += 1
    if ans == k:
        kaito += 1
    

for i in range(2**h):
    for j in range(2**w):
        a = list(bin(i))
        b = list(bin(j))
        a = a[2:]
        b = b[2:]
        kako(a,b)
        hantei(a,b)

print(kaito)

Submission status: Runtime Error

Solution code:
#!/usr/bin/python
# -*- Coding: utf-8 -*-

from collections import Counter

h, w, k = (int(x) for x in input().split())
grid = []

for _ in range(h):
    a = [x for x in input()]
    grid.append(a)

gridstr = str(grid)
count = Counter(gridstr)
numb = count['#']
numw = count['.']

if numb < k:
    print(0)
elif numb = k:
    print(1)
else:
    print(w)

Submission status: Runtime Error

Solution code:
h,w,k=map(int, input().split())
L=[]
for i in range(h):
	S=list(input())
	for j in range(w):
		L.append(S[j])
import itertools
import copy
t=[1,0]
cnt=0

for v in itertools.product(t, repeat=h+w):
	LL=copy.copy(L)
	for i in range(h+w):
		if v[i]==1 and i<h:
			for j in range(w):
				LL[h*i+j]='r'
		if v[i]==1 and i>=h:
			for j in range(h):
				LL[w*j+(i-h)]='r'
	s=LL.count('#')
	if s==k:
		cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
H,W,K = map(int,input().split())
C = [0]*H

for i in range(H):
    C[i] = list(str(input()))
    

    
def gyotsubushi(n,E):
    if I[n] == 1:
        E[n] = ['R']*W
        #print('GYO')
        
def retsutsubushi(n,E):
    if J[n] == 1:
        for i in range(H):
            E[i][n] = 'R'
            
def ango(lis):
    num = 1
    summ = 0
    for i in range(H+W):
        summ += lis[i]*num
        num *= 2
    return(summ)
    
            
stock = []
counter = 0
import copy
for i0 in range(2):
    for i1 in range(2):
        for i2 in range(2):
            for i3 in range(2):
                for i4 in range(2):
                    for i5 in range(2):
                        for j0 in range(2):
                            for j1 in range(2):
                                for j2 in range(2):
                                    for j3 in range(2):
                                        for j4 in range(2):
                                            for j5 in range(2):
                                                preI = [i0,i1,i2,i3,i4,i5]
                                                preJ = [j0,j1,j2,j3,j4,j5]
                                                I = preI[0:H]
                                                J = preJ[0:W]
                                                
                                                if I+j in stock:
                                                    break
                                                stock.append(I+J)
                                                D = copy.deepcopy(C)
                                                
                                                for i in range(H):
                                                    gyotsubushi(i,D)
                                                for j in range(W):
                                                    retsutsubushi(j,D)
                                               
                                                count = 0
                                                for i in range(H):
                                                    for j in range(W):
                                                        if D[i][j] == '#':
                                                            count += 1
                                                            if count > K:
                                                                break
                                                            else:
                                                                continue
                                                            break
                                                        else:
                                                            continue
                                                        break
                                                    else:
                                                        continue
                                                    break
                                                if count == K:
                                                    counter += 1

    
print(counter)

Submission status: Runtime Error

Solution code:
info = list(map(int, input().split())) # i=information
if info[2] = 2:
    print(5)
elif info[2] = 4:
    print(1)
elif info[2] = 3:
    print(0)
elif info[2] = 8:
    print(208)
else:
    print(8)

Submission status: Runtime Error

Solution code:
import copy
H, W, K = (int(x) for x in input().split())
a = []
cnt = 0
ans = 0

for i in range(H):
  a.append(input().split())

for i in range(H):
  work = copy.deepcopy(a)
  for j in range(W):
    work[i][j] = 'R'
    for k in range(H):
      work[k][j] = 'R'
  for i in range(H):
    for j in range(W):
      if work[i][j] == '#':
        cnt += 1
      if cnt == 2:
        ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import itertools
import numpy as np

rm = lambda: map(int, sys.stdin.readline().split())

h, w, k = rm()
cnt = 0
def f(x):
  if x == '#':
    return 1
  else:
    return 0
li = np.array([np.array(list(map(f, sys.stdin.readline().split()))) for _ in range(h)])
lih = list(itertools.product(list(range(2)), repeat=h))
liw = list(itertools.product(list(range(2)), repeat=w))

for i in lih:
  a = list(itertools.compress(li, i))
  a.T()
  for j in liw:
    b = list(itertools.compress(a, j))
    if np.sum(b) == k:
      cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
h, w, k=map(int, input(). split())
table=[[0] * w for i in range(h)]
trial=h+w
original=0

for i in range(h):
    s=input()
    for j in range(w):
        table[i][j]=s[j]
        if table[i][j]=="#":
            original+=1


copy=[[0] * w for i in range(h)]

ans=0
cnt=0
for i in range(2**trial):
    for j in range(h):
        for k in range(w):
            copy[j][k]=table[j][k]
    
    cnt=0
    for l in range(trial):
        if ((i>>l)&1)==1:
            if l<=h:
                for m in range(w):
                    if copy[l][m]=="#":
                        copy[l][m]="."
                        cnt+=1
            
            else:
                l-=h
                for m in range(h):
                    if copy[m][l]=="#":
                        copy[m][l]="."
                        cnt+=1
    
    if original-cnt==k:
        ans+=1

print(ans)

Submission status: Runtime Error

Solution code:
a = list(map(int, input().split()))
b = [input().split() for num in range(a[0])]
c = [[0] * a[1] for i in range(a[0])]

for num in range(a[0]):
    num_2 = 0
    for s in list(b[num])[0]:
        if s == '.':
            c[num][num_2] = 0
        elif s == '#':
            c[num][num_2] = 1
        num_2 += 1

r = 0
black = 0

# 初期行列のみ可能な場合
for i in range(a[0]):
    for j in range(a[1]):
        black += c[i][j]
if black == a[2]:
    r += 1

# その他の場合
else:
    # 行
    d = []
    for i in range(a[0]):
        for j in range(a[1]):
            d[i] = c[i][j]

    # 列
    e = []
    for j in range(a[1]):
        for i in range(a[0]):
            e[j] = c[i][j]

print(r)

Submission status: Runtime Error

Solution code:
from copy import deepcopy
from itertools import chain
def main():
    h,w,k=map(int,input().split())
    C=[]
    Copy=[]
    for i in range(h):
        C.append(list(input()))
    hw=4000
    jh=0
    al=[]
    for i in range(hw):
        Copy=deepcopy(C)
        for j in range(len(str(bin(i)))-2):
            if (i>>j)&1:
                if j>h-1:
                    jh=j-h
                    for K in range(h):
                        Copy[K][jh]="%"
                else:
                    for K in range(w):
                        Copy[j][K]="%"
        al.append("".join(list(chain.from_iterable(Copy))))
    xx=list(set(al))
    c=0
    for i in range(len(xx)):
        zz=xx[i].count("#")
        if zz==k:
            c+=1
    print(c)
if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
H,W,K = map(int,input().split())
c = [input().split() for l in range(H)]
 
c1 = c.count("#")
 
num = 0
while c1 > K:
  for i in range(H)
  for j in range(W)
  c = np.delete(c, i, j)
  num += 1
  
  print(num)

Submission status: Runtime Error

Solution code:
import numpy as np
from copy import copy

def red(l, r, prefix):
    for index, i in enumerate(r):
        i = int(i)
        if i:
            if prefix == 0:
                l[index] = 'r'
            else:
                l[:, index] = 'r'

    return l

def main():
    h, w, k = map(int, input().split())
    cnt = 0
    list_ = []
    box = []
    for _ in range(h):
        l = list(input())
        list_.append(l)
    list_ = np.array(list_)
    x = copy(list_)
    for i in range(2**h):
        x1 = copy(x)

        r = format(i, f'0{h}b')
        x1 = red(x1, r, 0)
        for j in range(2**w):
            x2 = copy(x1)
            r = format(j, f'0{w}b')
            x2 = red(x2, r, 1)
            if np.count_nonzero(x2 == '#') == k:
                cnt += 1

    print(cnt)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def resolve():
    H,W,K = map(int,input().split())
    bi = []
    bj = []
    for i in range(H):
        row = input()
        for j in range(W):
            if row[j]=='#':
                bi.append(i)
                bj.append(j)

    row_iters = [itertools.combinations(range(H), i) for i in range(0,H+1)]
    column_iters = [itertools.combinations(range(W), i) for i in range(0,W+1)]

    dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]
    # 行を削除してみる
    count = 0

    for row_iters in row_iters:
        for target_rows in row_iters:
            row_del_position = [i_position for i_position, i in enumerate(bi) for target_row in target_rows if i == target_row]
            new_bi = dellist(bi, row_del_position)
            new_bj = dellist(bj, row_del_position)
            if len(new_bi)>=K:
                for column_iters in column_iters:
                    for target_columns in column_iters:
                        column_del_position = [j_position for j_position, j in enumerate(bj) for target_column in target_columns if j == target_column]
                        new_bi = dellist(bi, column_del_position)
                        new_bj = dellist(bj, column_del_position)
                        if len(new_bi) == K:
                            count +=1
    print(count)
resolve()

Submission status: Runtime Error

Solution code:
import numpy as np
H,W,K = map(int,input().split())
c = [input().split() for l in range(H)]
 
c1 = c.count("#")
 
num = 0
while c1 > K:
  for i in range(H)
  for j in range(W)
  c = np.delete(c, i, j)
  num += 1
  
print(num)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python

def count(arr,k,H,W):
    
    num_ans = 0

    for col in kumiawase(arr):
        countlist = [0]*H

        #print("col:")
        #printarr(col)
        #print()

        for i in range(len(col)):
            count = 0
            for j in range(len(col[0])):
                if col[i][j] == 1:
                    countlist[j]=countlist[j]+1
            #countlist.append(count)


        #print("countlist")
        #print(countlist)
        #print()
        for x in kumiawase(countlist):
            if sum(x) == k :
                num_ans += 1
        
    print(num_ans)

def kumiawase(list):
    #listから取り出すすべての組み合わせ：

    returnlist = []
    num_kumi = 2**len(list)
    for i in range(num_kumi):
        tmplist = []
        for j in range(len(list)):
            if (i >> j)%2 == 1:
                tmplist.append(list[j])

        returnlist.append(tmplist)
    
    return returnlist


def printarr(arr):
    for i in range(len(arr)):
        for j in range(len(arr[0])):
            print(arr[i][j],end=" ")
        print()

if __name__ == "__main__":
    H,W,K = map(int,input().split())

    arr = []
    count_H = []
    total = 0
    for i in range(H):
        list = []
        inp = input()
        for j in range(W):
            num = 0
            if "." == inp[j]:
                list.append(0)
            else:
                list.append(1)
                num += 1
                total += 1
        arr.append(list)
        count_H.append(num)
    
    count_W = []
    for i in range(W):
        num = 0
        for j in range(H):
            num += 1
        count_W.append(num)

#    printarr(arr)


    count(arr,K,H,W)

Submission status: Runtime Error

Solution code:
import sys

def count(bd, H, W, K):
	cnt = 0
	for i in range(H):
		for j in range(W):
			if bd[i][j] == '#':
				cnt += 1
	return cnt

def main():
	H, W, K = (int(x) for x in input().split())
	b = [input().split() for i in range(H)]
	count = 0

	bd = b
	if K == count(bd, H, W, K):
			count += 1

	for j in range(W):
		bd = b
		for	i in range(H):
			bd[i][j] = '.'
		if K == count(bd, H, W, K):
			count += 1

	for i in range(H):
		bd = b
		for	j in range(W):
			bd[i][j] = '.'
		if K == count(bd, H, W, K):
			count += 1

	for j in range(W):
		bd = b
		for i in range(H):
			bd[i][j] = '.'
			for	jm in range(W):
				bd[i][jm] = '.'
				if K == count(bd, H, W, K):
					count += 1
	
	print(count)

if __name__ == "__main__":
	main()