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 = map(int, input().split())
C = [list(map(str, input().split())) for _ in range(h)]
cnt = 0
ans =0
cnt_h =0

cnt = w * h
for i in range(h):
    cnt_h = C[i][0].count("#") 
    for j in range(w):
        cnt_w = 0
        for m in range(h):
            if m!=i and C[m][0][j] == "#":
                cnt_w += 1
        if cnt - (cnt_w + cnt_h) == k:
            ans += 1
print(ans)

Submission status: Wrong Answer

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

for i in range(2**H-1):
  part1 = []
  part1 += board
  for j in range(H):
    if (i>>j)&1:
      part1[j] = ["*"]*W  
  for k in range(2**W-1):
    part2 = []
    part2 += part1
    for l in range(W):
      if (k>>l)&1:
        for n in range(H):
          part2[n][l] = "*"
    cnt = 0
    for m in part2:
      cnt += m.count("#")
    if cnt == K:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
from copy import deepcopy
h, w, k = map(int, input().split())
cells = []
for h_ in range(h):
    cells.append(list(map(lambda x:x[0],input())))

def drop(cells_,row=None,col=None):
    cells_copy = deepcopy(cells_)
    if (col != None):
        for i in range(len(cells)):
            cells_copy[i][col-1] = 'x'
    if (row != None):
        cells_copy[row-1] = ['x']*len(cells_copy[row-1])
    return cells_copy


def flatten(cells):
    flatten_cells = ''
    for i in range(len(cells)):
        flatten_cells += ''.join(cells[i])
    return flatten_cells

count = 0
# row only 
for row_ in [None]+list(range(1,h+1)): 
    for col_ in [None]+list(range(1,w+1)):
        cells_ = drop(cells, row=row_, col=col_)
        #print(cells_)
        counter = Counter(flatten(cells_))
        #print(row_,col_)
        #print('#:',counter.get('#'))
        if counter.get('#') == k:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
H, W ,K= map(int, input().split())
S = []
CNT=0
n=0
m=0
for _ in range(H):
    S.append(list(input()))
   
for n in range(H):
    for m in range(W):
        count=0
        for i in range(H):
            for j in range(W):
                if i!=n and j !=m and S[i][j]=="#":
                    count=count+1
            if count==K:
                CNT=CNT+1
                
                
for n in range(H):
    for m in range(W):
        for i in range(H):
            for j in range(W):
                if i!=n and S[i][j]=="#":
                    count=count+1
            if count==K:
                CNT=CNT+1
                
count=0                
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            count=count+1
if count==K:
    CNT=CNT+1  
  
print(CNT)

Submission status: Wrong Answer

Solution code:
import itertools
import copy

h,w,k = map(int,input().split())
c = [list(input()) for i in range(h)]
ans = 0
hh = []
for i in range(h+1):
    hh.append(list(itertools.combinations(range(h+1), i)))
ww = []
for i in range(w+1):
    ww.append(list(itertools.combinations(range(w+1), i)))
# print(hh)
# print(hh[0])

for _ in range(h+1):
    for hs in hh[_]:
        #init
        temp = copy.deepcopy(c)
        # print(c)

        for i in hs:
            # print(i) #i列の塗り潰し
            if i == 0:
                continue
            temp[i-1] = list('r' * w)

        for _ in range(w+1):
            for ws in ww[_]:
                #init
                temp2 = copy.deepcopy(temp)

                for j in ws:
                    # print(i) #j列の塗り潰し
                    if j == 0:
                        continue
                    for ii in range(h):
                        # print(temp[ii][j-1])
                        temp2[ii][j-1] = 'r'
                print(temp2)
                # 判定
                cnttemp = 0
                for iii in range(h):
                    cnttemp+= temp2[iii].count('#')
                if cnttemp == k:
                    ans += 1

print(ans//4)

Submission status: Wrong Answer

Solution code:
h, w, k = map(int, input().split())
C = [list(map(str, input().split())) for _ in range(h)]
cnt = 0
ans =0
cnt_h =0

cnt = w * k
for i in range(h):
    cnt_h = C[i][0].count("#") 
    for j in range(w):
        cnt_w = 0
        for m in range(h):
            if m!=i and C[m][0][j] == "#":
                cnt_w += 1
        if cnt - (cnt_w + cnt_h) == k:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
h, w, k = map(int, input().split())
a =  [list(map(str,input().split(" "))) for i in range(h)]
if a.count("#") == k:
    print(1)
elif k == h*w-1:
    print(0)
else:
    print(a.count("#"))

Submission status: Wrong Answer

Solution code:
import itertools

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

mat = []

for i in range(h):
    s = list(input())
    mat.append(s)

brack = 0

for i in range(h):
    for j in range(w):
        if mat[i][j] == "#":
            brack += 1

if k == brack:
    print(1)
    exit()

tate = [0] * w
yoko = [0] * h
for i in range(h):
    for j in range(w):
        if mat[i][j] == "#":
            tate[j] += 1
            yoko[i] += 1

tcom = []
ycom = []
for i in range(w):
    l = list(itertools.combinations(range(w), i+1))
    for j in l:
        tcom.append(j)
for i in range(h):
    l = list(itertools.combinations(range(h), i+1))
    for j in l:
        ycom.append(j)

ans = 0

for i in tcom:
    for j in ycom:
        cnt = 0
        for n in i:
            cnt += tate[n]
        for n in j:
            cnt += yoko[n]
        for n in i:
            for m in j:
                if mat[m][n] == "#":
                    cnt -= 1
        if brack - cnt == k:
            ans += 1

for i in tcom:
    tcnt = 0
    for n in i:
        tcnt += tate[n]
    if brack - tcnt == k:
        ans += 1

for i in ycom:
    ycnt = 0
    for n in i:
        ycnt += yoko[n]
    if brack - ycnt == k:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
s = [input() for i in range(1)]
list1 = list(map(int, s[0].split()))
h = list1[0]
w = list1[1]
k = list1[2]

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

for j in range(h):
    t[j] = t[j].replace('.','0')
    t[j] = t[j].replace('#','1')
    print(t[j])
    t[j] = np.array([int(i) for i in t[j]])
    for k in range(w):
        if t[j][k] == '.':
            t[j][k] = 0
        if t[j][k] == '#':
            t[j][k] = 1
print(t)

for j in range(h):
    t[j] = np.array([int(i) for i in t[j]])
    for k in range(w):
        if t[j][k] == '.':
            t[j][k] = 0
        if t[j][k] == '#':
            t[j][k] = 1
         
            
print(t)
print(np.sum(t))

Submission status: Wrong Answer

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

masu = []
for h in range(H):
    tmp = [1 if i == "#" else 0 for i in input()]
    masu.append(tmp)

masu_t = [list(x) for x in zip(*masu)]
ans = 0
sum_masu = [sum(x) for x in masu]
sum_masu_t = [sum(x) for x in masu_t]
all_sum = sum(sum_masu)
h_product = list(itertools.product([0, 1], repeat=H))
w_product = list(itertools.product([0, 1], repeat=W))

for h_pro in h_product:
    h_zip = [a * b for a, b in zip(sum_masu, h_pro)]
    tmp_masu = [a if b == 1 else [0]*W for a,b in zip(masu, h_pro)]
    h_sum = sum(h_zip)
    if h_sum <= K:
        for w_pro in w_product:
            w_zip = [a * b for a, b in zip(sum_masu_t, w_pro)]
            tmp_sum = 0
            for tmp in tmp_masu:
                tmp_masu2 = [a if b == 1 else 0 for a,b in zip(tmp, w_pro)]
                tmp_sum += sum(tmp_masu2)
            w_sum = sum(w_zip)
             
            if h_sum + w_sum - tmp_sum == K:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
h, w, k=map(int, input(). split())
table=[[0] * w for i in range(h)]
trial=h+w
original=0

for i in range(h):
    s=input()
    for j in range(w):
        table[i][j]=s[j]
        if table[i][j]=="#":
            original+=1


copy=[[0] * w for i in range(h)]

ans=0
cnt=0
for i in range(2**trial):
    for j in range(h):
        for k in range(w):
            copy[j][k]=table[j][k]
    
    cnt=0
    for l in range(trial):
        if ((i>>l)&1)==1:
            if l<h:
                for m in range(w):
                    if copy[l][m]=="#":
                        copy[l][m]="."
                        cnt+=1
            
            else:
                l-=h
                for m in range(h):
                    if copy[m][l]=="#":
                        copy[m][l]="."
                        cnt+=1
    
    if original-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):
    s=input()
    c.append(s)
blackh=[]
ans=0
for i in range(H):
    h=0
    for j in range(W):
        if c[i][j]=="#":
            h+=1
    blackh.append(h)
blackw=[]
for i in range(W):
    w=0
    for j in range(H):
        if c[j][i]=="#":
            w+=1
    blackw.append(w)
for i in range(2**H):
    for j in range(2**W):
        b=0
        h=[]
        w=[]
        for k in range(H):
            if ((i>>k)&1):
                b+=blackh[k]
                h.append(k)
        for l in range(W):
            if ((j>>l)&1):
                b+=blackw[l]
                w.append(l)
        for m in w:
            for n in h:
                if c[n][m]=="#":
                    b-=1
        if b==K:
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
print(5)

Submission status: Wrong Answer

Solution code:
H,W,K = map(int,input().split())
s = []
black = 0
row = [0]*(H+1)
col = [0]*(W+1)
for i in range(H):
  s.append(list(input()))
  black += s[i].count('#')
  row[i+1] += s[i].count('#')

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

count = 0
for y,i in enumerate(row):
  if black - i == K:
    count += 1
  for z,j in enumerate(col):
    if z==0 and y>=1:
      continue
    if black - (i+j) == K:
      if i+j!=0:
      	count += 1
if K in col[1:]:
  count += col[1:].count(K)
print(count)

Submission status: Wrong Answer

Solution code:
h, w, k = map(int, input().split())
C = [list(map(str, input().split())) for _ in range(h)]
cnt = 0
ans =0
cnt_h =0
for i in range(h):
    cnt = C[i][0].count("#") + cnt

for i in range(h):
    cnt_h = C[i][0].count("#") 
    for j in range(w):
        cnt_w = 0
        for m in range(h):
            if m!=i and C[m][0][j] == "#":
                cnt_w += 1
        if cnt - (cnt_w + cnt_h) == k:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy

H, W, K = map(int, input().split())
if H == 1:
    d = list(map(str, input().split()))
    X = list(d[0])
    black = 0
    for i in range(W):
        if X[i] == "#":
            black += 1

    t = 0
    s = "0" + str(W) + "b"

    #消すバージョン
    if K == 0:
        t += 2**W

    #消さない
    for i in range(2**W):
        black_xx = black
        WW = format(i, s)
        for j in range(W):
            if X[j] == "#":
                black_xx -= 1
        if black_xx == K:
            t += 1

    print(t)

elif W == 1:
    X = []
    for i in range(H):
        X.append(input())
    black = 0
    for i in range(H):
        if X[i] == "#":
            black += 1

    t = 0
    s = "0" + str(H) + "b"

    #消すバージョン
    if K == 0:
        t += 2**H

    #消さない
    for i in range(2**H):
        black_xx = black
        HH = format(i, s)
        for j in range(H):
            if X[j] == "#":
                black_xx -= 1
        if black_xx == K:
            t += 1

    print(t)



else:
    d = list(map(str, input().split()))
    X = list(d[0])
    for i in range(H - 1):
        d = list(map(str, input().split()))
        d = list(d[0])
        X = np.vstack((X, d))

    black = 0
    for i in range(X.shape[0]):
        for j in range(X.shape[1]):
            if X[i,j] == "#":
                black += 1

    t = 0
    s1 = "0" + str(H) + "b"
    s2 = "0" + str(W) + "b"
    for i in range(2**H):
        for j in range(2**W):

            XX = copy.copy(X)
            black_xx = black
            HH = format(i, s1)
            WW = format(j, s2)

            for ii in range(H):
                if HH[ii] == "1":
                    for iii in range(W):
                        if XX[ii,iii] == "#":
                            black_xx -= 1
                            XX[ii,iii] = "."
            for jj in range(W):
                if WW[jj] == "1":
                    for jjj in range(H):
                        if XX[jjj,jj] == "#":
                            black_xx -= 1
                            XX[jjj,jj] = "."
            if black_xx == K:
                t += 1

    print(t)

Submission status: Wrong Answer

Solution code:
from sys import stdin

def readline_from_stdin() -> str:
    return stdin.readline().rstrip

def cT(c) -> int:
    ccc = [cc.count(True) for cc in c]
    return sum(ccc)

def sortFn(c) -> list:
    nl = sorted(c, key=lambda x: x.count(True), reverse=True)
    return nl

def compFn(c) -> list:
    return [cc.count(True) for cc in c]

def combiFn(c) -> list:
    combi = [list(itertools.combinations(c, v+1)) for v in range(len(c))]
    combina = [ [ list(v)  for v in vvv]    for vvv in combi]
    return list(itertools.chain.from_iterable(combina))
    # return combina

def countCombiFn(c, X) -> int:
    combiSum = [list(itertools.combinations(c, v+1)) for v in range(len(c))]
    combinaSum = [ [list(v) for v in vvv] for vvv in combiSum]
    f1 = list(itertools.chain.from_iterable(combinaSum))
    # print(len(f1))
    # f2 = list(itertools.chain.from_iterable(f1))
    sumF1 = [sum(v) for v in f1]
    # print(sumF1)
    # print(sumF1.count(X))
    return sumF1.count(X)


if __name__ == '__main__':
    import itertools

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

    C = [[False if i == "." else True for i in input()] for i in range(H)]
    # sC = sortFn(C)
    comped = compFn(C)
    combi = combiFn(comped)
    # print(len(combi))
    # print(combi)
    cntArr = [countCombiFn(c, K) for c in combi]
    # print(cntArr)
    print(sum(cntArr))
    # print(sum(cntArr))

Submission status: Wrong Answer

Solution code:
import numpy as np

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

for i in range(H):
    l = list(input())
    l2 = []
    for j in l:
        if j == ".":
            l2.append(1)
        if j == "#":
            l2.append(2)
    box.append(l2)

ans = 0
for row in range(H+1):
    for col in range(W+1):
        npBox = np.array(box)
        if row != 0:
            npBox[row-1] = 3
        if col != 0:
            npBox[:, col-1] = 3
        if np.sum(npBox == 2 ) == K:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#import copy
h,w,k = list(map(int,input().split()))

c = []
count = 0
for i in range(h):
    cl = list(input())
    c.append(cl)
    count += cl.count("#")

hc = 2 ** h
wc = 2 ** w
result = 0

for i in range(hc):
    for j in range(wc):
        mc = 0
        hc2 = i
        hclis = []
        if i == 0:
            hclis = [0]
        while hc2 != 0:
            hclis.append(hc2 % 2)
            hc2 = hc2 // 2
        #cc = copy.copy(c)
        wc2 = j
        wclis = []
        if j == 0:
            wclis = [0]
        while wc2 != 0:
            wclis.append(wc2 % 2)
            wc2 = wc2 // 2
        #print(hclis,wclis)
        for k1 in range(len(hclis)):
            if hclis[k1] == 1:
                mc += c[k1].count("#")
            for k2 in range(len(wclis)):
                #if hclis[k1] == 1:
                    #mc += c[k1].count("#")
                if wclis[k2] == 1:
                    for l in range(h):
                        if c[l][k2] == "#":
                            mc += 1
                if hclis[k1] == 1 and wclis[k2] == 1 and c[k1][k2] == "#":
                    mc -= 1
                    #if cc[k1][k2] == "#":
                    #   mc += 1
                    #   cc[k1][k2] = "."
        if count - mc == k:
            result += 1
            #print(hclis,wclis)
            #print(c,mc)


#print(c)
#print(count)
print(result)

Submission status: Wrong Answer

Solution code:
def sumup(lst):
  sum = 0
  for i in range(len(lst)):
    sum += int(lst[i])
  return sum

h, v, k = map(int,input().split())
C = []
for i in range(h):
    l = input()
    C.append(l)
    
black_hcounter = []
black_vcounter = []
black_hvcounter = []
for i in range(h):
  counter = 0
  for j in range(v):
    if C[i][j] == "#":
      counter += 1
  black_hcounter.append(counter)
sum = sum(black_hcounter)
for j in range(v):
  counter = 0
  for i in range(h):
    if C[i][j] == "#":
      counter += 1
  black_vcounter.append(counter)
  for i in range(h):
    if C[i][j] != "#":
      black_hvcounter.append(black_hcounter[i]+black_vcounter[j])
    else:
      black_hvcounter.append(black_hcounter[i]+black_vcounter[j]-1)

ans = 0
herasu = sum - k
if k == sum:
  ans = 1
else:
  for i in range(1<<h):
    l = []
    for j in range(h):
        if (i>>j & 1) == 1:
          l.append(black_hcounter[j])
    if len(l) > 0 and sumup(l) == herasu:
        ans += 1
  for i in range(1<<v):
    l = []
    for j in range(v):
        if (i>>j & 1) == 1:
          l.append(black_vcounter[j])
    if len(l) > 0 and sumup(l) == herasu:
        ans += 1  
  for i in range(1<<h*v):
    l = []
    for j in range(h*v):
        if (i>>j & 1) == 1:
          l.append(black_hvcounter[j])
    if len(l) > 0 and sumup(l) == herasu:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

cnt = 0
for i in range(2**H):
    si = list(str(bin(i))[2:].zfill(3))
    for j in range(2**W):
        sj = list(str(bin(j))[2:].zfill(3))
        a = np.array(c[:])
        for k in range(len(a)):
            if si[2-k] == '1':
                a[k] = '.'
        for k in range(len(a[0])):
            if sj[2-k] == '1':
                a[:, k] = '.'
        if np.count_nonzero(a == '#') == K: cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
from itertools import chain
def main():
    h,w,k=map(int,input().split())
    C=[]
    Copy=[]
    for i in range(h):
        C.append(list(input()))
    hw=3600
    jh=0
    al=[]
    for i in range(hw):
        Copy=deepcopy(C)
        try:
            for j in range(len(str(bin(i)))-2):
                if (i>>j)&1:
                    if j>h-1:
                        jh=j-h
                        for K in range(h):
                            Copy[K][jh]="%"
                    else:
                        for K in range(w):
                            Copy[j][K]="%"
        except:
            pass
        al.append("".join(list(chain.from_iterable(Copy))))
    xx=list(set(al))
    c=0
    for i in range(len(xx)):
        zz=xx[i].count("#")
        if zz==k:
            c+=1
    print(c)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
h,w,k = readInts()
c = [input() for _ in range(h)]
# dp = [[0] * (w+1) for _ in range(h+1)]
# dp[0][0] = 1
# # dp[i+1][j+1] = i列目, j行目を選んだ時
black = 0
for nya in c:
    black += nya.count('#')

# 視点からどのくらいの距離を見るか
ans = 0

if black == k:
    print(1)
elif h*w == black:
    print(0)
else:
    for bitx in range(1 << w):
        for bity in range(1 << h):
            cost = 0
            table = [[0] * w for _ in range(h)]
            for y in range(h):
                for x in range(w):
                    if bitx & (1 << x):
                        for i in range(h):
                            table[i][x] = 1
                    if bity & (1 << y):
                        for i in range(w):
                            table[y][i] = 1
            for y in range(h):
                for x in range(w):
                    if table[y][x] == 1:
                        if c[y][x] == '#':
                            cost += 1
            if black - cost == k:
                ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
# from pprint import pprint
# import math
# import collections
import numpy as np
import itertools

# n = int(input())
h, w, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

white = '.'
black = '#'

c = []
c2 = [[0] * w for h in range(h)]
for i in range(h):
    c.append(list(input()))

for i in range(h):
    for j in range(w):
        c2[i][j] = 1 if c[i][j] == black else 0

# print(c2)

nc = np.array(c2)

black_total = np.sum(c2)

h_blacks = list(np.sum(c2, axis=1))
w_blacks = list(np.sum(c2, axis=0))

# print(h_blacks)
# print(w_blacks)

# bit全探索
pattern = []
cnt = 0
for _h in list(itertools.product([0, 1], repeat=h)):
    for _w in list(itertools.product([0, 1], repeat=w)):
        total = 0
        cross = 0
        for i, ih in enumerate(_h):
            if ih == 1:
                total += h_blacks[i]
        for j, jw in enumerate(_w):
            if jw == 1:
                total += w_blacks[j]

        for i, ih in enumerate(_h):
            for j, jw in enumerate(_w):
                if c2[i][j] == 1 and ih == 1 and jw == 1:
                    cross += 1

        ans = total - cross
        # print(_h,_w)
        # print(ans)
        if ans == k:
            cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
import re
import copy

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

temp_l=copy.deepcopy(lis)
  
for l in range(0,h):
  for k in range(0,w):
   kuro=0
   lis[l][k]=re.sub(".|#","r",lis[l][k])
   for m in lis:
    for n in m:
     if n=="#":
      kuro+=1
   if kuro==k:    
       ans+=1

for l in range(0,w):
  for k in range(0,h):
   kuro=0
   lis[k][l]=re.sub(".|#","r",lis[k][l])
   for m in lis:
    for n in m:
     if n=="#":
      kuro+=1
   if kuro==k:    
       ans+=1     
           
print(ans)

Submission status: Wrong Answer

Solution code:
import re
import copy

h,w,k=map(int,input().split())
lis=[]
ans=1
for i in range(h):
 lis.append(list(map(str,input())))

temp_l=copy.deepcopy(lis)
  
for l in range(0,h):
  for k in range(0,w):
   kuro=0
   lis[l][k]=re.sub(".|#","r",lis[l][k])
   for m in lis:
    for n in m:
     if n=="#":
      kuro+=1
   if kuro==k:    
       ans+=1

for l in range(0,w):
  for k in range(0,h):
   kuro=0
   lis[k][l]=re.sub(".|#","r",lis[k][l])
   for m in lis:
    for n in m:
     if n=="#":
      kuro+=1
   if kuro==k:    
       ans+=1     
           
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
import copy

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


def count_s(s):
    cnt = 0
    for ss in s:
        cnt += ss.count('.')
    return h*w-cnt

out=0
xx=h+w
if count_s(data) == k:
    out = 1

for kk in range(1,k+1):
    lst = list(itertools.combinations([x for x in range(xx)], kk))
    for ll in lst:
        dd = copy.deepcopy(data)
        for l in ll:
            if l >= h:
                for i in range(h):
                    buf = dd[i]
                    dd[i]=buf[:l-h]+'.'+buf[l-h+1:]
            else:
                dd[l]='.'*w
        if count_s(dd) == k:
            out += 1

print(out)

Submission status: Wrong Answer

Solution code:
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前
sort()
sorted(reverse=true)
配列の初期化
配列名=[a]*n+[b]*m
Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions
import sys
d = stdin.readline().rstrip().split()
H = int(d[0])
W = int(d[1])
K = int(d[2])

data = []
bCount = 0
result = 0
for el1 in range(H):
    tmp = stdin.readline().rstrip().split()
    d = []
    for el in tmp:
        for el3 in el:
            if el3 == '#':
                bCount += 1
            d.append(el3)
    data.append(d)
tr = []
for i in range(W):
    tr_row = []
    for vecto in data:
        tr_row.append(vecto[i])
    tr.append(tr_row)
data2 = tr
counter = 0
for el in range(H+W):
    counter += 2**el
for el in range(counter+1):
    bin_str = ''.join(list(reversed(str(bin(el))[2:])))
    poss = []
    count = 0
    for el2 in bin_str:
        if el2 == '1':
            poss.append(count)
        count += 1
    res = 0
    for el2 in poss:
        if el2 >= H:
            el2 -= H
            res += data2[el2].count('#')
        else:
            res += data[el2].count('#')
    if bCount-res == K:
        result += 1

print(result)

Submission status: Wrong Answer

Solution code:
import copy
import itertools
def main():
    H, W,K = map(int, input().split())
    c = []
    for i in range(H):
        c.append(list(input()))
    # print(c)
    alllist = [x for x in range(H+W)]
    ans = 0
    for i in range(1, H+W):
        numlist = list(itertools.combinations(alllist, i))
        for num in numlist:
            R = []
            C = []
            for n in num:
                if n < H:
                    R.append(n)
                else:
                    C.append(n-H)
            cnt = 0
            for h in range(H):
                for w in range(W):
                    if not h in R and not w in C:
                        if c[h][w] == '#':
                            cnt += 1
            if cnt == K:
                ans += 1
    print(ans)
                    
                
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
from itertools import chain
def main():
    h,w,k=map(int,input().split())
    C=[]
    Copy=[]
    for i in range(h):
        C.append(list(input()))
    hw=3600
    jh=0
    al=[]
    for i in range(hw):
        Copy=deepcopy(C)
        try:
            for j in range(len(str(bin(i)))+1):
                if (i>>j)&1:
                    if j>h-1:
                        jh=j-h
                        for K in range(h):
                            Copy[K][jh]="%"
                    else:
                        for K in range(w):
                            Copy[j][K]="%"
        except:
            pass
        al.append("".join(list(chain.from_iterable(Copy))))
    xx=list(set(al))
    c=0
    for i in range(len(xx)):
        zz=xx[i].count("#")
        if zz==k:
            c+=1
    print(c)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from itertools import product
import copy
H,W,K=map(int,input().split())
C=[]
if H==1 and W==1:
    tp=input()
    if tp=='#':
        print(0)
    else:
        print(1)
    exit()

else:
    for _ in range(H):
        C.append(list(input()))
    ans=0
    cnt=0
    for h in product(range(2),repeat=H):
        for w in product(range(2),repeat=W):
            num=0
            C_cp=copy.deepcopy(C)
            #print('C_cp_is',C_cp)
            for j in range(W):
                if w[j]==1:
                    for i in range(H):
                        C_cp[i][j]='r'

            for i in range(H):
                if h[i]==1:
                    for j in range(W):
                        C_cp[i][j]='r'
           # print(h,w)
            #print(C_cp)
            for i in range(H):
                num+=C_cp[i].count('#')
           # print(num)
            if num==K:
                ans+=1
                if (all(h)==True or all(w)==True) and (H==1 or W==1):
                    cnt+=1

print(ans-cnt//2)

Submission status: Wrong Answer

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


import numpy as np
import copy
import itertools


input_line = list(map(int,input().split(" ")))
H,W,K = input_line[0],input_line[1],input_line[2]
masu = np.array([list(input()) for i in range(H)])

H_list = [i for i in range(H)]
W_list = [i for i in range(W)]
lists = []
for i in H_list:
  for j in W_list:
    lists.append([i,j])
    
def bit(list1):
    solve = []
    for i in range(2**len(list1)):  # 空集合を除く場合はrange(1, 2**len(list1))
        list2 = []
        for j in range(len(list1)):
            if (i >> j) &1 == 1:
                list2.append(list1[j])
        solve.append(list2)
    return solve

H_bit = bit(H_list)
W_bit = bit(W_list)[1:]
# print(H_bit)
# print(lists)
masu_copy = copy.deepcopy(masu)
answer = 0
for i in lists:
    h,w = i[0],i[1]
    masu_copy = np.delete(masu_copy,h,0)
    masu_copy = np.delete(masu_copy,w,1)
    # print(masu_copy)
    solve = np.count_nonzero(masu_copy == "#")
    if solve == K: answer += 1
    masu_copy = copy.deepcopy(masu)

for i in H_bit:
    masu_copy = np.delete(masu_copy,i,0)
    solve = np.count_nonzero(masu_copy == "#")
    # print(masu_copy)
    if solve == K: answer += 1
    masu_copy = copy.deepcopy(masu)

for i in W_bit:
    masu_copy = np.delete(masu_copy,i,1)
    solve = np.count_nonzero(masu_copy == "#")
    # print(masu_copy)
    if solve == K: answer += 1
    masu_copy = copy.deepcopy(masu)

print(answer)