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 and V

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

c = [list(str(input())) for j in range(h)]

ans = 0

for maskR in range(2**h):
    for maskC in range(2**w):
        black = 0
        for i in range(h):
            for j in range(w):
                if ((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0 and c[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1

print(ans)

Submission status: Accepted

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

ans = 0
for row in range(1<<h):
    for col in range(1<<w):
        d = copy.deepcopy(c)
        sum = 0
        for i in range(h):
            if row & (1<<i):
                for j in range(w):
                    d[i][j] = '.'
        for j in range(w):
            if col & (1<<j):
                for i in range(h):
                    d[i][j] = '.'

        for i in range(h):
            for j in range(w):
                if d[i][j] == '#':
                    sum+=1
        if sum == k:
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
H,W,K = map(int,input().split())
init_map = []
for i in range(H):
    row = list(input())
    init_map.append(row)
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 init_map[i][j] == "#":
                        cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
H,W,K = (int(x) for x in input().split())

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

counter = 0
for h in range(1<<H):
    for w in range(1<<W):
        hmask = format(h, 'b').zfill(H)
        wmask = format(w, 'b').zfill(W)

        bcounter = 0
        for i in range(H):
            for j in range(W):
                if hmask[i] == '0' and wmask[j] == '0' and c[i][j] == '#':
                     bcounter += 1
        if bcounter == K:
            counter += 1

print(counter)

Submission status: Accepted

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

ans = 0
for maskR in range(1 << H):
  for maskC in range(1 << W):
    blk = 0
    
    for i in range(H):
      for j in range(W):
        if ((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0 and c[i][j] == '#':
          blk += 1
    if blk == K:
      ans += 1
    
print(ans)

Submission status: Accepted

Solution code:
def main():
    from itertools import product

    H, W, K = map(int, input().split())
    G = [input() for _ in range(H)]

    tot = sum(g.count('#') for g in G)

    ans = 0
    for row_select in product([0, 1], repeat=H):
        for col_select in product([0, 1], repeat=W):
            cnt = tot
            for r, ser in enumerate(row_select):
                for c, sec in enumerate(col_select):
                    if (G[r][c] == '#') and (ser or sec):
                        cnt -= 1
            if cnt == K:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok

Submission status: Accepted

Solution code:
def main():
  h, w, k = map(int, input().split())
  s = [input() for _ in range(h)]
  ans = 0
  for i in range(2**h):
    for j in range(2**w):
      if z(s, b(j, w), b(i, h)) == k:
        ans += 1
  print(ans)


def z(s, row, col):
  return sum(
    sum(0 if s[i][j] == '.' or c or r else 1 for j, r in enumerate(row))
    for i, c in enumerate(col)
  )

def b(n, digit):
  return [n // (2**i) % 2 for i in range(digit)]

main()

Submission status: Accepted

Solution code:
import copy
h,w,k=map(int,input().split())
c=[[[".","#"].index(j)for j in list(input())]for i in range(h)]
p=0
for i in range(2**h):
    a=bin(i)[2:].zfill(h)
    for j in range(2**w):
        b=bin(j)[2:].zfill(w)
        d=copy.deepcopy(c)
        for x in range(w):
            if b[x]=="1":
                for y in range(h):
                    d[y][x]=0
        for x in range(h):
            if a[x]=="1":
                d[x]=[0]*w
        q=0
        for x in d:
            q+=sum(x)
        if q==k:
            p+=1
print(p)

Submission status: Accepted

Solution code:
H, W, K = map(int,(input().split()))
c = []
for _ in range(H):
  c.append(input())
ans = 0
for maskR in range((1<<H)-1):
  for maskC in range((1<<W)-1):
    black=0
    for i in range(H):
      for j in range(W):

        if ((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0 and  c[i][j] == '#': 
           black += 1
    if black == K:

      ans += 1
print(ans)

Submission status: Accepted

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

for i in range(2**h):
    l=copy.deepcopy(mylist)
    for j in range(h):
        if (i>>j&1):
            for q in range(w):
                l[j][q]="!"
    for m in range(2**w):
        l2=copy.deepcopy(l)
        for n in range(w):
            if (m>>n&1):
                for o in range(h):
                    l2[o][n]="!"
        cnt=0
        for p in range(h):
            cnt+=l2[p].count("#")
        if cnt==k:
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
def ten2bi(i, N):
    bi_list = []    #二進数表記のリスト(ex. ten2bi(31, 5)  -> [1, 1, 1, 1, 1])
    for j in range(N):
        if i >= 2**(N - j - 1):
            bi_list.append(1)
            i -= 2**(N - j - 1)
        else:
            bi_list.append(0)

    return bi_list

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

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

ans = 0
k = 0

for i in range(2**H):
    for j in range(2**W):
        row_list = ten2bi(i, H)
        column_list = ten2bi(j, W)
        for h in range(H):
            for w in range(W):
                if row_list[h] == 0 and column_list[w] == 0:
                    if c_list[h][w] == '#':
                        k += 1
        if k == K:
            ans += 1
        k = 0

print(ans)

Submission status: Accepted

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

black_num = 0
temp_list = []
row_bit = []
line_bit = []

ans = 0

# for cnt_h in range(h):
#     for cnt_w in range(w):
#         if c[cnt_h][cnt_w] == "#":
#             black_num += 1
# if black_num == k:
#     print(1)
if 1 == 2:
    print()
else:
    for i in range(2**h):
        temp_bit = [0] * h

        for j in range(h):
            if((i >> j) & 1):
                temp_bit[h - 1 - j] = 1

        row_bit.append(temp_bit)

    for i in range(2**w):
        temp_bit = [0] * w

        for j in range(w):
            if((i >> j) & 1):
                temp_bit[w - 1 - j] = 1

        line_bit.append(temp_bit)

    # print(row_bit)
    # print(line_bit)

    for cnt_row in range(2**h):
        for cnt_line in range(2**w):
            temp_list = []
            black_num = 0
            for cnt_h in range(h):
                if row_bit[cnt_row][cnt_h] == 0:
                    # temp_list.append(c[cnt_h])
                    for cnt_w in range(w):
                        if line_bit[cnt_line][cnt_w] == 0:
                            # print("this", temp_list[cnt_line][cnt_w])
                            if c[cnt_h][cnt_w] == '#':
                                black_num += 1

            # black_num = 0
            # for cnt_h in range(len(temp_list)):
            #     for cnt_w in range(len(temp_list[cnt_h])):
            #         if temp_list[cnt_h][cnt_w] == "#":
            #             black_num += 1
            if black_num == k:
                ans += 1

    print(ans)

Submission status: Accepted

Solution code:
h,w,k1=map(int,input().split())
c=[]
ans=0
for i in range(h):
    c.append(list(input()))
for i in range(2**(h+w)):
    lh=[]
    lw=[]
    num=0
    for j in range(h):
        if (i >> j) & 1:
            lh.append(j)
    for j in range(h,h+w):
        if (i >> j) & 1:
            lw.append(j-h)
    for j in range(len(lh)):
        for kk in range(len(lw)):
            if c[lh[j]][lw[kk]]=="#":
                num+=1
    if num==k1:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
import copy
import itertools

H,W,K = map(int,input().split())
C=[]
Hl=[]
Wl=[]
for h in range(H):
  C.append(list(input()))
  
for i in range(H+1):
  Hl+=list(map(list,itertools.combinations(range(H),i)))
for i in range(W+1):
  Wl+=list(map(list,itertools.combinations(range(W),i)))

def check (D):
  count=0
  for h in range(H):
    for w in range(W):
      if(D[h][w]=="#"):
        count+=1
  return count

def paint (D):
  ans=0
  for hl in Hl:
    for wl in Wl:
      D1 = copy.deepcopy(D)
      count =0
      for h in range(H):
        for w in range(W):
          if(h in hl or w in wl):
            D1[h][w] ="r"
      if(K==check(D1)):
        ans +=1
  return ans

print(paint(C))

Submission status: Accepted

Solution code:
h,w,k = map(int,input().split())
c = [list(input()) for _ in range(h)]
cnt = 0
for p_h in range(2**h):
    for p_w in range(2**w):
        black = 0
        for i in range(h):
            for j in range(w):
                if (p_h>>i)&1==0 and (p_w >> j)&1==0:
                        if c[i][j]=='#':
                            black += 1
        if black == k:
            cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
from itertools import product
h,w,k=map(int,input().split())
M=[input() for i in range(h)]
a=0
for A in product([0,1],repeat=h):
    for B in product([0,1],repeat=w):
        ANS=0
        for i in range(h):
            for j in range(w):
                if M[i][j]=='#' and A[i]==0 and B[j]==0:
                    ANS+=1
        if ANS==k:
            a+=1

print(a)

Submission status: Accepted

Solution code:
h,w,k=map(int,input().split())
c=[list(input()) for _ in range(h)]
ans=0
 
for a in range(2**h):
    sa="0"+str(h)+"b"
    la=list(format(a,sa))
    for b in range(2**w):
        sb = "0" + str(w) + "b"
        lb = list(format(b, sb))
        cnt=0
        for i in range(h):
            for j in range(w):
                if la[i]!="1" and lb[j]!="1" and c[i][j]=="#":
                    cnt+=1
        if cnt==k:
            ans+=1
print(ans)

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

h,w,k = inpm()
c=inplL(h)
ans=0
for i in range(2**h):
    for j in range(2**w):
        cnt=0
        for hh in range(h):
            for ww in range(w):
                if (i>>hh)&1 != 1 and (j>>ww)&1 != 1 and c[hh][ww]=='#':
                    cnt+=1
        if cnt==k:
            ans+=1
                
print(ans)

Submission status: Accepted

Solution code:
import numpy as np



def power_set(item_lists):

    p_sets = [[]]

    for item in item_lists:
        tmp = []
        for element in p_sets:
            tmp.append(element + [item])
        p_sets.extend(tmp)

    return p_sets

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

mat = [input() for l in range(H)]
mat = [[s[i] for i in range(W)] for s in mat]

mat = np.array([[(0 if mat[i][j]=='.' else 1) for j in range(W)] for i in range(H)])

row_sums=np.array([np.sum(mat[i]) for i in range(H)])
column_sum=np.array([np.sum(mat[:,i]) for i in range(W)])


row_sets=power_set(list(range(H)))
column_sets=power_set(list(range(W)))

preB=np.sum(row_sums)
count=0
for row_set in row_sets:
    for column_set in column_sets:
# =============================================================================
#         print(row_set,column_set)
#         print(np.sum(row_sums[row_set]),np.sum(column_sum[column_set]))
#         print(np.sum(mat[row_set,column_set]))
# =============================================================================
        dupli=sum([sum([mat[i][j] for j in column_set]) for i in row_set])
        remain=preB-np.sum(row_sums[row_set])-np.sum(column_sum[column_set])+dupli

        if remain==K: 
            count+=1

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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+w)):
    lh=[]
    lw=[]
    num=0
    for j in range(h):
        if (i >> j) & 1:
            lh.append(j)
    for j in range(h,h+w):
        if (i >> j) & 1:
            lw.append(j-h)
    for j in range(len(lh)):
        for kk in range(len(lw)):
            if c[lh[j]][lw[kk]]=="#":
                num+=1
    if num==k:
        ans+=1
print(ans)

Submission status: Accepted

Solution code:
from itertools import combinations
h,w,k=[int(i) for i in input().split()]
a=[]
for i in range(h):
    a.append([i for i in input()])
# creating permutations of all lengths and values
ha=[int(i) for i in range(h)]
wa=[int(i) for i in range(w)]
cnt=0
for i in range(h):
    cnt+=a[i].count('#')
ans=0
for i in range(h):
    p=list(combinations(ha,i))
    for j in range(w):
        q=list(combinations(wa,j))
        for ii in p:
            for jj in q:
                da=[i[:] for i in a]
                for iii in ii:
                    for iiii in range(w):
                        if da[iii][iiii]=='#': da[iii][iiii]='.'
                for jjj in jj:
                    for jjjj in range(h):
                        if da[jjjj][jjj]=='#': da[jjjj][jjj]='.'
                chk=0
                for i in range(h):
                    chk+=da[i].count('#')
                if chk==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 row in range(1<<H):
  for col in range(1<<W):
    count=0
    
    for i in range(H):
      for j in range(W):
        if c[i][j]=="#" and row&(1<<i)==0 and col&(1<<j)==0:
          count+=1
    if count==K:
      ans += 1
    
print(ans)

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 a in range(2**H):
    for b in range(2**W):
        black=0
        for i in range(H):
            for j in range(W):
                if ((a >> i) & 1) and ((b >> j) & 1) and c[i][j] == '#':
                    black += 1
        if black == K:
            ans += 1
print(ans)

Submission status: Accepted

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

n = 0
for i in range(1<<h):
    for j in range(1<<w):
        cnt = 0
        for x in range(h):
            for y in range(w):
                if i >> x & 1 and j >> y & 1:
                    if A[x][y] == '#':
                        cnt += 1
        if cnt == k:
            n += 1
print(n)

Submission status: Accepted

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

ans = 0
for i in range(2**H):
    for j in range(2**W):
        cnt = 0
        for p in range(H):
            for q in range(W):
                if (i >> p) & 1 or (j >> q) & 1:
                    continue
                else:
                    if field[p][q] == "#":
                        cnt += 1
        if cnt == 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 row in range(1<<H):
  for col in range(1<<W):
    count=0
    for i in range(H):
      for j in range(W):
        if row&(1<<i)==0 and col&(1<<j)==0 and c[i][j]=="#":
          count+=1
    if count==K:
      ans+=1
print(ans)

Submission status: Accepted

Solution code:
from itertools import product
import copy
H,W,K = map(int,input().split())
S = [input().strip() for _ in range(H)]
A = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            A[i][j] = 1
cnt = 0
for x in product((0,1),repeat=H):
    for y in product((0,1),repeat=W):
        B = copy.deepcopy(A)
        for i in range(H):
            if x[i]==1:
                for j in range(W):
                    B[i][j]=0
        for j in range(W):
            if y[j]==1:
                for i in range(H):
                    B[i][j]=0
        tot=0
        for i in range(H):
            for j in range(W):
                tot += B[i][j]
        if tot==K:
            cnt += 1
print(cnt)

Submission status: Accepted

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

ans = 0
for ib in range(1<<h):
    for jb in range(1<<w):
        black = 0
        for i in range(h):
            if ib & (1<<i): continue
            for j in range(w):
                if jb & (1<<j): continue
                black += c[i][j]=="#"
        if black == k: ans += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

H, W, K = mapint()

query = [list(input()) for _ in range(H)]
ans = 0
for i in range(1<<H):
    for j in range(1<<W):
        cnt = 0
        for h in range(H):
            for w in range(W):
                if not (i>>h)&1 and not (j>>w)&1:
                    if query[h][w]=='#':
                        cnt += 1
        if cnt==K:
            ans += 1

print(ans)

Submission status: Accepted

Solution code:
def base10toN(num, base):
    converted_string, modstring = "", ""
    currentnum = num
    if not num:
        return '0'
    while currentnum:
        mod = currentnum % base
        currentnum = currentnum // base
        converted_string = chr(48 + mod + 7*(mod > 10)) + converted_string
    return converted_string
h,w,k=map(int,input().split())
c=[]
for i in range(h):
  a=input()
  c.append(a)
ans=0
for i in range(2**h):
  iconvert=base10toN(i,2)
  ic=[]
  for _ in range(h-len(iconvert)):
    ic.append('0')
  for _ in range(len(iconvert)):
    ic.append(iconvert[_])
  for j in range(2**w):
    jconvert=base10toN(j,2)
    jc=[]
    for _ in range(w-len(jconvert)):
      jc.append('0')
    for _ in range(len(jconvert)):
      jc.append(jconvert[_])
    count=0
    for a in range(h):
      for b in range(w):
        if ic[a]=='0' and jc[b]=='0' and c[a][b]=='#':
          count+=1
    if count==k:
      ans+=1
print(ans)

Submission status: Accepted

Solution code:
h, w, k = map(int, input().split())
c = []
for _ in range(h):
    c.append(input())
ans = 0
for i in range(2**h):
    for j in range(2**w):
        tmp = 0
        for y in range(h):
            for x in range(w):
                if i>>y&1 or j>>x&1 or c[y][x]=='.':
                    continue
                tmp += 1
        if tmp==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 a in range(2**H):
    for b in range(2**W):
        cnt = 0
        for i in range(H):
            if a & (1<<i) > 0:
                continue
            for j in range(W):
                if b & (1<<j) > 0:
                    continue
                if C[i][j] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Submission status: Accepted

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

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

for i in range(2 ** h):
  for j in range(2 ** w):
    now = 0
    for x in range(h):
      for y in range(w):
        if not (i >> x) & 1 and not (j >> y) & 1 and c[x][y] == '#':
          now += 1
    if now == k:
      ans += 1

print(ans)

Submission status: Accepted

Solution code:
H, W, K = (int(i) for i in input().split())  

d = [[0 for i in range(W)] for j in range(H)]
for i in range(H):
  R = input()
  for j, X in enumerate(R):
    if X == '#':
      d[i][j] = 1

ans = 0
for maskW in range(2 ** W):
  for maskH in range(2 ** H):
    tmp = 0
    for i in range(H):  # このループが一番のポイント
      for j in range(W): 
        if ((maskW >> j) & 1) and ((maskH >> i) & 1):
          if d[i][j] == 1:
            tmp += 1
            
    if tmp == K:
      #print(maskW, maskH)
      ans += 1

print(ans)

Submission status: Accepted

Solution code:
import itertools
import copy

def countKuro(table):
	return sum(sum(table, []))

height, width, kuro = map(int, input().split())

constanttable = []
for _ in range(height):
	line = []
	str = input()
	for char in str:
		if char == '.':
			line.append(0)
		else:
			line.append(1)
	constanttable.append(line)

counter = 0
heightconds = list(itertools.product(range(2), repeat = height))
widthconds = list(itertools.product(range(2), repeat = width))

for h, heightcond in enumerate(heightconds):
	table = copy.deepcopy(constanttable)
	for l, linecond in enumerate(heightcond):
		if linecond == 1:
			table[l] = [0] * width

	if countKuro(table) < kuro:
		continue

	for widthcond in widthconds:
		transposed_table = list(map(list, zip(*table)))
		for c, columncond in enumerate(widthcond):
			if columncond == 1:
				transposed_table[c] = [0] * height

		if countKuro(transposed_table) == kuro:
			counter += 1

print(counter)

Submission status: Accepted

Solution code:
def editorial():
    h, w, k = map(int, input().split())
    mat = []
    for r in range(h):
        mat.append(list(input()))
    
    ans = 0
    for rowmask in range(0, 1<<h):
        for colmask in range(0, 1<<w):
            count = 0
            for r in range(h):
                for c in range(w):
                    if (rowmask>>r)&1 == 0 and (colmask>>c)&1 == 0 and mat[r][c] == '#': count += 1
            if count == k: ans += 1
    print(ans)

editorial()

Submission status: Accepted

Solution code:
import numpy as np
import itertools
H,W,K=map(int,input().split())
arr=np.array([list(input()) for _ in range(H)])
ans=0
for h in range(1,H+1):
    for w in range(1,W+1):
        hl=list(itertools.combinations(list(range(H)), h))
        wl=list(itertools.combinations(list(range(W)), w))
        
        for hl_ in hl:
            for wl_ in wl:
                if sum(np.ravel(arr[np.ix_(hl_,wl_)])=='#') == K:
                    ans+=1
print(ans)

Submission status: Accepted

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

from itertools import product
ans = 0
for mask in product(['0', '1'], repeat = h + w):
    mask = int(''.join(mask), 2)
    count = 0
    for r in range(h):
        for c in range(w):
            if ((mask >> r)&1 == 0) and ((mask >> (h + c))&1 == 0) and mat[r][c] == '#':
                count +=1
    if count == k: ans += 1
print(ans)

Submission status: Accepted

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

ans = 0
for h_bit in range(1 << H):
	for w_bit in range(1 << W):
		black = 0
		for i in range(H):
			for j in range(W):
				if h_bit & (1 << i) and w_bit & (1 << j):
					if C[i][j] == '#':
						black += 1
		if black == K:
			ans += 1
			
print(ans)

Submission status: Accepted

Solution code:
h,w,k=map(int,input().split())
c=[input() for i in range(h)]
ans=0
for h_1 in range(1<<h):
  for w_1 in range(1<<w):
    black=0
    for i in range(h):
      for j in range(w):
        if (h_1>>i)&1==0 and (w_1>>j)&1==0 and c[i][j]=='#': #該当マスが最初の時点で黒く、そのマスが属する行と列が赤く塗られていないとき
          black+=1
    if black==k:
      ans+=1
print(ans)

Submission status: Accepted

Solution code:
from itertools import *
from copy import *

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

grid = list(
  i for i in ''.join(
  	str(input()) for i in range(H)
	)
)

H_p = list(product([0,1], repeat=H))
W_p = list(product([0,1], repeat=W))

#0:塗る, 1:塗らない

ans = 0

for h_p in H_p:
  for w_p in W_p:
    grid_ = copy(grid)
    
    for h in range(H):
      if h_p[h] == 0:
        for _w in range(W):
          grid_[_w + h*W] = '*'
    
    for w in range(W):
      if w_p[w] == 0:
        for _h in range(H):
          grid_[w + _h*W] = '*'
          
    if grid_.count('#') == K:
      ans += 1
      #print(w_p, h_p)
          
        

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(2**H-1):
  for j in range(2**W-1):
    h=list(str(format(i,"b").zfill(H)))
    w=list(str(format(j,"b").zfill(W)))
    black=0
    for l in range(H):
      for m in range(W):
        if h[l]=="0" and w[m]=="0":
          if board[l][m]=="#":
            black+=1
    if black==K:
      ans+=1
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
h,w,k = map(int,input().split())
c = []
for _ in range(h):
    c.append(list(input()))
c = np.array(c)
c = 1*(c == "#")

def test(c,y,x):
    d = c.copy()
    for i in range(h):
        if (1 << i) & y:
            d[i,:] = 0
    for i in range(w):
        if (1 << i) & x:
            d[:,i] = 0
    return (d.sum() == k)
asum = 0
for y in range(1 << h):
    for x in range(1 << w):
        asum += test(c,y,x)
print(asum)

Submission status: Accepted

Solution code:
import numpy as np
h,w,k=map(int,input().split())
trout=np.zeros((h,w))
cnt=0
for i in range(h):
  a=list(input())
  for j in range(w):
    if a[j]=="#":
      trout[i][j]=1
    else:
      trout[i][j]=0
for i in range(2**(h+w)):
  test=np.copy(trout)
  for j in range(h+w):
    if (i>>j)&1:
      if h+w-j>h:
        test[:,w-j-1]=0
      else:
        test[h+w-j-1,:]=0
  if test.sum()==k:
    cnt+=1
print(cnt)

Submission status: Accepted

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

ans = 0

for h_1 in range(2**h):
    for w_1 in range(2**w):
        black = 0

        for i in range(h):
            for j in range(w):
                if (h_1 >> i) & 1 == 0 and (w_1 >> j) & 1 == 0 and mas[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
H, W, K = map(int, input().split())
C = [input() for i in range(H)]
ctoi = lambda x: 1 if x == '#' else 0
F = list(list(map(ctoi, c)) for c in C)
ans = 0
for b1 in range(1<<H):
    for b2 in range(1<<W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if b1 & (1<<i) and b2 & (1<<j):
                    cnt += F[i][j]
        if cnt == K:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import numpy as np

H, W, K = list(map(int, input().split()))
C = []
for i in range(H) :
  C.append(list(map(lambda c : 1 if c == "#" else 0, input())))
C = np.array(C)
ans = 0
for i in range(2**H) :
  for j in range(2**W) :
    C_copy = C.copy()
    for ii in range(H+1) :
      if i & int(2**(ii)) :
        C_copy[ii-1, :] = 0
    for jj in range(W+1) :
      if j & int(2**(jj)) :
        C_copy[:, jj-1] = 0
    if np.sum(C_copy) == K :
      ans += 1
    
  
print(ans)

Submission status: Accepted

Solution code:
h,w,k = map(int,input().split())
line = [input() for i in range(h)]
ans = 0
for i in range(1<<h):
    for j in range(1<<w):
        cnt = 0
        for ii in range(h):
            if i&(1<<ii):continue
            for jj in range(w):
                if j&(1<<jj):continue
                if line[ii][jj] == "#":
                    cnt += 1  
        if cnt == k:
            ans += 1
print(ans)

Submission status: Accepted

Solution code:
import copy
h,w,k = map(int, input().split())
t = []
for l in range(h):
  t.append(list(input()))

counts = []

for hp in range(2 ** h):
  for wp in range(2 ** w):
    tt = copy.deepcopy(t)
    for hs in range(h + 1):
      for ws in range(w + 1):
        if hs > 0:
          hb = 1 << (hs - 1)
          if hp & hb > 0:
            for wi in range(w):
              tt[hs - 1][wi] = '.'
        if ws > 0:
          wb = 1 << (ws - 1)
          if wp & wb > 0:
            for hi in range(h):
              tt[hi][ws - 1] = '.'
    total = 0
    for hh in range(h):
      for ww in range(w):
        if tt[hh][ww] == '#':
          total += 1
    counts.append(total)
print(counts.count(k))