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:
from itertools import product

H, W, K = map(int, input().split())

C = [list(input().split()) for _ in range(H)]

ans = 0

for row_bit in product(range(2), repeat = H):
    for col_bit in product(range(2), repeat = W):
        cnt = 0
        for row in range(H):
            for col in range(W):
                if C[row][col] == '#' and (row_bit[row] and col_bit[col]):
                    cnt += 1
            if cnt = K:
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import product

H, W, K = map(int, input().split())

C = [list(input()) for _ in range(H)]

ans = 0

for row_bit in product(range(2), repeat = H):
    for col_bit in product(range(2), repeat = W):
        cnt = 0
        for row in range(H):
            for col in range(W):
                if C[row][col] == '#' and (row_bit[row] and col_bit[col]):
                    cnt += 1
            if cnt = K:
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import product

H, W, K = map(int, input().split())

C = [list(input()) for _ in range(H)]

ans = 0

for row_bit in product(range(2), repeat = H):
    for col_bit in product(range(2), repeat = W):
        cnt = 0
        for row in range(H):
            for col in range(W):
                if c[row][col] == '#' and (row_bit[row] and col_bit[col]):
                    cnt += 1
            if cnt = K:
                ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import pandas as pd

H,W,K = list(map(int, input().split()))
t=[]
for i in range(H):
    t.append([int(i) for i in input().replace(".","0").replace("#","1")])

cnt = 0
for i in range(2**H):
    for j in range(2**W):
        d = pd.DataFrame(t)
        i_2 = [int(k) for k in bin(i)[2:].rjust(H,"0")]
        j_2 = [ int(k) for k in bin(j)[2:].rjust(W,"0")]
        #print(i_2)
        #print(j_2)
        
        for h in range(H):
            d.iloc[h,:] = d.iloc[h,:] * i_2[h]
        for w in range(W):
            d.iloc[:,w] = d.iloc[:,w] * j_2[w]
        num = sum((d == 1).sum())
        #print(num)
        #print(d)
        if num == K:
            cnt +=1
            
print(cnt)

Submission status: Runtime Error

Solution code:
import pandas as pd

H,W,K = list(map(int, input().split()))
t=[]
for i in range(H):
    t.append([int(i) for i in input().replace(".","0").replace("#","1")])

cnt = 0
for i in range(2**H):
    for j in range(2**W):
        d = pd.DataFrame(t)
        i_2 = [int(k) for k in bin(i)[2:].rjust(H,"0")]
        j_2 = [ int(k) for k in bin(j)[2:].rjust(W,"0")]
        #print(i_2)
        #print(j_2)
        
        for h in range(H):
            d.iloc[h,:] = d.iloc[h,:] * i_2[h]
        for w in range(W):
            d.iloc[:,w] = d.iloc[:,w] * j_2[w]
        num = sum((d == 1).sum())
        #print(num)
        #print(d)
        if num == K:
            cnt +=1

Submission status: Runtime Error

Solution code:
import itertools
import numpy as np

H, W, K = map(int, input().split())

temp = []
for _ in range(H):
  C = list(input())
  A = [c.replace('.', '0') for c in C]
  A = [a.replace('#', '1') for a in A]
  A = list(map(lambda x: int(x), A))
  temp.append(A)
  
C = np.array(temp)

count = 0
l = [0, 1]
wide = itertools.product(1, repeat=W)
for w in wide:
  height = itertools.product(1, repeat=H)
  for h in height:
    copy_C = C.copy()
    for num, i in enumerate(w):
      if i == 1:
        copy_C[:, num - 1] = 0
      for num2, j in enumerate(h):
        if j == 1:
          copy_C[num2 - 1, :] = 0
      if copy_C.sum() == K:
        count = count + 1
print(count)

Submission status: Runtime Error

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

count = 0
for binh in range(2**h):
    for binw in range(2**w):
        redh, redw = bin(binh)[2:], bin(binw)[2:]  # remove suffix '0x'
        squares = [list(row) for row in c]
        for rh in redh:
            for wh in range(w):
                squares[rh][wh] = '*'
        for rw in redw:
            for hw in range(h):
                squares[rw][hw] = '*'
        count += sum(row.count('#') for row in squares) == k

print(k)

Submission status: Runtime Error

Solution code:
from python.c import squares


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

count = 0
for binh in range(2**h):
    for binw in range(2**w):
        redh, redw = bin(binh)[2:], bin(binw)[2:]  # remove suffix '0x'
        squares = [list(row) for row in c]
        for rh in redh:
            for wh in range(w):
                squares[rh][wh] = '*'
        for rw in redw:
            for hw in range(h):
                squares[rw][hw] = '*'
        count += sum(row.count('#') for row in squares) == k

print(k)

Submission status: Runtime Error

Solution code:
row, col, num = map(int, input().split())

tmp_l = []
board = []
for i in range(row):
  str = input()
  for j in range(col):
    if str[j] == '.':
      tmp_l.append(0)
    if str[j] == '#':
      tmp_l.append(1)
  board.append(tmp_l)
  tmp_l = []

onoff = []
bi = [32, 16, 8, 4, 2, 1]
for i in range(64):
  tmp = i
  for j in bi:
    tmp_l.insert(0, int(tmp / j))
    tmp = tmp % j
  onoff.append(tmp_l)
  tmp_l = []

count = 0
ans = 0
for i in range(2**row):
  for j in range(2**col):
    for k in range(row):
      if onoff[i][k] == 1:
        for l in range(col):
          if onoff[j][l] == 1:
            if board[l][k] == 1:
              count += 1
    if count == num:
      ans += 1
    count = 0

print(ans)

Submission status: Runtime Error

Solution code:
row, col, num = map(int, input().split())

tmp_list = []
board = []
for i in range(row):
  str = input()
  for j in range(col):
    if str[j] == '.':
      tmp_list.append(0)
    if str[j] == '#':
      tmp_list.append(1)
  board.append(tmp_list)
  tmp_list = []

onoff = []
bi = [32, 16, 8, 4, 2, 1]
for i in range(64):
  tmp = i
  for j in bi:
    tmp_list.insert(0, int(tmp / j))
    tmp %= j
  onoff.append(tmp_list)
  tmp_list = []

count = 0
ans = 0
for i in range(2**row):
  for j in range(2**col):
    for k in range(row):
      if onoff[i][k] == 1:
        for l in range(col):
          if onoff[j][l] == 1:
            if board[l][k] == 1:
              count += 1
    if count == num:
      ans += 1
    count = 0

print(ans)

Submission status: Runtime Error

Solution code:
H,W,K = [int(i) for i in input().split()]
C = [list(input()) for _ in range(H)]

row = [0]*W + [0]
col = [0]*H + [0]

for i in range(H):
    for j in range(W):
        if C[i][j] == '#':
            col[i] += 1

for i in range(W):
    for j in range(H):
        if C[i][j] == '#':
            row[i] += 1

ans = 0
for i in range(H):
    for j in range(W):
        if col[i]+row[j] == K:
            ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
h, w, k = map(int, input().split())
X = [[1 if a == "#" else 0 for a in input()] for _ in range(H)
ans = 0
for ii in range(1 << h):
  for jj in range(1 << w):
    if sum([sum([X[i][j] for j in range(w) if jj >> j & 1]) for i in range(h) if ii >> i & 1]) == k:
      ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
h, w, k = gets.chomp.split(" ").map(&:to_i)
map = Array.new(h)
h.times do |i|
  map[i]=gets.chomp.split("")
end

cnt = 0
ans = 0
(1<<h).times do |i|
  (1<<w).times do |j|
    cnt = 0
    h.times do |h_shift|
      w.times do |w_shift|
        next if i>>h_shift&1==1 or j>>w_shift&1==1
        if map[h_shift][w_shift] == "#"
          cnt += 1
        end
      end
    end
    if k==cnt
      ans += 1
    end
  end
end
puts ans

Submission status: Runtime Error

Solution code:
        h0, w0, k0 = [ int(x) for x in input().split() ]
        buf = {}
        for i in range(h0):
          buf[1 << i] = { 1 << j for j,x in enumerate(input()) if x == '#' }
        found = 0
        for i in range(1, 1 << h0):
          idx = {}
          for k,v in buf.items():
            if k & i == 0: continue
            for v in vs: idx[v] = idx.get(v, 0) + 1
          for j in range(1, 1 << w0):
            n = sum([ v for k,v in idx.items() if k & j ])
            if n == k0: found += 1
        print(found)

Submission status: Runtime Error

Solution code:
    h0, w0, k0 = [ int(x) for x in input().split() ]
    buf = {}
    for i in range(h0):
      buf[1 << w0] = { 1 << j for j,x in enumerate(input()) if x == '#' }
    found = 0
    for i in range(1, 1 << h0):
      idx = {}
      for k,v in buf.items():
        if k & i == 0: continue
        for v in vs: idx[v] = idx.get(v, 0) + 1
      for j in range(1, 1 << w0):
        n = sum([ v for k,v in idx.items() if k & j ])
        if n == k0: found += 1
    print(found)

Submission status: Runtime Error

Solution code:
h0, w0, k0 = [ int(x) for x in input().split() ]
buf = 1
for i in range(h0):
  buf[1 << w0] = { 1 << j for j,x in enumerate(input()) if x == '#' }
found = 0
for i in range(1, 1 << h0):
  idx = {}
  for k,v in buf.items():
    if k & i == 0: continue
    for v in vs: idx[v] = idx.get(v, 0) + 1
  for j in range(1, 1 << w0):
    n = sum([ v for k,v in idx.items() if k & j ])
    if n == k0: found += 1
print(found)

Submission status: Runtime Error

Solution code:
h, w, k = map(int,input().split())
c = []
for i in range(h):
  c.append(input())
  
def countb(c):
  num = 0
  for i in range(h):
    num += c[i].count("#")
  return(num)

def printb(c, row, col):
  c = c[:]
  #print(row,col)
  cnt = 0
  while row != 0:
    if row  & 0b1:
     
      c[cnt] = "."*w
    cnt += 1
    row = row >> 1
  
  cnt = 0
  while col != 0:
    #print(col&0b1)
    if col & 0b1:
      for i in range(h):
        c[i] = c[i][:cnt]+"."+c[i][cnt+1:]
    cnt += 1
    col = col >> 1
    
  #print("\n".join(c))
  return countb(c)

if countb(c) == k:
  print(0)
else:
  ans = 0
  for i in range(2**h):
    for j in range(2**w):
      if printb(c,i,j) == k:
        ans += 1
        
  
print(ans)

Submission status: Runtime Error

Solution code:
h, w, k = map(int, input().split())
c = []
for i in range(h):
    c.append(list(map(str, input().split())))
ans = 0
for j in range(1<<h):
    for k in range(1<<w):
        black = 0
        for m in range(h):
            for n in range(w):
                if ((j>>m) & 1) == 0 and ((k>>n) & 1) == 0 and c[m][n] == "#":
                    black += 1
        if black == k:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import itertools

H, W, K = map(int, input().split())
C = []
 
for i in range(H):
    C.append(input())

ans = 0

for i in range(H+1):
    for j in range(W+1):
        for m in itertools.combinations(list(range(H)), i):
            for n in itertools.combinations(list(range(W)), j):
                count = 0
                for a in m:
                    for b in n:
                        if(C[b][a] == "#"):
                            count += 1
                if(count == K):
                    ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
h,w,k=map(int,input().split())
c=[list(input())for i in range(h)]
d=0
for i in range(2**h):
    for j in range(2**w):
        i=bin(i)[2:]
        j=bin(j)[2:]
        i="0"*(h-len(i))+i
        j="0"*(j-len(j))+j
        p=0
        for s in range(h):
            for t in range(w):
                if i[s]==j[t]==0 and c[s][t]=="#":
                    p+=1
        if p==k
        d+=1
print(d)

Submission status: Runtime Error

Solution code:
import copy

H, W, K = map(int, input().split())
tiles = [list(input().split()) for _ in range(H)]
count  = 0

for num in range(2**(H+W)):
  copied_tiles = copy.deepcopy(tiles)
  for i in range(H+W):
    if num>>i&1:
      if i < H:
        for j in range(W):
          copied_tiles[i][j] = 'R'
      else:
        for j in range(H):
          copied_tiles[j][i-H] = 'R'
  black_c = 0
  for i in range(H):
    for j in range(W):
      if copied_tiles[i][j] == '#':
        black_c += 1
  if black_c == K:
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
h,w,k=map(int,input().split())
matrix=[]
for i in range(h):
	s=list(input())
	matrix.append(s)
hlist=[]
for i in range(h):
	hlist.append(i)
wlist=[]
for i in range(w):
	wlist.append(i)
rows=[]
cols=[]
for i in range(h+1):
	obj=itertools.combinations(hlist, i)
	rows+=list(obj)
for i in range(w+1):
	obj=itertools.combinations(wlist, i)
	cols+=list(obj)
ans=0
for i in rows:
	for j in cols:
		count=0
		for a in range(h):
			for b in range(w):
				if(matrix[a][b]=='#' and a not in i and b not in j):
					count+=1
		if(count==k):
			ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
h,w,k = map(int, input().split())

for _ in range(h):
    c=list(input())

ans = 0

for i in range(h):
    for j in range(w):
        count = 0
        for m in range(h):
            for l in range(w):
                if (i>>m)&1==0 and (j>>l)&1==0 and c[m][l]== "#":
                    count+=1
        if count == k: ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
h,w,k = map(int, input().split())

for _ in range(h):
    c=list(input())

ans = 0

for i in range(h):
    for j in range(w):
    cnt = 0
        for m in range(h):
            for l in range(w):
                if (i>>m)&1==0 and (j>>l)&1==0 and c[m][l]== "#":
                    cnt+=1
        if cnt == k: ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
import copy
H,W,K=map(int,input().split())
L=[list(map(int,input().split())) for i in range(H)]
ans=0
for i in range(2**H):
    for j in range(2**W):
        C=copy.deepcopy(L)
        for k range(H):
            if (i>>k&1):
                C[k]=["r"]*W
        for l range(W):
            if (j>>l&1):
                for m range(H):
                    C[l][m]="r"
        count=0
        for i in range(H):
            for j in range(W):
                if C[i][j]=="#":
                    count+=1
        if count==K:
            ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
H,W,K=map(int,input().split())
L=[list(map(int,input().split())) for i in range(H)]
ans=0
for i in range(2**H):
    for j in range(2**W):
        C=deepcopy.(L)
        for k range(H):
            if (i>>k&1):
                C[k]=["r"]*W
        for l range(W):
            if (j>>l&1):
                for m range(H):
                    C[l][m]="r"
        count=0
        for i in range(H):
            for j in range(W):
                if C[i][j]=="#":
                    count+=1
        if count==K:
            ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

h, w, k = map(int, input().split())
ccc = [input() for _ in range(h)]
nccc = np.zeros((h, w))

for i in range(h):
  tmp = ccc[i]
  for j in range(w):
    if tmp[j]=="#":
      nccc[i][j]=1

for i in range(h):
  for j in range(w):

Submission status: Runtime Error

Solution code:
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())
  
H,W,K=input2()
c=[list(input()) for _ in range(H)]

ans=0
print(c)

for row_line in product(range(2),repeat=H): #[行]0:そのまま，1:赤く塗る
	for col_line in product(range(2), repeat=W): #[列]0:そのまま，1:赤く塗る
		# 黒("#")の数え上げ
		cnt=0
		for row in range(H):
			for col in range(W):
				if c[row][col]=="#" and row_line[row]==0 and col_line[col]==0:
					cnt+=1

		if cnt==K:
			ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
umber=list(map(int,input().split()))
H,W,K=number[0],number[1],number[2]
answer=0
nums=[]
for i in range(H):
    tmp=list(str(input()))
    nums.append(tmp)
count=0
for cowmask in range(1<<H):
    for rowmask in range(1<<W):
        count=0
        for x in range(H):
            for y in range(W):
                if (cowmask>>x)&1==0 and (rowmask>>y)&1==0 and nums[x][y]=="#":
                    count+=1
        if count==K:
            answer+=1
            
print(answer)

Submission status: Runtime Error

Solution code:
import numpy as np
import copy
import itertools
h = int(input())
w = int(input())
k = int(input())
s = [list(input()) for i in range(h)]
data = np.zeros(h*w).reshape(h,w)
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            data[i][j] = 1

ans = 0
## 塗らない場合
if np.sum(data == 1) == k:
    ans = 1
## すべて塗った場合
if k == 0:
    ans = 1

a = list()
b = list()
for i in range(1,h):
    a += list(itertools.combinations(range(h), i))
for i in range(1,w):
    b += list(itertools.combinations(range(w), i))

for i in a:
    for j in b:
        temp = data.copy()
        temp[i,:] = 2
        temp[:,j] = 2
        if np.sum(temp == 1) == k:
            ans += 1

for i in a:
    temp = data.copy()
    temp[i,:] = 2
    if np.sum(temp == 1) == k:
        ans += 1
        
for j in b:
    temp = data.copy()
    temp[:,j] = 2
    if np.sum(temp == 1) == k:
        ans += 1
        
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import itertools
h = int(input())
w = int(input())
k = int(input())
s = [list(input()) for i in range(h)]
data = np.zeros(h*w).reshape(h,w)
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            data[i][j] = 1

ans = 0
## 塗らない場合
if np.sum(data == 1) == k:
    ans = 1
## すべて塗った場合
if k == 0:
    ans = 1

a = list()
b = list()
for i in range(1,h):
    a += list(itertools.combinations(range(h), i))
for i in range(1,w):
    b += list(itertools.combinations(range(w), i))

for i in a:
    for j in b:
        temp = data.copy()
        temp[i,:] = 2
        temp[:,j] = 2
        if np.sum(temp == 1) == k:
            ans += 1

for i in a:
    temp = data.copy()
    temp[i,:] = 2
    if np.sum(temp == 1) == k:
        ans += 1
        
for j in b:
    temp = data.copy()
    temp[:,j] = 2
    if np.sum(temp == 1) == k:
        ans += 1
        
print(ans)

Submission status: Runtime Error

Solution code:
h,w,k=map(int, input().split())
board = [list(input()) for _ in range(h)]
ans=0
for paint_h in range(2**h):
  for paint_w in range(2**w):
    cnt=0
    for i in range(h):
      for j in range(w):
        if (paint_h>>i)&1==0 and (paint_w>>j)&1==0:
          if board[i][j]=='#':
            cnt+=1
    if cnk==l:
      ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import sys 
from collections import defaultdict
from queue import Queue 
# For getting input from input.txt file 
sys.stdin = open('input.txt', 'r')  
# sys.stdout = open('output.txt', 'w') 
 
def powerset(s):
    x = len(s)
    lst = []
    for i in range(1 << x):
        lst.append([s[j] for j in range(x) if (i & (1 << j))])
    return lst

input = sys.stdin.readline

h, w, k = map(int,input().split())

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

white, black = 0, 0
for i in range(h):
    for j in range(w):
        if grid[i][j] == '.': white += 1
        else: black += 1

remove_row = powerset(range(h))
remove_col = powerset(range(w))

sol = 0
for r_row in remove_row:
    for r_col in remove_col:
        cnt = 0
        for i in range(h):
            if i in r_row: continue
            for j in range(w):
                if j in r_col: continue
                if grid[i][j] == '#': cnt += 1
        if cnt == k: sol += 1
print(sol)

Submission status: Runtime Error

Solution code:
from itertools import product

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

ans = 0

for row_bit in product(range(2), repeat=h):
    for col_bit in product(range(2), repeat=w):
        cnt = 0
        for row in range(h):
            for col in range(w):
                if (c[row][col] == '#') and ((row_bit[row] == 0) and (col_bit[col] == 0)):
                    cnt += 1   
        if cnt == k:
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from itertools import product

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

print(c)
ans = 0

for row_bit in product(range(2), repeat=h):
    for col_bit in product(range(2), repeat=w):
        cnt = 0
        for row in range(h):
            for col in range(w):
                if (c[row][col] == '#') and ((row_bit[row] == 0) and (col_bit[col] == 0)):
                    cnt += 1   
        if cnt == k:
            print(row_bit, col_bit)
            ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
import itertools

H, W, K = map(int, input().split())
c = [list(input().split()) for l in range(H)]

listH = list(range(H))
Hcombi = []
for n in range(H+1):
    a = list(itertools.combinations(listH,n))
    Hcombi.extend(a)

listW = list(range(W))
Wcombi = []
for n in range(W+1):
    a = list(itertools.combinations(listW,n))
    Wcombi.extend(a)

N = 0

for h in Hcombi:
    for w in Wcombi:
        X = np.array(c)
        X[[h],:] = 'n'
        X[:,[w]] = 'n'
        count = np.sum(X == '#')
        if count == K:
            N +=1        
print(str(N))

Submission status: Runtime Error

Solution code:
import numpy as np
import itertools

H, W, K = map(int, input().split())
c = [list(input().split()) for l in range(H)]

listH = list(range(H))
Hcombi = []
for n in range(len(listH)+1):
    a = list(itertools.combinations(listH,n))
    Hcombi.extend(a)

listW = list(range(W))
Wcombi = []
for n in range(len(listW)+1):
    a = list(itertools.combinations(listW,n))
    Wcombi.extend(a)

N = 0

for h in Hcombi:
    for w in Wcombi:
        X = np.array(x)
        X[[h],:] = 'n'
        X[:,[w]] = 'n'
        count = np.sum(X == '#')
        if count == K:
            N +=1        
print(str(N))

Submission status: Runtime Error

Solution code:
import numpy as np
import itertools

H, W, K = map(int, input().split())
x = [list(input().split()) for l in range(H)]

listH = list(range(H))
Hcombi = []
for n in range(len(listH)+1):
    a = list(itertools.combinations(listH,n))
    Hcombi.extend(a)

listW = list(range(W))
Wcombi = []
for n in range(len(listW)+1):
    a = list(itertools.combinations(listW,n))
    Wcombi.extend(a)

N = 0

for h in Hcombi:
    for w in Wcombi:
        X = np.array(x)
        X[[h],:] = 'n'
        X[:,[w]] = 'n'
        count = np.sum(X == '#')
        if count == K:
            N +=1        
print(str(N))

Submission status: Runtime Error

Solution code:
import numpy as np
import itertools

H, W, K = map(int, input().split())
x = [list(input().split()) for l in range(H)]

listH = list(range(H))
Hcombi = []
for n in range(len(listH)+1):
    a = list(itertools.combinations(listH,n))
    Hcombi.extend(a)

listW = list(range(W))
Wcombi = []
for n in range(len(listW)+1):
    a = list(itertools.combinations(listW,n))
    Wcombi.extend(a)

N = 0

for h in Hcombi:
    for w in Wcombi:
        X = np.array(x)
        X[[h],:] = 'n'
        X[:,[w]] = 'n'
        count = np.sum(X == '#')
        if count == K:
            N +=1        
print(N)

Submission status: Runtime Error

Solution code:
H,W,K=map(int,input().split())
#Hが縦、Wが横、Kが欲しい数
import copy
#cを取得
c=[input() for l in range(H)]
c=[list(c[s]) for s in range(H)]
#cを置き換えた
for i in range(W):
  for j in range(H):
    if c[i][j]=="#":
      c[i][j]=1
    else:
      c[i][j]=0
#何個黒か数える奴
def counting(data):
  count=0
  for i in range(W):
    for j in range(H):
      if data[i][j]==1:
        count+=1
  return count
#塗る奴
def drawing(data,x,y):
  newdata=copy.deepcopy(data)
  for i in range(W):
    for j in range(H):
      newdata[x][j]=0
      newdata[i][y]=0
  return newdata
#仕上げの奴
result=0
T=0
if counting(c)==K:
  result+=1
for i in range(W):
  for j in range(H):
    T=counting(drawing(c,i,j))
    if T==K:
      result+=1
print(result)

Submission status: Runtime Error

Solution code:
H,W,K=map(int,input().split())
#Hが縦、Wが横、Kが欲しい数
import copy
#cを取得
c=[input() for l in range(H)]
print(c)
c=[list(c[s]) for s in range(H)]
print(c)
#cを置き換えた
for i in range(W):
  for j in range(H):
    if c[i][j]=="#":
      c[i][j]=1
    else:
      c[i][j]=0
#何個黒か数える奴
def counting(data):
  count=0
  for i in range(W):
    for j in range(H):
      if data[i][j]==1:
        count+=1
  return count
#塗る奴
def drawing(data,x,y):
  newdata=copy.deepcopy(data)
  for i in range(W):
    for j in range(H):
      newdata[x][j]=0
      newdata[i][y]=0
  return newdata
#仕上げの奴
result=0
T=0
if counting(c)==K:
  result+=1
for i in range(W):
  for j in range(H):
    T=counting(drawing(c,i,j))
    if T==K:
      result+=1
print(result)

Submission status: Runtime Error

Solution code:
H,W,K=map(int,input().split())
#Hが行、Wが列、Kが欲しい数
import copy
#cを取得
c=[input() for l in range(H)]
c=[list(c[s]) for s in range(W)]
#cを置き換えた
for i in range(H):
  for j in range(W):
    if c[i][j]=="#":
      c[i][j]=1
    else:
      c[i][j]=0
#何個黒か数える奴
def counting(data):
  count=0
  for i in range(H):
    for j in range(W):
      if data[i][j]==1:
        count+=1
  return count
#塗る奴
def drawing(data,x,y):
  newdata=copy.deepcopy(data)
  for i in range(H):
    for j in range(W):
      newdata[x][j]=0
      newdata[i][y]=0
  return newdata
#仕上げの奴
result=0
T=0
if counting(c)==K:
  result+=1
for i in range(H):
  for j in range(W):
    T=counting(drawing(c,i,j))
    if T==K:
      result+=1
print(result)

Submission status: Runtime Error

Solution code:
H,W,K=map(int,input().split())
#Hが行、Wが列、Kが欲しい数
#cを取得
c=[input() for l in range(H)]
c=[list(c[s]) for s in range(W-1)]
#cを置き換えた
for i in range(H):
  for j in range(W):
    if c[i][j]=="#":
      c[i][j]=1
    else:
      c[i][j]=0
import copy
c2=copy.deepcopy(c)
#何個黒か数える奴
def counting(data):
  count=0
  for i in range(H):
    for j in range(W):
      if data[i][j]==1:
        count+=1
  return count
#塗る奴
def drawing(data,x,y):
  for i in range(H):
    for j in range(W):
      newdata=copy.deepcopy(data)
      newdata[x][j]=0
      newdata[i][y]=0
  return newdata
#仕上げの奴
result=0
T=0
for i in range(H):
  for j in range(W):
    T=counting(drawing(c,i,j))
    if T==K:
      result+=1
print(result)

Submission status: Runtime Error

Solution code:
import itertools
def getCombList(xList):
  N = len(xList)
  result = []
  for n in range(1,N+1):
    for conb in itertools.combinations(xList, n):
      result.append(list(conb)) #タプルをリスト型に変換
  #print(result)
  return result

import sys
sys.setrecursionlimit(20000)

import numpy as np
L1 = input()
H, W, K = map(int, L1.split(" "))
mat = np.zeros([H,W], dtype="int32")
for i in range(H):
  Li = input()
  for j, s in enumerate(Li):
    if s == "#":
      mat[i,j] = 1

if np.sum(np.sum(mat)) < K:
  print(0)
else:
  if np.sum(np.sum(mat)) == K:
    c = 1
  else:
    c = 0
  matp = mat.copy()
  HList = list(range(H))
  WList = list(range(W))
  HcombList = getCombList(HList)
  WcombList = getCombList(WList)
  for Hcomb in HcombList:
    for Wcomb in WcombList:
      matp[Hcomb, :] = 0
      matp[:, Wcomb] = 0
      if np.sum(np.sum(matp)) == K:
        c = c + 1
      matp = mat.copy()
      
  for Hcomb in HcombList:
    matp[Hcomb, :] = 0
    if np.sum(np.sum(matp)) == K:
      c = c + 1
    matp = mat.copy()

  for Wcomb in WcombList:
    matp[:, Wcomb] = 0
    if np.sum(np.sum(matp)) == K:
      c = c + 1
    matp = mat.copy()

print(c)

Submission status: Runtime Error

Solution code:
import itertools
def getCombList(xList):
  N = len(xList)
  result = []
  for n in range(1,N+1):
    for conb in itertools.combinations(xList, n):
      result.append(list(conb)) #タプルをリスト型に変換
  #print(result)
  return result

import numpy as np
L1 = input()
H, W, K = map(int, L1.split(" "))
mat = np.zeros([H,W], dtype="int32")
for i in range(H):
  Li = input()
  for j, s in enumerate(Li):
    if s == "#":
      mat[i,j] = 1

if np.sum(np.sum(mat)) < K:
  print(0)
else:
  if np.sum(np.sum(mat)) == K:
    c = 1
  else:
    c = 0
  matp = mat.copy()
  HList = list(range(H))
  WList = list(range(W))
  HcombList = getCombList(HList)
  WcombList = getCombList(WList)
  for Hcomb in HcombList:
    for Wcomb in WcombList:
      matp[Hcomb, :] = 0
      matp[:, Wcomb] = 0
      if np.sum(np.sum(matp)) == K:
        c = c + 1
      matp = mat.copy()
      
  for Hcomb in HcombList:
    matp[Hcomb, :] = 0
    if np.sum(np.sum(matp)) == K:
      c = c + 1
    matp = mat.copy()

  for Wcomb in WcombList:
    matp[:, Wcomb] = 0
    if np.sum(np.sum(matp)) == K:
      c = c + 1
    matp = mat.copy()

print(c)

Submission status: Runtime Error

Solution code:
import itertools
def getCombList(xList):
  N = len(xList)
  result = []
  for n in range(1,N):
    for conb in itertools.combinations(xList, n):
      result.append(list(conb)) #タプルをリスト型に変換
  #print(result)
  return result

import numpy as np
L1 = input()
H, W, K = map(int, L1.split(" "))
mat = np.zeros([H,W], dtype="int32")
for i in range(H):
  Li = input()
  for j, s in enumerate(Li):
    if s == "#":
      mat[i,j] = 1

if np.sum(np.sum(mat)) < K:
  print(0)
else:
  if np.sum(np.sum(mat)) == K:
    c = 1
  else:
    c = 0
  matp = mat.copy()
  HList = list(range(H))
  WList = list(range(W))
  HcombList = getCombList(HList)
  WcombList = getCombList(WList)
  for Hcomb in HcombList:
    for Wcomb in WcombList:
      matp[Hcomb, :] = 0
      matp[:, Wcomb] = 0
      if np.sum(np.sum(matp)) == K:
        c = c + 1
      matp = mat.copy()
      
  for Hcomb in HcombList:
    matp[Hcomb, :] = 0
    if np.sum(np.sum(matp)) == K:
      c = c + 1
    matp = mat.copy()

  for Wcomb in WcombList:
    matp[:, Wcomb] = 0
    if np.sum(np.sum(matp)) == K:
      c = c + 1
    matp = mat.copy()

print(c)