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: Accepted

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

c = [0] * H
for i in range(H):
    c[i] = input()

count = 0
for rows in range(1 << H):
    for cols in range(1 << W):
        black = 0
        for i in range(H):
            if (rows >> i) % 2 == 1:
                continue
            for j in range(W):
                if (cols >> j) % 2 == 1:
                    continue
                black += c[i][j] == '#'
        if black == K:
            count += 1
print(count)

Submission status: Accepted

Solution code:
import numpy as np
h,w,k = map(int,input().split())
c = []
for _ in range(h):
  row = [1 if a=='#' else 0 for a in input()]
  c.append(row)
c = np.array(c).reshape(h,w)
ans = 0
for bith in range(1<<h+w):
  d = np.copy(c)
  for i in range(h+w):
    if (bith>>i)&1:
      if i<h:
        d[i]=0
      else:
        d[:,i-h]=0
  if np.sum(d)==k:
    ans += 1
print(ans)

Submission status: Accepted

Solution code:
#abc173c
h,w,k=map(int,input().split())
l=[list(input()) for i in range(h)]
res=0
for hh in range(2**h):
 for ww in range(2**w):
  cnt=0
  for i in range(h):
   for j in range(w):
    if (hh>>i)&1==0 and (ww>>j)&1==0:
     if l[i][j]=='#':
      cnt+=1
  if cnt==k:
   res+=1
print(res)

Submission status: Accepted

Solution code:
H, W, K = map(int,input().split())
board = [list(input()) for h in range(H)]

ans = 0
for paint_h in range(2 ** H):#すべての行、列の塗り方を二進数列挙
    for paint_w in range(2 ** W):
        cnt = 0
        for h in range(H):
            for w in range(W):
                if (paint_h >> h) & 1 == 0 and (paint_w >> w) & 1 == 0:
            #各行h番目のビットと各列w番目のビット両方が０やったら
            #そのマスは塗られん
                    if board[h][w] == "#":#塗りつぶされんのが黒マスやったら＋１
                        cnt += 1
        if cnt == K: #塗られん黒マスがＫ個やったらans+=1
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq
from itertools import combinations as comb

def subsets(L):
    for i in range(len(L) + 1):
        for c in comb(L, i):
            yield c


def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    h, w, k = rl()
    grid = []
    for i in range(h):
        grid.append(input())


    def test(rows, cols):
        blacks = 0
        for i in range(h):
            if i in rows:
                continue
            for j in range(w):
                if j in cols:
                    continue
                if grid[i][j] == "#":
                    blacks += 1
        return blacks

    ans = 0
    for rowset in subsets(range(h)):
        for colset in subsets(range(w)):
            if test(rowset, colset) == k:
                ans += 1

    print (ans)





mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()

Submission status: Accepted

Solution code:
import numpy as np

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

lis = np.array(lis)
total_black = np.count_nonzero(lis == "#")
row_black = np.count_nonzero(lis == "#", axis=1)
column_black = np.count_nonzero(lis == "#", axis=0)
ans = 0

for i in range(2**H):
  for j in range(2**W):
    black = 0
    for k in range(H):
      if (i >> k)&1:
        black += row_black[k]
      for l in range(W):
        if not k and (j >> l)&1:
          black += column_black[l]
        if (i >> k)&1 and (j >> l)&1:
          black -= np.count_nonzero(lis[k][l] == "#")
    if K == total_black - black:
      ans += 1
                  
print(ans)

Submission status: Accepted

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

ans = 0

for h in range(2**H):
    for w in range(2**W):
        h_s = bin(h)[2:].zfill(6)[::-1]
        w_s = bin(w)[2:].zfill(6)[::-1]
        cnt = 0
        for i, c in enumerate(C):
            for j, a in enumerate(c):
                if h_s[i] == "0"\
                and w_s[j] == "0"\
                and a == "#":
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
h, w, k=map(int, input().split())
table=list(input() for i in range(h))

ans=0
cnt=0

for i in range(2**h):
    for j in range(2**w):
        for s in range(h):
            for t in range(w):
                if table[s][t]=="#" and (i>>s)&1 and (j>>t)&1:
                    cnt+=1
        
        if cnt==k:
            ans+=1

        cnt=0
print(ans)

Submission status: Accepted

Solution code:
import sys
import numpy as np
input = lambda: sys.stdin.readline().rstrip()

def main():
    h, w, k = map(int, input().split())
    c = []
    ans = 0
    for _ in range(h):
        c.append(list(input()))
    grid = np.array(c)
    for i in range(2**(w+h)):
        tmp = grid.copy()
        row, col = [], []
        for j in range(w+h):
            if (i >> j) & 1:
                if j < w:
                    col.append(j)
                else:
                    row.append(j-w)
        tmp = np.delete(tmp, row, 0)
        tmp = np.delete(tmp, col, 1)
        if np.sum(tmp == '#') == k:
            ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
H, W, K = map(int, input().split())
A = []
ans = 0
black = 0
for i in range(H):
  A.append(list(input()))

for i in range(1 << H):
  for j in range(1 << W):
    black = 0
    for m in range(H):
      for n in range(W):
        if A[m][n] == "#" and (i>>m)&1 and (j>>n)&1:
          black += 1
    if black == K:
      ans += 1
      
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0
for i in range(1<<H):
    for j in range(1<<W):
        count = 0
        for h in range(H):
            for w in range(W):
                if ((i>>h)& 1) or ((j>>w)& 1) or C[h][w] == ".":
                    continue
                count += 1
        if count == K:
            ans += 1
print(ans)

Submission status: Accepted

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

for i in range(h):
    lis.append(input())

ans = 0

for rows in range(1 << h):
    for cols in range(1 << w):
        b = 0
        for i in range(h):
            if (rows >> i) & 1 == 1:
                continue
            for j in range(w):
                if (cols >> j) & 1 == 1:
                    continue
                
                if lis[i][j] == "#":
                    b += 1
        
        if b == k:
            ans += 1


print(ans)

Submission status: Accepted

Solution code:
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

h,w,k=mp()
grid=[]
for i in range(h):
    grid.append(input())
ans=0
for i in range(2**h):
    for j in range(2**w):
        c=0
        for x in range(h):
            for y in range(w):
                if ((i>>x)&1) and ((j>>y)&1) and grid[x][y]=="#":
                    c+=1
        if c==k:
            ans+=1
print(ans)

Submission status: Accepted

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

cnt = 0
for rows in range(1 << H):
    for cols in range(1 << W):
        black = 0
        for i in range(H):
            if (rows >> i) % 2 == 1:
                continue
            for j in range(W):
                if (cols >> j) % 2 == 1:
                    continue
                black += c[i][j] == '#'
        if black == K:
            cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
import copy

def to_vector(bit):
    res = []
    id = 0
    while(bit > 0):
        if bit & 1: res.append(id)
        id += 1
        bit >>= 1
    return res


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

c = []
for _ in range(H):
    c.append(list(input()))

ans = 0
for row_bit in range(2 << (H-1)):
    for column_bit in range(2 << (W-1)):
        c_now = copy.deepcopy(c)
        row_vector = to_vector(row_bit)
        column_vector = to_vector(column_bit)
        
        for h in range(H):
            for w in range(W):
                if h in row_vector or w in column_vector:
                    c_now[h][w] = "."

        cnt = 0
        for X in c_now: cnt += X.count("#")
        
        if cnt == K: ans += 1

print(ans)

Submission status: Accepted

Solution code:
import copy
import itertools

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

def check(c, k):
  cnt = 0
  for i in range(len(c)):
    cnt += c[i].count('#')
  if cnt == k:
    return True
  else:
    return False

def make_list(c, h, w):
  for h_ in h:
    c[h_] = ['*'] * len(c[h_])
  for w_ in w:
    for i in range(len(c)):
      c[i][w_] = '*'
  return c

cnt = 0

for i in range(h):
  h_comb = list(itertools.combinations(range(h), i))
  for j in range(w):
    w_comb = list(itertools.combinations(range(w), j))
    for h_ in h_comb:
      for w_ in w_comb:
        c_ = copy.deepcopy(c)
        c_ = make_list(c_, h_, w_)
        if check(c_, k):
          cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

H, W, K = MAP()
grid = [[]] * H
for i in range(H):
    grid[i] = list(input())

ans = 0
for bit1 in range(1<<H):
    for bit2 in range(1<<W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if grid[i][j] == '#' and (not bit1>>i & 1) and (not bit2>>j & 1):
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
H, W, K = map(int, input().split())
c = [input() for i in range(H)]
"""                                                                                                                                  
H = 6                                                                                                                                
W = 6                                                                                                                                
K = 3                                                                                                                                
c = ['...#.#',                                                                                                                       
     '...###',                                                                                                                       
     '#.....',                                                                                                                       
     '...#..',                                                                                                                       
     '...###',                                                                                                                       
     '...##.']                                                                                                                       
"""
ret = 0
for i in range(2**H):
    for j in range(2**W):
        num = 0
        mask_h = str(bin(i))[2:].zfill(H)
        mask_w = str(bin(j))[2:].zfill(W)
        for  k in range(H):
            if mask_h[k] == '0': continue
            for l in range(W):
                if mask_w[l] == '0': continue
                if c[k][l] == '#':
                    num += 1
        if num == K:
            ret += 1

print (ret)

Submission status: Accepted

Solution code:
h, w, k = map(int, input().split())
ans = 0
c = [input() for i in range(h)]
for i in range(1<<h):
    for j in range(1<<w):
        cnt = 0
        for l in range(h):
            for m in range(w):
                if c[l][m] == '#' and (i >> l) & 1 and (j >> m) & 1:
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Submission status: Accepted

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

def check(rows, cols):
  black = 0
  for i in range(h):
    if i in rows: continue
    for j in range(w):
      if j in cols: continue
      if maze[i][j] == "#":
        black += 1

  return black == k

res = 0

for i in range(1<<h):
  paint_rows = []
  for j in range(h):
    if (i>>j)&1:
      paint_rows.append(j)

  for n in range(1<<w):

    paint_cols = []
    for m in range(w):
      if (n>>m)&1:
        paint_cols.append(m)

    if check(paint_rows, paint_cols):
      res += 1

print(res)

Submission status: Accepted

Solution code:
H, W, K = map(int,input().split())
c = []
for i in range(H):
    c.append(list(input()))
ans = 0
for maskR in range(1<<H):
    for maskC in range(1<<W):
        black = 0
        for i in range(H):
            for j in range(W):
                if ((maskR >> i) & 1) == 1 and ((maskC >> j) & 1) == 1 and c[i][j] == '#': black+=1
        if black == K: ans+=1
print(ans)

Submission status: Accepted

Solution code:
# bit全探索
# 全探索して求めたい個数のパターンが見つかったらansにプラス1している。
#
# H:高さ W:幅 K:残したい'#'の個数
# 高さと幅のMAXは6
H,W,K = map(int,input().split())

c = []
ans = 0

# 入力文字の取得
# (例)
# ..#
# ###
for i in range(H):
    c.append(list(input()))

for i in range(2**H): # 000000, 000001, 0000010, 000011, ..., 111111

    for j in range(2**W): # 000000, 000001, 0000010, 000011, ..., 111111

        now = 0
        for x in range(H): # 0, 1, ..., 5行
            for y in range(W): # 0, 1, ..., 5列

                # 高さ：i(000000) の一番右の桁から順番に見ていき、&が1
                # 幅　：i(000000) の一番右の桁から順番に見ていき、&が1
                # そして"#"のときにカウントを1増やす。
                # ↓これでも良いみたいだけど、よくわからなかった。
                # if 2**x & i > 0 and 2**y & j > 0 and c[x][y] == "#":
                if i >> x & 1 and j >> y & 1 and c[x][y] == "#":
                    now += 1

        # nowが今回求めたい個数の場合にansをプラス1する
        if now == K:
            ans += 1

print (ans)

Submission status: Accepted

Solution code:
def C():
    H, W, K = map(int, input().split())
    C = []
    for _ in range(H):
        C.append(input())
    count = 0
    for mask_i in range(2**H-1):
        for mask_j in range(2**W-1):
            black = 0
            for i in range(H):
                for j in range(W):
                    if mask_i >> i & 1 == 0 and mask_j >> j & 1 == 0 and C[i][j] == '#':
                        black += 1
            if black == K:
                count += 1
    print(count)

C()

Submission status: Accepted

Solution code:
from itertools import *

h, w, k = map(int, input().split())
c = []
ans = 0

for i in range(h):
    c.append(input())

count = 0

for i in range(h+1):
    conbI = list(combinations(list(range(h)), i))

    for j in range(w+1):
        conbJ = list(combinations(list(range(w)), j))

        for tupleI in conbI:
            for tupleJ in conbJ:
                temp = 0
                for x in range(h):
                    for y in range(w):
                        if x in tupleI or y in tupleJ:
                            continue
                        else:
                            if c[x][y] == '#':
                                temp += 1

                if temp == k:
                    ans += 1


print(ans)

Submission status: Accepted

Solution code:
import copy
(H,W,K) = map(int,input().split())
l = [[0 for i in range(W)] for j in range(H)]
ans = 0
for i in range(H):
    a = input()
    for j in range(W):
        l[i][j]=a[j]

t = [0 for i in range(W)]
y = [0 for i in range(H)]

for i in range(H):
    for j in range(W):
        if l[i][j]=='#':
            t[j]+=1
            y[i]+=1

sum = 0

for i in range(H):
    sum += y[i]

for i in range(1<<H):
    for j in range(1<<W):
        S = sum
        Y = copy.deepcopy(y)
        T = copy.deepcopy(t)
        for k in range(H):
            if i>>k&1:
                S-=Y[k]
                for q in range(W):
                    if l[k][q]=='#':
                        T[q]-=1
        for p in range(W):
            if j>>p&1:
                S-=T[p]
        if S == K:
            ans += 1
            #print(str(i)+"-"+str(j))
            #print(sum)
        
#print(T)
#print(Y)
#print(S)
print(ans)

Submission status: Accepted

Solution code:
from itertools import product

h, w, k = map(int, input().split())
c = [input() for _ in range(h)]
ans = 0
for bh in product([0, 1], repeat=h):
    for bw in product([0, 1], repeat=w):
        cnt = 0
        for i, j in enumerate(bh):
            for x, y in enumerate(bw):
                if j == 1 and y == 1 and c[i][x] == "#":
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
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())
C = np.frombuffer(read(), 'S1').reshape(H, -1)[:, :W]
 
C = 1 * (C == b'#')
 
def f(C, x, y):
    rows = [i for i in range(H) if x & (1<<i)]
    cols = [i for i in range(W) if y & (1<<i)]
    D = C[rows][:,cols]
    return D.sum() == K
 
ans = 0
for x in range(1 << H):
    for y in range(1 << W):
        ans += f(C, x, y)
print(ans)

Submission status: Accepted

Solution code:
h,*c=open(0)
h,w,k=map(int,h.split())
print(sum(k==sum(y>>w+z//w&y>>z%w&ord(c[z//w][z%w])&1for z in range(h*w))for y in range(1<<h+w)))

Submission status: Accepted

Solution code:
def b_in_row(row):
  return sum([1 if c == '#' else 0 for c in row])

def in_flag(value, flag):
  return bool((1 << value) & flag)

def count_removes(h, w, row_flag, col_flag):
  tbr = 0
  for row in range(h):
    if in_flag(row, row_flag):
      tbr += b_in_row(m[row])
    else:
      for col in range(w):
        if in_flag(col, col_flag):
          if m[row][col] == '#':
            tbr += 1
  return tbr

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

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

black = sum([b_in_row(row) for row in m])

remove = black - k

ans = 0
for row_flag in range(1 << h):
  for col_flag in range(1 << w):
    tbr = count_removes(h, w, row_flag, col_flag)
    
    if tbr == remove:
      ans += 1

print(ans)

Submission status: Accepted

Solution code:
h, w, k = map(int, input().split())
C = []
for _ in range(h): C.append(input())
import itertools
ans = 0
for hbit, wbit in itertools.product(range(1<<h), range(1<<w)):
    c = 0
    for i, j in itertools.product(range(h), range(w)):
        if hbit>>i & 1 and wbit>>j & 1 and C[i][j] == '#': c += 1
    if c == k: ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools
h,w,k = map(int,input().split())
grid = []
black = 0
cnt = 0
for _ in range(h):
    s = input()
    grid.append(s)
#print(grid)

row = list(itertools.product([0,1],repeat=h))
column = list(itertools.product([0,1],repeat=w))
result = 0
for i in row:
    for j in column:
        cnt = 0
        for m in range(len(i)):
            for n in range(len(j)):
                if i[m]==0 and j[n] == 0 and grid[m][n] == '#':
                    cnt += 1

        if cnt == k:
            #print("i,j",i,j)
            result += 1

print(result)

Submission status: Accepted

Solution code:
h, w, k = map(int, input().split())
C = []
for _ in range(h): C.append(input())
ans = 0
for hbit in range(1<<h): # red row bit
    for wbit in range(1<<w): # red col bit
        c = 0
        for i in range(h):
            for j in range(w):
                if hbit>>i & 1 and wbit>>j & 1 and C[i][j] == '#': c += 1
        if c == k: ans += 1
print(ans)

Submission status: Accepted

Solution code:
h, w, k = map(int, input().split())
c = [input() for _ in range(h)]
ans = 0
for bi in range(1<<h):
    for bj in range(1<<w):
        tmp = sum(c[i][j]=='#' for i in range(h) for j in range(w) if (bi>>i&1) and (bj>>j&1))
        if tmp==k:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import itertools

h, w, k = map(int, input().split())
s = [0] * h
countH = [0] * h
countW = [0] * w
ans = []
ans_sub = [[0 for j in range(2)] for i in range(h * w)]
num = 0
ans_count = 0

for i in range(h):
    s[i] = list(input())
    for j in range(w):
        if s[i][j] == '#':
            ans_sub[num][0] = i
            ans_sub[num][1] = j + h
            ans.append(ans_sub[num])
            num += 1

lis = list(range(h + w))
#print(ans)

for n in range(h + w):
    for pair in itertools.combinations(lis, n + 1):
        count = 0
        for i in range(len(ans)):  # blacklist
            if (ans[i][0] not in pair) and (ans[i][1] not in pair):
                count += 1  # その黒がけずられないか
            
        if count == k:
            #print(len(ans), count)
            ans_count += 1
            #print(ans_count)
if k == len(ans):
    ans_count += 1

print(ans_count)

Submission status: Accepted

Solution code:
h, w, k = map(int, input().split())
ans = 0
c = [input() for i in range(h)]
for i in range(1<<h):
    for j in range(1<<w):
        cnt = 0
        for l in range(h):
            for m in range(w):
                if c[l][m] == '#' and (i >> l) & 1 and (j >> m) & 1:
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
# https://www.youtube.com/watch?v=-ZvzikEQkPY
# bit全探索
H, W, K = map(int, input().split())
c = [input() for _ in range(H)]
result = 0
"""
bit全探索
1<<HOGE=2^HOGE
根元事象が2のコインのようなものが得意
"""


for rows in range(1 << H):
    for cols in range(1 << W):
        black = 0
        # bitが1になっているか2重ループで探索
        # 赤なら黒ではないからcontinue
        # それ意外ならblackカウンタインクリメント
        for i in range(H):
            if (rows >> i) % 2 == 1:
                continue
            for j in range(W):
                if (cols >> j) % 2 == 1:
                    continue
                if c[i][j] == "#":
                    black += 1
        if black == K: # ループのなかで条件に合う場合をカウントする
            result += 1

print(result)

Submission status: Accepted

Solution code:
import numpy as np

H,W,K=map(int,input().split())
E=[]
for e in range(H):
    _=input()
    temp=_.replace('#','1').replace('.','0')
    
    E.append(list(map(int,temp)))

Arr=np.array(E)
# print(Arr)
FA=0

for h in range (2**H):
    # print("h:{0}が始まるよ。".format(h))
    select_H=[]
    for i in range (H):
        if (h>>i) & 1==1:
            select_H.append(1)
        else:
            select_H.append(0)
    sHarr=np.array(select_H)
    delSHarr=np.where(sHarr==1)
    # print(sHarr)
    # print(delSHarr)
    _ans=np.delete(Arr,delSHarr,axis=0)
    # print('________________ans__________________')
    # print(_ans)

    for w in range (2**W):
        # print("w:{0}が始まるよ。".format(w))
        select_W=[]
        for j in range (W):
            if (w>>j) &1 ==1:
                select_W.append(1)
            else:
                select_W.append(0)
        sWarr=np.array(select_W)
        delsWarr=np.where(sWarr==1)
        ans=np.delete(_ans,delsWarr,axis=1)
        # print("***ans***")
        # print(ans)

        if np.sum(ans)==K:
            FA+=1

print(FA)



# for x in range(2**H):
    
    # ans=np.delete(_ans,sWarr,axis=1)
# print(ans)

Submission status: Accepted

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

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

ans = 0
for ii in range(2**H):
    for jj in range(2**W):
        tmp = 0
        for i in range(H):
            for j in range(W):
                # print(ii>>i, jj>>j)
                if (ii>>i)&1 or (jj>>j)&1:
                    continue
                if C[i][j] =="#":
                    tmp += 1
        if tmp == K:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
h, w, k = map(int, input().split())

c = [input() for _ in range(h)]
ret = 0
for i_s in range(2 ** h):
    for j_s in range(2 ** w):
        black = 0
        for i in range(h):
            for j in range(w):
                if (i_s >> i)&1 == 1:
                    continue
                if (j_s >> j)&1 == 1:
                    continue
                if c[i][j] == "#":
                    black += 1
        
        if black == k:
            ret += 1

print(ret)

Submission status: Accepted

Solution code:
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
H,W,K = map(int,readline().split())
grid = [list(readline().decode().rstrip()) for _ in range(H)]
black_cnt = 0
for i in range(H):
  for j in range(W):
    if grid[i][j] == '#':
      black_cnt += 1
erase_cnt = black_cnt - K
ans = 0
for bit_H in range(1 << H):
    for bit_W in range(1 << W):
        cnt = 0 
        for i in range(H):
            for j in range(W):
                if (((bit_H >> i) & 1) or ((bit_W >> j) & 1)) and grid[i][j] == '#':
                    cnt += 1              
        if erase_cnt == cnt:
            ans += 1
print(ans)

Submission status: Accepted

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

A = 0
for ibit in range(2 ** H):
    for jbit in range(2 ** W):
        B = 0
        for i in range(H):
            for j in range(W):
                if (ibit & (1 << i)) or (jbit & (1 << j)):
                    continue
                if c[i][j] == '#':
                    B += 1
        if B == K:
            A += 1
print(A)

Submission status: Accepted

Solution code:
import itertools
H, W, K = map(int, input().split())
ans = 0
pattern = []

for i in range(H):
  pattern.append(list(input()))

for i in itertools.product([0,1], repeat=H):
  for j in itertools.product([0,1], repeat=W):
    numsharp = 0
    for h in range(H):
      for w in range(W):
        if i[h] == 0 and j[w] == 0:
          if pattern[h][w] == '#':
            numsharp += 1
    if numsharp == K:
      ans += 1

print(ans)

Submission status: Accepted

Solution code:
h,*c=open(0)
h,w,k=map(int,h.split())
print(sum(k==sum(y>>w+z//w&y>>z%w&1and'.'>c[z//w][z%w]for z in range(h*w))for y in range(1<<h+w)))

Submission status: Accepted

Solution code:
import copy
def board_check(tmp_board):
    count=0
    for i in range(H):
        for j in range(W):
            if tmp_board[i][j]=='#':
                count+=1
    if count == K:
        return 1
    else:
        return 0
if __name__ == "__main__":
    H,W,K = map(int,input().split())
    board = [list(input()) for _ in range(H)]
    n_H=2**H
    n_W = 2**W
    cnt = 0
    for i in range(n_H):
        l_h=[]
        for ih in range(H):
            if i>>ih & 1:
                l_h.append(ih)
        for j in range(n_W):
            tmp_board=copy.deepcopy(board)
            #print(tmp_board)
            l_w =[]
            for jw in range(W):
                if j >> jw & 1:
                    l_w.append(jw)
            #print("l_h:",l_h)
            #print("l_w:",l_w)
            #処理
            #print(l_h,l_w)
            if l_h :
                for x in l_h:
                    for j in range(W):
                        tmp_board[x][j] = 'x'
                #print(tmp_board)
            if l_w:
                for x in l_w:
                    for j in range(H):
                        tmp_board[j][x] = 'x'
            if board_check(tmp_board)==1:
                #print("ok")
                #print(l_h,l_w)
                cnt+=board_check(tmp_board)
    print(cnt)

Submission status: Accepted

Solution code:
import itertools

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

for i in range(H):
  c = list(input())
  C.append(c)
  
ans = 0

for h in itertools.product([0, 1], repeat = H):
  for w in itertools.product([0, 1], repeat = W):
    cnt = 0
    for i in range(H):
      for j in range(W):
        if h[i] == 0 and w[j] == 0 and C[i][j] == "#":
          cnt += 1
    if cnt == K:
      ans += 1

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

H, W, K = inm()
grid = [ins() for _ in range(H)]


def solve():
    ans = 0
    for i in range(1 << H):
        for j in range(1 << W):
            cnt = 0
            for r in range(H):
                if i & (1 << r):
                    continue
                for c in range(W):
                    if j & (1 << c):
                        continue
                    if grid[r][c] == "#":
                        cnt += 1
            if cnt == K:
                ans += 1

    return ans


print(solve())

Submission status: Accepted

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

mat = []
for i in range(H):
	mat.append(str(input()))

num = 0
for i in range(H):
	for j in range(W):
		if mat[i][j] == '#':
			num += 1

ans = 0
for i in range(1<<H):
	for j in range(1<<W):
		cnt = 0
		for ii in range(H):
			for jj in range(W):
				if (i>>ii) & 1 == 1 and (j>>jj) & 1 == 1 and mat[ii][jj] == '#':
					cnt += 1
		if cnt == K:
			ans += 1

print(ans)