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: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest

import numpy as np

def resolve():
    # s = input()
    # n = int(input())
    H, W, K = map(int, input().split())
    c = np.array([list(input()) for _ in range(H)])
    h_list = [np.count_nonzero(cc == '#') for cc in c]
    w_list = [np.count_nonzero(cc == '#') for cc in c.transpose()]
    ans = 0
    total = sum(w_list)

    if total == K:
        print(1)
    else:
        for i in range(2 ** H):
            for j in range(2 ** W):
                tmp_ans = 0
                tmp_h = []
                tmp_w = []

                for k in range(H):
                    if ((i >> k) & 1):  # 2進数表記して、論理積を取る
                        tmp_ans += h_list[k]
                        tmp_h.append(k)

                for l in range(W):
                    if ((j >> l) & 1):  # 2進数表記して、論理積を取る
                        tmp_ans += w_list[l]
                        tmp_w.append(l)

                for hh in tmp_h:
                    for ww in tmp_w:
                        if c[hh, ww] == '#':
                            tmp_ans -= 1

                if total - tmp_ans == K:
                    ans += 1

        print(ans)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 3 2
..#
###"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2 3 4
..#
###"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """2 2 3
##
##"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """6 6 8
..##..
.#..#.
#....#
######
#....#
#....#"""
        output = """208"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Wrong Answer

Solution code:
import sys

H,W,K = map(int,input().split())
a = [sys.stdin.readline().strip() for _ in range(H)]

ans = 0
for i in range(2**H-1):
    for j in range(2**W-1):
        b = 0
        for s in range(H):
            for t in range(W):
                if (i >> s) & 1 and (j >> t) & 1 and a[s][t] == "#":
                    b += 1
            if b == K:
                ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

H,W,K = map(int,input().split())
a = [sys.stdin.readline().strip() for _ in range(H)]

ans = 0
for i in range(2**H):
    for j in range(2**W):
        b = 0
        for s in range(H):
            for t in range(W):
                if (i >> s) & 1 and (j >> t) & 1 and a[s][t] == "#":
                    b += 1
            if b == K:
                ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
str = input()
if str.isupper()== "TRUE":
  print("A")
else:
  print("a")

Submission status: Wrong Answer

Solution code:
h,w,k=map(int,input().split())
dot=[list(input()) for i in range(h)]
ans=0
for i in range(2**h):
    for j in range(2**w):
        
        count=0
        
        for ii in range(h):
            for jj in range(w):
                if(i >> ii)&1==0 and (j>>jj)&1==0:
                    if dot[ii][jj]=='#':
                        count+=1
    if count==k:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
h,w,k=map(int,input().split())
dot=[list(input()) for i in range(h)]
ans=0
for i in range(2**h):
    for j in range(2**w):
        
        count=0
        
        for ii in range(h):
            for jj in range(w):
                if(i >> ii)&1==0 & (j>>jj)&1==0:
                    if dot[ii][jj]=='#':
                        count+=1
    if count==k:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
h,w,k=map(int,input().split())
dot=[list(input()) for i in range(h)]
ans=0
for i in range(2**h):
    for j in range(2**w):
        
        count=0
        
        for ii in range(h):
            for jj in range(w):
                if(i >> ii)==0 & (j>>jj)==0:
                    if dot[ii][jj]=='#':
                        count+=1
    if count==k:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
H,W,K = map(int,input().split())
s = [list(input()) for i in range(H)]
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)&0) and ((b>>j)&0) and (s[i][j]=="#"):
                    black += 1
        if black == K:
            ans += 1
print(ans)

Submission status: Wrong Answer

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

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

ans = 0

#make binary numbers ranging from 0 to 2**h -1 or 2**w -1
for row in range(2**h):
    for column in range(2**w):
        count = 0
        # Neither ith digit of row nor jth digit of column is 1 and c[i][j] is black.
        for i in range(h):
            for j in range(w):
                if ((row << i)&1) == 0 and ((column << j)&1) == 0 and c[i][j] == '#':
                    count += 1
        if count == k:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
H, W, K = [int(n) for n in input().split()]
for _ in range(K):
  a = 1
print(1)

Submission status: Wrong Answer

Solution code:
#173_C
h, w, k = map(int, input().split())
c = []
for i in range(h):
    array = list(input())
    c.append(array)

ans = 0
for i in range(2**h):
    for j in range(2**w):
        h_list = list(format(i, 'b'))
        h_list = [0] * (h-len(h_list)) + h_list
        w_list = list(format(j, 'b'))
        w_list = [0] * (w-len(w_list)) + w_list
        black = 0
        for k in range(h):
            for l in range(w):
                if h_list[k]=='0' and w_list[l]=='0' and c[k][l]=='#':
                    black += 1
        if black == k:
            ans += 1
            
print(ans)

Submission status: Wrong Answer

Solution code:
def resolve():
    import itertools
    import numpy as np
    
    N, W, K = map(int, input().split())
    g_all = np.array([list(input()) for i in range(N)])
    
    K_all = np.count_nonzero(g_all == '#')
    count = 0
    
    def dfs(i, g):
        if (i < N):
            g[i, :] = ['r'] * W
        else:
            g[:, i - N] = ['r'] * N
        return g
    
    g = g_all
    
    for L in range(2 ** (N + W)):
        g = g_all.copy()
        for i in range(N + W):
            if (i < N):
                if ((L >> i) & 1):
                    g[i, :] = ['r'] * W
            else:
                if ((L >> i) & 1):
                    g[:, i - N] = ['r'] * N
        if np.count_nonzero(g == '#') == K:
            count += 1
    print(count)

Submission status: Wrong Answer

Solution code:
H,W,K = map(int,input().split())
s = [list(input()) for i in range(H)]
ans = 0
for a in range(2**H):
    for b in range(2**W):
        for i in range(H):
            black = 0
            for j in range(W):
                if ((a>>i)&0) and ((b>>j)&0) and (s[i][j]=="#"):
                    black += 1
        if black == K:
            ans += 1
print(ans)

Submission status: Wrong Answer

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

ans = 0
for h in range(2 ** H):
  for w in range(2 ** H):
    count = 0
    for i in range(H):
      for j in range(W):
        if ((h >> i) & 1) == 0 and ((w >> j) & 1) == 0:
          if C[i][j] == '#':
            count += 1
    if K == count:
      ans += 1

print(ans)

Submission status: Wrong Answer

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

ans = 0
for h in range(2 ** H):
  for w in range(2 ** H):
    count = 0
    for i in range(H):
      for j in range(W):
        if ((h >> i) & 1) == 0 and (w >> j) & 1 == 0:
          if C[i][j] == '#':
            count += 1
    if K == count:
      ans += 1

print(ans)

Submission status: Wrong Answer

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

num = 0
for i in range(0,h):
    num = 0
    for m in range(0,w):
        if arr[i][m] == "#":
            num +=1
        for j in range(0,i+1):
            for n in range(0,m+1):
                if arr[j][n] == "#":
                    num -= 1
        if num == k:
            result += 1
print(result)

Submission status: Wrong Answer

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

ans = 0
for i in range(H+1):
  for j in range(W+1):
    countRed = 0
    _board = board
    if i>0:
      for h in range(W):
        _board[i-1][h] = "."
    if j>0:
      for h in range(H):
        _board[h][j-1] = "."
      for h in range(H):
        countRed += board[h].count("#")
    if countRed == K:
      ans += 1
 
print(ans)

Submission status: Wrong Answer

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

cnt = 0
for cols in range(H**2):
    for rows in range(W**2):
        black = 0
        for i in range(H):
            for j in range(W):
                if ((cols >> i) & 1) == 0 and ((rows >> j) & 1) == 0:
                    if cw[i][j] == '#':
                        black += 1
        if black == K:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

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

ans = 0
for i in range(2 ** (h)):
    for j in range(2 ** (w)):
        bag = 0
        sharp = 0
        
        for l in range(h):
            for m in range(w):
                
                if s[l][m] == "#":
                    sharp +=1
                if ((i >> l)&1) or ((j>>m)&1):
                    if s[l][m] == "#":
                        bag += 1
                        
            if sharp - bag == k:
                ans += 1
                
print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(2 ** (h)):
    for j in range(2 ** (w)):
        bag = 0
        
        for l in range(h):
            for m in range(w):
                if ((i >> l)&1) or ((j>>m)&1):
                    if s[l][m] == "#":
                        bag += 1
        if bag == k:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
h,w,k=map(int,input().split())
cij=[]
g=[]
tot=0
for i in range(h):
    cij+=input().split()
    a=cij[i].count("#")
    tot+=a
    g.append(a)
#今から各行、各列に存在する"#"の個数を数えていく
#各行当たりの個数はcij[i].count("#")とすればよい
#各列当たりの個数はまとめておく.
#j列の"#"の個数をr[j]とする
r=[]
for j in range(w):
    c=0
    for i in range(h):
        if cij[i][j]=="#":
            c+=1
    r.append(c)

ans=0
if tot==k:
    ans+=1
for i in range(h):
    if tot-g[i]==k:
        ans+=1
    for j in range(w):
        if tot-r[j]==k:
            ans+=1
        if tot-g[i]-r[j]+cij[i][j].count("#")==k:
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
h,w,k=map(int,input().split())
cij=[]
g=[]
tot=0
for i in range(h):
    cij+=input().split()
    a=cij[i].count("#")
    tot+=a
    g.append(a)
#今から各行、各列に存在する"#"の個数を数えていく
#各行当たりの個数はcij[i].count("#")とすればよい
#各列当たりの個数はまとめておく.
#j列の"#"の個数をr[j]とする
r=[]
for j in range(w):
    c=0
    for i in range(h):
        if cij[i][j]=="#":
            c+=1
    r.append(c)

ans=0
if tot==k:
    ans+=1
for i in range(h):
    if tot-g[i]==k:
        ans+=1
    for j in range(w):
        print(cij[i][j].count("#"))
        if tot-r[j]==k:
            ans+=1
        if tot-g[i]-r[j]+cij[i][j].count("#")==k:
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import copy
h, w, k = map(int, input().split())
arr = []
for i in range(0,h):
    arr.append(list(input()))
arr1 = copy.deepcopy(arr)
result = 0
    
for i in range(0,h):
    for j in range(0,w):
        arr[i][j] = ""
    num = 0
    for l in range(0,h):
        num += arr[l].count("#")
    if num == k:
        result += 1
 
 
for j in range(0,w):
    for i in range(0,h):
        arr1[i][j] = ""
    num = 0
    for l in range(0,h):
        num += arr1[l].count("#")
    if num == k:
        result += 1
        
print(result)

Submission status: Wrong Answer

Solution code:
import copy
h, w, k = map(int, input().split())
arr = []
for i in range(0,h):
    arr.append(list(input()))
arr1 = copy.copy(arr)
result = 0
    
for i in range(0,h):
    for j in range(0,w):
        arr[i][j] = ""
    num = 0
    for l in range(0,h):
        num += arr[l].count("#")
    if num == k:
        result += 1
 
 
for j in range(0,w):
    for i in range(0,h):
        arr1[i][j] = ""
    num = 0
    for l in range(0,h):
        num += arr1[l].count("#")
    if num == k:
        result += 1
        
print(result)

Submission status: Wrong Answer

Solution code:
h, w, k = map(int, input().split())
arr = []
for i in range(0,h):
    arr.append(list(input()))
 
result = 0
    
for i in range(0,h):
    for j in range(0,w):
        arr[i][j] = ""
    num = 0
    for l in range(0,h):
        num += arr[l].count("#")
    if num == k:
        result += 1
 
 
for j in range(0,w):
    for i in range(0,h):
        arr[i][j] = ""
    num = 0
    for l in range(0,h):
        num += arr[l].count("#")
    if num == k:
        result += 1
        
print(result)

Submission status: Wrong Answer

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

result = 0
    
for i in range(0,h):
    for j in range(0,w):
        arr[i][j] = ""
    num = 0
    for l in range(0,h):
        num += arr[l].count("#")
    if num == k:
        result += 1

for i in range(0,w):
    for j in range(0,h):
        arr[j][i] = ""
    num = 0
    for l in range(0,h):
        num += arr[l].count("#")
    if num == k:
        result += 1
        
print(result)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

h,w,k = map(int,input().split())
x = []
for i in range(h):
    x.append(list(map(int,list(input().rstrip().replace(".","0").replace("#","1")))))
#h,w = 2,3
count = 0
for i in range(0,max(h**2,2)):
    y = list(map(int,format(i,"0"+str(h)+"b")))
    for j in range(0,max(w**2,2)):
        z = list(map(int,format(j,"0"+str(w)+"b")))
        sum0 = 0
        for l in range(w):
            for m in range(h):
                sum0 += y[m] * z[l] * x[m][l]
        if sum0 ==k:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
h, w, k = map(int, input().split())
c = [input(i) for i in range(h)]
ans = 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:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
H, W, K = map(int, input().split())
C = []
for i in range(H):
    C.append(input().rstrip())
print(C)
ans = 0
for h in range(2**H):
    for w in range(2**W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (h>>i)&1 != 1 and (w>>j)&1 != 1 and C[i][j] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import product
h,w,k=map(int,input().split())
idxs=[]
cols=[0]*w
clis=[]
al=0
k_score=0
def nir(x):
  if x=='#':return 1
  else:return 0
  
for _ in range(h):
  tmp=list(map(nir, list(input())))
  clis.append(tmp)
  idxs.append(sum(tmp))
  al+=sum(tmp)
  for q in range(w):
    cols[q]+=tmp[q]
uu=product((0,1),repeat=h+w)
for bits in uu:
  idd=[]
  coll=[]
  for i in range(h):
    if bits[i]==1:idd.append(i)
  
  for i in range(w):
    if bits[i+h]==1:coll.append(i)
  
  s=al
  if not coll:
    for x in idd:s-=idxs[x]
  elif not idd:
    for y in coll:s-=cols[y]
  else:
    for x in idd:
      for y in coll:
        s-=idxs[x]
        s-=cols[y]
        s+=clis[x][y]
        
  if s==k:k_score+=1
    
print(k_score)

Submission status: Wrong Answer

Solution code:
H, W , K = map(int, input().split())
F = [ input() for _ in range(H)]
ans = 0
for i in range(2**H):
  for j in range(2**W):
    cnt = 0
    for ii in range(H):
      for jj in range(W):
        if (i>>ii)%2 == 0 or (j>>jj)%2 == 0 or F[ii][jj]=='.':
          continue
        cnt += 1
      if cnt == K:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import product
h,w,k=map(int,input().split())
idxs=[]
cols=[0]*w
clis=[]
al=0
k_score=0
def nir(x):
  if x=='#':return 1
  else:return 0
  
for _ in range(h):
  tmp=list(map(nir, list(input())))
  clis.append(tmp)
  idxs.append(sum(tmp))
  al+=sum(tmp)
  for q in range(w):
    cols[q]+=tmp[q]
    
for bits in product((0,1),repeat=h+w):
  idd=[]
  coll=[]
  for i in range(h):
    if bits[i]==1:idd.append(i)
  
  for i in range(w):
    if bits[i]==1:coll.append(i)
  
  s=al
  for x in idd:
    for y in coll:
      s-=idxs[x]
      s-=cols[y]
      s+=clis[x][y]
  
  if s==k:k_score+=1
    
print(k_score)

Submission status: Wrong Answer

Solution code:
H, W, K=map(int,input().split())
F = [input() for _ in range(H)]
print(F)
ans = 0 
for i in range(2**H):
  for j in range(2**W):
    cnt = 0
    for ii in range(H):
      for jj in range(W):
        if (i>>ii)%2==0 or (j>>jj)%2==0 or F[ii][jj]==".":
          continue
        cnt+=1
    if cnt==K:
      ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

H, W, K = map(int, input().split())
lst = ["."]*(W+1)
#print(lst)
cnt = 0
for i in range(H):
    s = input()                                       
    lst = np.append(lst,[".",*s])
#print(lst)    
lst = lst.reshape(H+1,W+1)
for hs in range(H+2):
  for he in range(hs+1,H+2):
    if hs==0 and he==2: break 
    for ws in range(W+2):
      for we in range(ws+1,W+2):
        if ws==0 and we==2: break
        if we==0 and he==0: continue 
        cp = lst.copy()
        cp[hs:he,:] = "h"
        cp[:,ws:we] = "w"
        if np.count_nonzero(cp=="#") == K:
          cnt += 1
        #print(cp,hs,he,ws,we,np.count_nonzero(cp=="#")) 
#print(lst)
#print(cnt)        
#a0 = np.count_nonzero(cp=="#",axis=0) == K
#a1 = np.count_nonzero(cp=="#",axis=1) == K
#cnt += np.count_nonzero(a0==True)   
#cnt += np.count_nonzero(a1==True) 
print(cnt)

Submission status: Wrong Answer

Solution code:
h,w,k=map(int,input().split())
c=[]
for i in range(h):
    c.append(list(input()))
z=0
for i in range(h):
    for j in range(w):
        if c[i][j]=='#':
            z+=1
ans=0
for i in range(1<<h):
    for j in range(1<<w):
        tmp=0
        for ii in range(h):
            for jj in range(w):
                if (i&(1<<ii) or j&(1<<jj)) and c[ii][jj]=='#':
                    tmp+=1
        print(tmp)
        if tmp+k==z:
            ans+=1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for bit_y in range(2 ** h):
    for bit_x in range(2 ** w):
        block = 0
        for y in range(h):
            for x in range(w):
                # c[y][x]が元から#じゃない、y,xが赤に塗り替える対象の行と列に選ばれているならカウントしない
                if (bit_y >> y & 1 and bit_x >> x & 1) or c[y][x] != '#':
                    continue
                block += 1
        if block == k:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
h, w, k = map(int, input().split())
c = []
for _ in range(h):
    c.append(list(input()))
def calc_black_cnt(maskR, maskC):
    cnt = 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] == '#':
                cnt += 1
    return cnt
ans = 0
for maskR in range(1<<h):
    for maskC in range(1<<w):
         if calc_black_cnt(maskR, maskC) == k:
                ans += 1
ans

Submission status: Wrong Answer

Solution code:
H,W,K = list(map(int,input().split()))
c = []
for i in range(H):
    c.append(list(input()))
ans = 0
H_pattern,W_pattern = 2**H,2**W
for i in range(0,H_pattern):
    for j in range(0,W_pattern):
        H_active_arr,W_active_arr=list(bin((H_pattern-1)&i)[2:].zfill(H)),list(bin((W_pattern-1)&j)[2:].zfill(W))
        count = 0
        print(H_active_arr)
        print(W_active_arr)
        for k,arr in enumerate(c):
            for l,item in enumerate(arr):
                if H_active_arr[k] == "1" and W_active_arr[l] == "1" and item == "#":
                    count += 1
        if count == K:
            ans += 1
print(ans)

Submission status: Wrong Answer

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

ans = 0
for n in range(1 << h):
  for m in range(1 << w):
    count = 0
    for i in range(h):
      for j in range(w):
        if n >> i & 1:
          continue
        if m >> j & 1:
          continue
        if c[i][j] == '#':
          count += 1
      if count == k:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
h,w,k = map(int,input().split())
a = []
for i in range(h):
	temp = []
	t = input()
	for j in range(w):
		if t[j] == ".": temp.append(0)
		else: temp.append(1)
	a.append(temp)
#print(a)
h_max = pow(2,h)
w_max = pow(2,w)
ans = 0
for i in range(h_max):
	h_str = str(bin(i)[2:])
	if len(h_str) < h: h_str = "0"*(h-len(h_str)) + h_str
	for j in range(w_max):
		w_str = str(bin(j)[2:])
		if len(w_str) < w: w_str = "0"*(w-len(w_str)) + w_str
		#print(h_str,w_str)
		s = 0
		for m in range(h):
			for n in range(w):
				if h_str[m] == "1" or w_str[n] == "1":
					if a[m][n]: s += 1
		if s == k: ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
h, w, k = map(int, input().split())
matrix = []
total = 0
row = []
col = [0] * w
for _ in range(h):
  c = input()
  cnt = 0
  for i in range(w):
    if c[i] == '#':
      cnt += 1
      col[i] += 1
  total += cnt
  row.append(cnt)
  matrix.append(c)
state = total
r_lst = []
c_lst = []
ans = 0
for k in range(2**h):
  for l in range(2**w):
    for i in range(h):
      if k & (1 << i) == 2**i:
        state -= row[i]
        r_lst.append(i)
    for j in range(w):
      if l & (1 << j) == 2**j:
        state -= col[j]
        c_lst.append(j)
    for p in r_lst:
      for q in c_lst:
        if matrix[p][q] == '#':
          state += 1
    if state == k:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
H, W, K = map(int, input().split())
C = []
for _ in range(H):
    C.append(list(input()))
# print(f'{C=}')

ans = 0
for H_bit in range(1 << H):
    for W_bit in range(1 << W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if ((H_bit >> i) & 1) == 0 and ((W_bit >> i)
                                                & 1) == 0 and C[i][j] == '#':
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
h,w,k=map(int,input().split())
c=[input() for _ in range(h)]
count=0
for H in range(h<<1):
  for W in range(w<<1):
    b=0
    for i in range(h):
      for j in range(w):
        if (H >> i) & 1 == 0 and (W >> j) & 1 == 0 and c[i][j] == "#":
          b+=1
    if b==k:
      count+=1
print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:

import numpy as np

H, W, K = map(int,input().split())
D = np.zeros([H,W])

black_count = 0
for i in range(H):
    C = list(input())
    for j in range(len(C)):
        if(C[j] == "#"):
            D[i][j] = 1


#print(D)
for i in range(2**H):
    h = format(i, '06b')
    for j in range(2**W):
        w = format(j, '06b')
        d = D.copy()

        for hi in range(H):
            if(h[hi] == '1'):
                d[hi,:]=0
        for wi in range(W):
            if(w[wi] == '1'):
                d[:,wi]=0
            
        if (d.sum() == K):
            black_count += 1

print(black_count)

Submission status: Wrong Answer

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

ans = 0
for h in range(1 << H):
    for w in range(1 << W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if h >> i & 1:
                    continue
                if w >> j & 1:
                    continue
                cnt += 1
        if cnt == K:
            ans += 1

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# coding:utf-8

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
# print(c)
black = 0
H = []
W = []
ans = 0

for bit_h in range(2**h):
    for bit_w in range(2**w):
        black = 0
        for i in range(h):
            if not ((bit_h >> 1) & 1):
                continue
            for j in range(w):
                if not ((bit_w >> 1) & 1):
                    continue
                if c[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
h,w,r = map(int,input().split())
l=[];an=0
cr=[];k=[0]*w
for i in range(h):
  x=list(input())
  l.append(x)
  cr.append(x.count('#'))
  for j in range(w):
    if x[j]=='#':
      k[j]+=1
ar=cr+k;tot=sum(cr)
tt=len(ar)
for i in range(1<<tt):
  re=tot;rr=[]
  cc=[]
  for j in range(tt):
    if i&(1<<j):
      re-=ar[j]
      if j>=h:
        cc.append(h-j)
      else:
        rr.append(j)
  #print(i,rr,cc,re)
  if re==r:
    an+=1
  #print(i,re)
print(an)

Submission status: Wrong Answer

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

init_map = []

for i in range(H):
    row = list(input())
    init_map.append(row)

#print(init_map)

ans = 0

for paint_h in range(2 ** H):
    print("h: " + str(paint_h))
    for paint_w in range(2 ** W):
        print("w: " + str(paint_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: Wrong Answer

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

field = [list(input()) for i in range(h)]

ans = 0
for maskr in range(0, h*2):
    for maskc in range(0, w*2):
        black = 0
        for i in range(h):
            for j in range(w):
                if ((maskr>>i) & 1) == 0 and ((maskc>>j) & 1) == 0 and field[i][j] == '#':
                    black +=1
        if black == k:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
H, W, K = map(int, input().split())
g = [list(input()) for _ in range(H)]
print(*g, sep="\n")
ans = 0
for h in range(2**H):
    for w in range(2**W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (h >> i) & 1 == 0 and (w >> j) & 1 == 0 and g[i][j] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    R, C, K = map(int, input().split())
    grid = []
    for r in range(R):
        grid.append([1 if c == '#' else 0 for c in input()])
                
    n_configs = 0

    for rm in range(2**R):
        for cm in range(2**C):
            nblack = sum(grid[r][c] * ((rm >> r) & 1) * ((cm >> c) & 1) for r in range(R) for
                    c in range(C))
            if nblack == K:
                n_configs += 1

    print(n_configs, flush=True)
    return

Submission status: Wrong Answer

Solution code:
def main():
    R, C, K = map(int, input().split())
    grid = []
    for r in range(R):
        grid.append([1 if c == '#' else 0 for c in input()])
                
    n_configs = 0

    for rm in range(2**R):
        rmask = [int(b) for b in bin(rm)[2:].zfill(R)]
        for cm in range(2**C):
            cmask = [int(b) for b in bin(cm)[2:].zfill(C)]
            nblack = sum(grid[r][c] * rmask[r] * cmask[c] for r in range(R) for
                    c in range(C))
            if nblack == K:
                n_configs += 1

    print(n_configs, flush=True)
    return