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:
H,W,K = [int(x) for x in input().split()]
c = []
for i in range(H):
  a = input()
  c.append([])
  for j in range(W):
    c[i] = c[i] + [a[j]]

ans = 0
d = c

for n in range(2 ** (H * W - 1)):
  count = 0
  bi = []
  bj = []
  N = n
  for i in range(H):
    bi = bi + [N%2]
    N = N // 2
  for j in range(W):
    bj = bj + [N%2]
    N = N // 2
  for i in range(H):
    for j in range(W):
      if c[i][j] == '#' and bi[i] == 0 and bj[j] == 0:
        count += 1
  if count == K:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

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

Submission status: Wrong Answer

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

ans = 0
for i in range(1 << h):
    for j in range(1 << w):
        cnt = 0
        for k in range(h):
            for l in range(w):
                if i >> k & 1:
                    continue
                if j >> l & 1:
                    continue
                if lc[k][l] == '#':
                    cnt += 1
            if cnt == K:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
h,w,k = map(int,input().split())
row = [] #列
column = [] #行

a = [input() for i in range(h)]

for i in range(h):
    sharp = 0
    for j in range(w):
        if a[i][j] == "#":
            sharp += 1
    row.append(sharp)

for i in range(w):
    sharp = 0
    for j in range(h):
        if a[j][i] == "#":
            sharp += 1
    column.append(sharp)

sum = 0
for i in range(len(row)):
    sum += row[i]

ans = 0
for i in range(len(row)):
    for j in range(len(column)):
        dup = 0
        if a[i][j] == "#":
            dup = 1
        if sum - (row[i] + column[j]) + dup == k:
            ans += 1

for i in range(len(row)): #列だけ
    if sum - row[i] == k:
        ans += 1

for i in range(len(column)): #行だけ
    if sum - column[i] == k:
        ans += 1

for i in range(len(row)):
    for j in range(i + 1, len(row)):
        if sum - (row[i] + row[j]) == k:
            ans += 1

for i in range(len(column)):
    for j in range(i + 1, len(column)):
        if sum - (column[i] + column[j]) == k:
            ans += 1
if sum == k:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
h,w,k=map(int,input().split())
l=[input() for i in range(h)]
al=0
ans=0
g=[0 for i in range(h)]
yo=[0 for i in range(w)]
for i in range(h):
  for j in range(w):
    if(l[i][j]=="#"):
      g[i]+=1
      yo[j]+=1
      al+=1


for i in range(h+1):
  for j in range(w+1):
    if (i==0):
      for y in itertools.combinations(range(w), j):
        alcpy=al
        for b in y:
          alcpy-=yo[b]
        if(alcpy==k):
          ans+=1
    else:
      for x in itertools.combinations(range(h), i):
        for y in itertools.combinations(range(w), j):
          alcpy=al
          for a in x:
            alcpy-=g[a]
            for b in y:
              alcpy-=yo[b]
              if(l[a][b]=="#"):
                alcpy+=1
          if(alcpy==k):
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
h,w,k=map(int,input().split())
l=[input() for i in range(h)]
al=0
ans=0
g=[0 for i in range(h)]
yo=[0 for i in range(w)]
for i in range(h):
  for j in range(w):
    if(l[i][j]=="#"):
      g[i]+=1
      yo[j]+=1
      al+=1


for i in range(h+1):
  for j in range(w+1):
    if (i==0):
      alcpy=al
      for y in itertools.combinations(range(w), j):
        for b in y:
          alcpy-=yo[b]
        if(alcpy==k):
          ans+=1
    else:
      for x in itertools.combinations(range(h), i):
        for y in itertools.combinations(range(w), j):
          alcpy=al
          for a in x:
            alcpy-=g[a]
            for b in y:
              alcpy-=yo[b]
              if(l[a][b]=="#"):
                alcpy+=1
          if(alcpy==k):
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools as itr
import numpy as np

(h, w, k) = list(map(int, input().split(' ')))
field = [list(input()) for i in range(h)]

#print((h, w, k))
#print(field)

pattern_count = 0

for i in range(h):
    for j in range(w):
        r_combi = itr.combinations(range(h), i)
        c_combi = itr.combinations(range(w), j)
        for r in r_combi:
            for c in c_combi:
                row_deleted = np.delete(field, r, axis=0)
                deleted = np.delete(row_deleted, c, axis=1)
                count = np.sum(np.char.count(deleted, '#'))
                #print(r, c, count)
                if count == k:
                    pattern_count += 1

print(pattern_count)

Submission status: Wrong Answer

Solution code:
H, W, K = list(map(int, input().split()))
matrix = [[0 for j in range(W)] for i in range(H)]
matrix2 = [[0 for j in range(W)] for i in range(H)]
for i in range(H):
    c_i = input()
    for j in range(W):
        if c_i[j] == '#':
            matrix[i][j] = 1
            matrix2[i][j] = 1
COUNT = 0
for i in range(2**(H+W)):
    x_i = []
    y_i = []
    count = 0
    for j in range(H+W):
        if ((i >> j) & 1):
            if j < H:
                x_i.append(j)
            else:
                y_i.append(j-H)
    for k in x_i:
        for l in range(W):
            matrix[k][l] = -1
    for k in range(H):
        for l in y_i:
            matrix[k][l] = -1
    for k in range(H):
        for l in range(W):
            if matrix[k][l] == 1:
                count += 1
    if count == K:
        COUNT += 1
    matrix = matrix2
print(COUNT)

Submission status: Wrong Answer

Solution code:
import copy
H, W, K = list(map(int, input().split()))
matrix = [[0 for j in range(W)] for i in range(H)]
for i in range(H):
    c_i = input()
    for j in range(W):
        if c_i[j] == '#':
            matrix[i][j] = 1
p = copy.deepcopy(matrix)
COUNT = 0
for i in range(2**(H+W)):
    x_i = []
    y_i = []
    count = 0
    for j in range(H+W):
        if ((i >> j) & 1):
            if j < H:
                x_i.append(j)
            else:
                y_i.append(j-H)
    for k in x_i:
        for l in range(W):
            matrix[k][l] = -1
    for k in range(H):
        for l in y_i:
            
            matrix[k][l] = -1
    for k in range(H):
        for l in range(W):
            if matrix[k][l] == 1:
                count += 1
    if count == K:
        COUNT += 1
    matrix = p
print(COUNT)

Submission status: Wrong Answer

Solution code:
H,W,K = map(int,input().split())
c,ch,cw,a=[],[],[0]*6,0

for _ in range(H):
	t = input()
	c.append(t)
	ch.append(sum([x=='#' for x in t]))
for j in range(W):
	for i in range(H):
		if c[i][j] == '#':
			cw[j] += 1

for i in range(1<<H):
	for j in range(1<<W):
		s,si,sj=0,[],[]
		for d in range(H):
			if i & 1<<d:
				si.append(d)
				s += ch[d]
		for d in range(W):
			if j & 1<<d:
				sj.append(d)
				s += cw[d]
		for p in si:
			for q in sj:
				if c[p][q] == '#':
					s -= 1
		if s == K:
			a += 1
print(a)

Submission status: Wrong Answer

Solution code:
import itertools
h,w,n=map(int, input().split())
l=[str(input())for _ in range(h)]
ans = 0

for i in list(itertools.product([0,1], repeat= h)):
    for j in list(itertools.product([0,1], repeat= w)):
        b = 0
        for k in range(h):
            for m in range(w):
                if i[k] == 0 and j[m] == 0 and l[k][m] == '#':
                    b +=1
        if b == n:
            ans += 1
            print(ans)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

H, W, K = [int(i) for i in input().split()]
A = np.zeros([H, W], dtype=bool)
for i in range(H):
    A[i] = np.array([False if i=="." else True for i in input()])

T = A.sum()
T_row = A.sum(1)
T_col = A.sum(0)

def calc(I, J):
    return T - T_row[I].sum() - T_col[J].sum() + A[I][:,J].sum()

def repr(i, W):
    s = np.binary_repr(i, width=W)[::-1]
    return [i for i, j in enumerate(s) if j == "1"]

count = 0
for i in range(2**H-1):
    for j in range(2**W-1):
        row = repr(i, H)
        col = repr(j, W)
        if calc(row, col) == K:
            print(row, col)
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np

H, W, K = [int(i) for i in input().split()]
A = np.zeros([H, W], dtype=bool)
for i in range(H):
    A[i] = np.array([False if i=="." else True for i in input().split()])

T = A.sum()
T_row = A.sum(1)
T_col = A.sum(0)

def calc(I, J):
    return T - T_row[I].sum() - T_col[J].sum() + A[I][:,J].sum()

def repr(i, W):
    s = np.binary_repr(i, width=W)[::-1]
    return [i for i, j in enumerate(s) if j == "1"]

count = 0
for i in range(2**H-1):
    for j in range(2**W-1):
        row = repr(i, H)
        col = repr(j, W)
        if calc(row, col) == K:
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n,m,k = map(int, input().split())
l = [input() for i in range(n)]

A=[]
for i in range(n):
    A.append(list(l[i]))
def judge(d):
    if d=="#":
        return 1
    else:
        return 0
V=[]
u=0
for i in range(n):
    v=0
    for j in range(m):
        v+=judge(A[i][j])
    V.append(v)
    u+=v
W=[]
for j in range(m):
    w=0
    for i in range(n):
        w+=judge(A[i][j])
    W.append(w)
    u+=w
u=u//2
s=0
for i in range(n):
    for j in range(m):
        if u-(V[i]+W[j]-judge(A[i][j]))==k:
            s+=1
for i in range(n):
    if u-(V[i])==k:
            s+=1
for j in range(m):
    if u-(W[j])==k:
            s+=1
if u==k:
    s+=1
print(s)

Submission status: Wrong Answer

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

import copy

ar = [[0 for _ in range(w)] for _ in range(h)]


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

print(ar)
d = {}
for i in range(h):
    for j in range(w):
        d[(i+1,j+1)] = ar[i][j]

print(d)
sm = 0
for i in d.values():
    if(i == "#"):
        sm += 1

gl = sm - k
print("gl",gl)

ans = 0
def ch_red(x):
    d_tmp = copy.deepcopy(d)
    #print(d_tmp)
    cnt = 0
    x_ar_bin = [0 for _ in range(h+w)]
    v = h+w
    for i in range(h+w):
        x_ar_bin[i] = int(bin(x >> i),2)%2
    
    #print(x_ar_bin)

    for i in range(h):
        if(x_ar_bin[i] == 0):
            continue
        else:
            for j in range(w):
                key = (i+1,j+1)
                if(d_tmp[key] == "#"):
                    d_tmp[key] = "$"
                    cnt += 1
    
    for i in range(h,h+w):
        if(x_ar_bin[i] == 0):
            continue
        else:
            for j in range(h):
                key = (j+1,i+1-h)
                if(d_tmp[key] == "#"):
                    d_tmp[key] = "$"
                    cnt += 1
    
    
    if(cnt == gl):
        return 1
    else:
        return 0

    #print(cnt)

mx = 2**(h+w)

print(mx)
for i in range(mx):
    ans += ch_red(i)

print(ans)

Submission status: Wrong Answer

Solution code:
H, W, K = map(int, input().split())
c = [input() for _ in range(H)]
ybla = [0]*H
xbla = [0]*W
all_black = 0
for i in range(H):
    all_black += c[i].count('#')
    ybla[i] += c[i].count('#')
    for j in range(W):
        if c[i][j] == '#':
            xbla[j] += 1

print(ybla, xbla)
ans = 0
for i in range(2**H):
    y = []
    total1 = 0
    for j in range(H):
        if (i >> j) & 1:
            y.append(j)
            total1 += ybla[j]
    # print(y, total)
    for k in range(2**W):
        x = []
        total2 = 0
        for l in range(W):
            if (k >> l) & 1:
                # print(bin(k), l)
                x.append(l)
                total2 += xbla[l]
        total = total1 + total2
        if len(y) and len(x):
            for yy in y:
                for xx in x:
                    if c[yy][xx] == '#':
                        total -= 1
        # print(y, x, total, total1, total2)
    
        if all_black == K + total:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
H, W, K = map(int, input().split())
c = [input() for _ in range(H)]
ybla = [0]*H
xbla = [0]*W
all_black = 0
for i in range(H):
    all_black += c[i].count('#')
    ybla[i] += c[i].count('#')
    for j in range(W):
        if c[i][j] == '#':
            xbla[j] += 1

# print(ybla, xbla)
ans = 0
for i in range(2**H):
    y = []
    total1 = 0
    for j in range(H):
        if (i >> j) & 1:
            y.append(j)
            total += ybla[j]
    # print(y, total)
    for k in range(2**W):
        x = []
        total2 = 0
        for l in range(W):
            if (k >> l) & 1:
                # print(bin(k), l)
                x.append(l)
                total2 += xbla[l]
        total = total1 + total2
        for yy in y:
            for xx in x:
                if c[yy][xx] == '#':
                    total -= 1
        # print(y, x, total)
    
        if all_black == K + total:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
import copy

h,w,k = list(map(int, input().split()))
lst = [None for i in range(h)]
for i in range(h):
    lst[i] = list(input())
ans = 0

H = list(itertools.product([0,1],repeat=h))
W = list(itertools.product([0,1],repeat=w))

for i in H:
    for j in W:
        if sum(i)+sum(j)<=k:
            lst_test = copy.deepcopy(lst)
            for I in range(h):
                if i[I]==1:
                    for a in range(w):
                        lst_test[I][a] = "R"
            for J in range(w):
                if j[J]==1:
                    for a in lst_test:
                        a[J] = "R"
            # print(i,j)
            # print(lst_test)
            count = 0
            for a in lst_test:
                for b in a:
                    if b=="#":
                        count += 1
            if count == k:
                ans += 1

print(ans)

Submission status: Wrong Answer

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

id_count = 0
d = {}

for i in range(H):
  
  l = input()
  for j in range(W):
#    print(i,j,j+H)
    if l[j] == '#':
      if i in d:
        d[i].append(id_count)
      else:
        d[i]=[id_count]
        
      if j+H in d:
        d[j+H].append(id_count)
      else:
        d[j+H]=[id_count]
      id_count +=1

#print(d)
      
ans = 0
#print(id_count)

if id_count == K:
  print(1)
else:
  
  for i in range(2 ** (H+W)):
    wrk_list=[]
    for j in range(H+W):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
          wrk_list.extend(d.get(j,[]))  
    if wrk_list==[]:
      set1 = []
    else:
      set1 = set(wrk_list)
  
#    print('set',set1,i)
    if id_count - len(set1) == K:
      ans +=1
  print(ans)

Submission status: Wrong Answer

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

id_count = 0
d = {}

for i in range(H):
  
  l = input()
  for j in range(W):
    
    if l[j] == '#':
      if i in d:
        d[i].append(id_count)
      else:
        d[i]=[id_count]
        
      if j+H in d:
        d[j+H].append(id_count)
      else:
        d[j+H]=[id_count]
      id_count +=1

#print(d)
      
ans = 0
#print(id_count)

if id_count == K:
  print(1)
else:
  
  for i in range(2 ** (H+W)):
    wrk_list=[]
    for j in range(H+W):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
          wrk_list.extend(d.get(j,[]))  
    if wrk_list==[]:
      set1 = []
    else:
      set1 = set(wrk_list)
  
#    print('set',set1,i)
    if len(set1) == K:
      ans +=1
  print(ans)

Submission status: Wrong Answer

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

id_count = 0
d = {}

for i in range(H):
  
  l = input()
  for j in range(W):
    
    if l[j] == '#':
      if i in d:
        d[i].append(id_count)
      else:
        d[i]=[id_count]
        
      if j+H in d:
        d[j+H].append(id_count)
      else:
        d[j+H]=[id_count]
      id_count +=1

#print(d)
      
ans = 0
#print(id_count)

if id_count == K -1:
  print(1)
else:
  
  for i in range(2 ** (H+W)):
    wrk_list=[]
    for j in range(H+W):
        if ((i >> j) & 1):
          wrk_list.extend(d.get(j,[]))  
    if wrk_list==[]:
      set1 = []
    else:
      set1 = set(wrk_list)
  
#    print('set',set1,i)
    if len(set1) == K:
      ans +=1
  print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np

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

c = np.zeros((H, W))
result = 0
for i in range(H):
    word = input()
    for j in range(W):
        if word[j] == '.':
            c[i][j] = 0
        elif word[j] == '#':
            c[i][j] = 1

for mask_h in range(2**H):
    bin_mask_h = format(mask_h,  '0' + str(H) + 'b')
    for mask_w in range(2**W):
        bin_mask_w = format(mask_w, '0' + str(W) + 'b')
        black_num = 0
        for i in range(H):
            if bin_mask_h[i] == '0':
                continue
            for j in range(W):
                if bin_mask_w[j] == '0':
                    continue
                if c[i][j] == 1:
                    black_num += 1
        print(str(bin_mask_h) + ' ' + str(bin_mask_w) + ' ' + str(black_num))
        if black_num == K:
            result += 1

print(result)

Submission status: Wrong Answer

Solution code:
import itertools
import numpy as np

H,W,K=map(int,input().split())
m=[]
for i in range(H):
    m.append(list(input()))
print(m)
ans=0
for i in range(2**H):
     for j in range(2**W):
            i_s=format(i, "0{0}b".format(H))
            j_s=format(j, "0{0}b".format(W))
            M=[[[] for _ in range(W)] for _ in range(H)]
            for h in range(H):
                for w in range(W):
                    if i_s[h]=="1" or j_s[w]=="1":
                        M[h][w]="$"
                    else:
                        M[h][w]=m[h][w]
            M_1=list(itertools.chain.from_iterable(M))
            if M_1.count("#")==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 maskR in range(H):
  for maskC in range(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 = black + 1
    if black == K: 
      ans = ans + 1
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
import copy
import numpy as np

H, W, K = map(int, input().split())
C = []
for i in range(H):
    # C.append(list(input()))
    C.append(input())
# print(C)
total_b = 0
# for m in C:
#     for n in m:
#         if(n == '#'):
#             total_b += 1

for m in C:
    total_b += m.count('#')

# print(total_b)
diff = total_b - K
row_cnt = []
for i in range(H):
    if(C[i].count('#') <= diff):
        # row_cnt[i] = C[i].count('#')
        row_cnt.append(i)

col_cnt = []
for i in range(W):
    cnt_temp = 0
    for n in C:
        if n[i] == '#':
            cnt_temp += 1
    if(cnt_temp <= diff):
        # col_cnt[i] = cnt_temp
        col_cnt.append(i)

# print(row_cnt)
# print(col_cnt)
row_list = []
col_list = []
for i in range(len(row_cnt) + 1):
    row_list.append(list(itertools.combinations(row_cnt, i)))

for i in range(len(col_cnt) + 1):
    col_list.append(list(itertools.combinations(col_cnt, i)))
temp = copy.deepcopy(C)
C.clear()
for x in temp:
    C.append(list(x))
arr=np.array(C,dtype=str)

ans_cnt = 0
if diff == 0:
    ans_cnt = 1
for row in row_list:
    for col in col_list:
        temp_arr = copy.deepcopy(arr)
        # print(temp_arr)
        y = np.delete(temp_arr, row, axis = 0)
        y = np.delete(y, col, axis = 1)
        cnt = np.count_nonzero((y == '#'))
        if cnt == K:
            ans_cnt += 1

print(ans_cnt)

Submission status: Wrong Answer

Solution code:
import itertools
import copy
import numpy as np

H, W, K = map(int, input().split())
C = []
for i in range(H):
    # C.append(list(input()))
    C.append(input())
# print(C)
total_b = 0
# for m in C:
#     for n in m:
#         if(n == '#'):
#             total_b += 1

for m in C:
    total_b += m.count('#')

# print(total_b)
diff = total_b - K
row_cnt = []
for i in range(H):
    if(C[i].count('#') <= diff):
        # row_cnt[i] = C[i].count('#')
        row_cnt.append(i)

col_cnt = []
for i in range(W):
    cnt_temp = 0
    for n in C:
        if n[i] == '#':
            cnt_temp += 1
    if(cnt_temp <= diff):
        # col_cnt[i] = cnt_temp
        col_cnt.append(i)

# print(row_cnt)
# print(col_cnt)
row_list = []
col_list = []
for i in range(len(row_cnt) + 1):
    row_list.append(list(itertools.combinations(row_cnt, i)))

for i in range(len(col_cnt) + 1):
    col_list.append(list(itertools.combinations(col_cnt, i)))
temp = copy.deepcopy(C)
C.clear()
for x in temp:
    C.append(list(x))
arr=np.array(C,dtype=str)

ans_cnt = 0
for row in row_list:
    for col in col_list:
        temp_arr = copy.deepcopy(arr)
        # print(temp_arr)
        y = np.delete(temp_arr, row, axis = 0)
        y = np.delete(y, col, axis = 1)
        cnt = np.count_nonzero((y == '#'))
        if cnt == K:
            ans_cnt += 1

print(ans_cnt)

Submission status: Wrong Answer

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)

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

Solution code:
# unfinished

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

ls = [0]*h

for i in range(h) :
    ls[i] = input()

ans = 0

def ct(ls) :
    c = 0
    for line in ls :
        c += line.count('#')
    return c

def rew(ls,h,w) : # 1行1列しか消していないので複数行消せるようにする
    lst = ls.copy()
    if h>=0 :
        lst[h-1] = 'r'*(len(lst[0]))
    if w>=0 :
        for i in range(len(lst)) :
            lst[i] = lst[i][:w]+'r'+lst[i][w+1:]
    return lst

for i in range(-1,h) :
    for j in range(-1,w) :
#        print(rew(ls,i,j),i,j)
        if ct(rew(ls,i,j)) == k :
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
h,w,k = map(int,input().split())
c = [[c for c in l.strip()] for l in sys.stdin]
print(c)

Submission status: Wrong Answer

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

ans = 0
  
for paint_h in range(H ** 2):
  for paint_w in range(W ** 2):
    count = 0
    for i in range(H):
      for j in range(W):
        if ((paint_h >> i) & 1) == 0 and ((paint_w >> j) & 1) == 0:
          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())
c = [input() for _ in range(H)]

n = H + W
ans = 0
  
for paint_h in range(H ** 2):
  for paint_w in range(W ** 2):
    count = 0
    for i in range(H):
      for j in range(W):
        if ((paint_h >> i) & 1) == 0 and ((paint_w >> j) & 1) == 0:
          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())
c = [input() for _ in range(H)]

n = H + W
ans = 0
  
for paint_h in range(H ** 2):
  for paint_w in range(W ** 2):
    count = 0
    for i in range(H):
      for j in range(W):
        if (paint_h >> i) & 1 == 0 and (paint_w >> j) & 1 == 0:
          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())
c = [input() for _ in range(H)]

n = H + W
ans = 0
  
for paint_h in range(H ** 2):
  for paint_w in range(W ** 2):
    count = 0
    for i in range(H):
      for j in range(W):
        if c[i][j] == '#' and (paint_h >> i) & 1 == 0 and (paint_w >> j) & 1 == 0:
          count += 1
    if count == K:
      ans += 1
    
print(ans)

Submission status: Wrong Answer

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

a = [list(input()) for _ in range(H)] #listの中にlist()を標準入力する。H行分作成する。
#a = np.zeros((int(H),int(W)))

ans = 0
for i in range(2**H): #行の塗り方のパターン
    for j in range(2**W): #列の塗り方のパターン
        count = 0
        for s in range(H):
            for t in range(W):
                if(i >> s)&1 and (j>>t) & 1 and a[s][t] =="#":
                    count += 1
            if count == K:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
H,W,K = map(int,input().split())

a = [list(input()) for _ in range(H)] #listの中にlist()を標準入力する。H行分作成する。
#a = np.zeros((int(H),int(W)))
print(a)
count = 0
ans = 0
for i in range(2**W): #行の塗り方のパターン
    for j in range(2**H): #列の塗り方のパターン
        count = 0
        for s in range(H):
            for t in range(W):
                if(i >> s)&1 and (j>>t) & 1 and a[s][t] =="#":
                    count += 1
            if count == K:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest

import numpy as np

def resolve():
    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)

    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

    if total == 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()