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
H,W,K = map(int,input().split())
s = [list(input()) for i in range(H)]
laynum = []
rownum = []
for i in range(H):
    blnum = 0
    for j in range(W):
        if s[i][j] == "#":
            blnum += 1
    laynum.append(blnum)
for i in range(W):
    blnum = 0
    for j in range(H):
        if s[j][i] == "#":
            blnum+=1
    rownum.append(blnum)
total = sum(laynum)
if total == K:
    print(1)
    sys.exit()
way = 0
for i in laynum:
    for j in rownum:
        if i==total-K or j==total-K or j+i==total-K:
            way+=1
for s in range(0,len(laynum)):
    for t in range(s+1,len(laynum)):
        if laynum[s]+laynum[t] == total-K:
            way+=1
for s in range(0,len(rownum)):
    for t in range(s+1,len(rownum)):
        if rownum[s]+rownum[t] == total-K:
            way+=1
print(way)

Submission status: Wrong Answer

Solution code:
H,W,K = map(int,input().split())
s = [list(input()) for i in range(H)]
laynum = []
rownum = []
for i in range(H):
    blnum = 0
    for j in range(W):
        if s[i][j] == "#":
            blnum += 1
    laynum.append(blnum)
for i in range(W):
    blnum = 0
    for j in range(H):
        if s[j][i] == "#":
            blnum+=1
    rownum.append(blnum)
total = sum(laynum)
way = 0
for i in laynum:
    for j in rownum:
        if i==total-K or j==total-K or j+i==total-K:
            way+=1
for s in range(0,len(laynum)):
    for t in range(s+1,len(laynum)):
        if laynum[s]+laynum[t] == total-K:
            way+=1
for s in range(0,len(rownum)):
    for t in range(s+1,len(rownum)):
        if rownum[s]+rownum[t] == total-K:
            way+=1
if way == 0:
    way = 1
print(way)

Submission status: Wrong Answer

Solution code:
H,W,K = map(int,input().split())
s = [list(input()) for i in range(H)]
laynum = []
rownum = []
for i in range(H):
    blnum = 0
    for j in range(W):
        if s[i][j] == "#":
            blnum += 1
    laynum.append(blnum)
for i in range(W):
    blnum = 0
    for j in range(H):
        if s[j][i] == "#":
            blnum+=1
    rownum.append(blnum)
total = sum(laynum)
way = 0
for i in laynum:
    for j in rownum:
        if i==total-K or j==total-K or j+i==total-K:
            way+=1
for s in range(0,len(laynum)):
    for t in range(s+1,len(laynum)):
        if laynum[s]+laynum[t] == total-K:
            way+=1
for s in range(0,len(rownum)):
    for t in range(s+1,len(rownum)):
        if rownum[s]+rownum[t] == total-K:
            way+=1
print(way)

Submission status: Wrong Answer

Solution code:
H,W,K = map(int,input().split())
s = [list(input()) for i in range(H)]
laynum = []
rownum = []
for i in range(H):
    blnum = 0
    for j in range(W):
        if s[i][j] == "#":
            blnum += 1
    laynum.append(blnum)
for i in range(W):
    blnum = 0
    for j in range(H):
        if s[j][i] == "#":
            blnum+=1
    rownum.append(blnum)
total = sum(laynum)
way = 0
for i in laynum:
    for j in rownum:
        if i==total-K or j==total-K or j+i==total-K:
            way+=1
for s in range(0,len(laynum)):
    for t in range(s,len(laynum)):
        if laynum[s]+laynum[t] == total-K:
            way+=1
for s in range(0,len(rownum)):
    for t in range(s,len(rownum)):
        if rownum[s]+rownum[t] == total-K:
            way+=1
print(way)

Submission status: Wrong Answer

Solution code:
H,W,K = map(int,input().split())
s = [list(input()) for i in range(H)]
laynum = []
rownum = []
for i in range(H):
    blnum = 0
    for j in range(W):
        if s[i][j] == "#":
            blnum += 1
    laynum.append(blnum)
for i in range(W):
    blnum = 0
    for j in range(H):
        if s[j][i] == "#":
            blnum+=1
    rownum.append(blnum)
total = sum(laynum)
way = 0
for i in laynum:
    for j in rownum:
        if i==total-K or j==total-K or j+i==total-K:
            way+=1
            print(i,j)
for s in range(0,len(laynum)):
    for t in range(s,len(laynum)):
        if laynum[s]+laynum[t] == total-K:
            way+=1
for s in range(0,len(rownum)):
    for t in range(s,len(rownum)):
        if rownum[s]+rownum[t] == total-K:
            way+=1
print(way)

Submission status: Wrong Answer

Solution code:
H,W,K = map(int,input().split())
s = [list(input()) for i in range(H)]
laynum = []
rownum = []
for i in range(H):
    blnum = 0
    for j in range(W):
        if s[i][j] == "#":
            blnum += 1
    laynum.append(blnum)
for i in range(W):
    blnum = 0
    for j in range(H):
        if s[j][i] == "#":
            blnum+=1
    rownum.append(blnum)
total = sum(laynum)
way = 0
for i in laynum:
    for j in rownum:
        if i==total-K or j==total-K or j+i==total-K:
            way+=1
print(way)

Submission status: Wrong Answer

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

    n = H + W
    ans = 0
    for case in range(2**n):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (case >> i) & 1:
                    if (case >> j + H) & 1:
                        if grid[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())
c = [input() for i in range(h)]
ans = 0

for maskR in product([0,1], repeat=h):
    for maskC in product([0,1], repeat=w):
        b = 0
        for i in range(h):
            for j in range(w):
                if maskR[i]==1 and maskC[j]==1 and c[i][j]=="#":
                    b += 1
            if b == k:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import product
h, w, k = map(int, input().split())
c = []
ans = 0
for i in range(h):
    li = list(input())
    c.append(li)
for maskR in product([0,1], repeat=h):
    for maskC in product([0,1], repeat=w):
        b = 0
        for i in range(h):
            for j in range(w):
                if maskR[i]==1 and maskC[j]==1 and c[i][j]=="#":
                    b += 1
            if b == k:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
h, w, k = map(int, input().split())
grid = np.zeros((h, w))
ans = 0
for i in range(h):
    li = list(input())
    for j in range(w):
        if li[j]=="#":
            grid[i, j] = 1
for maskR in range(1<<h):
    for maskC in range(1<<w):
        b = 0
        for i in range(h):
            for j in range(w):
                if((maskR >> i) & 1)==0 and ((maskC>>j) & 1)==0 and grid[i][j]==1:
                    b += 1
            if b == k:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
h, w, k = map(int, input().split())
grid = np.zeros((h, w))
ans = 0
for i in range(h):
    li = list(input())
    for j in range(w):
        if li[j]=="#":
            grid[i, j] = 1
for maskR in range(2**h):
    for maskC in range(2**w):
        b = 0
        for i in range(h):
            for j in range(w):
                if((maskR >> i) & 1)==0 and ((maskC>>j) & 1)==0 and grid[i][j]==1:
                    b += 1
            if b == k:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import copy

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

for i in range(-1,H):
    for j in range(-1,W):
        map = copy.deepcopy(c)
        sharp = 0

        if i != -1:
            for k in range(W):
                map[i][k] = "-"

        if j != -1:
            for k in range(H):
                map[k][j] = "-"

        for k in map:
            for l in k:
                if l == "#":
                    sharp += 1
        print(map)
        if sharp == K:
            count += 1
print(count)

Submission status: Wrong Answer

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

for i in range(-1,H):
    for j in range(-1,W):
        sharp = 0
        if i != -1:
            for k in range(W):
                c[i][k] = "-"
        if j != -1:
            for k in range(H):
                c[k][j] = "-"

        for a in c:
            for b in a:
                if b == "#":
                    sharp += 1
        if sharp == K:
            count += 1

print(count)

Submission status: Wrong Answer

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

for mask_h in range(2 ** H):
  for mask_w in range(2 ** W):
    black = 0
    for i in range(H):
      for j in range(W):
        if ((mask_h >> i) & 1 == 0) and ((mask_w >> j) & 1 == 0) and table[i][j] == '#': # 塗り潰し行、列ではなくて、色が黒'#'の場合
          black += 1

  if black == K:
    ans += 1
print(str(ans))

Submission status: Wrong Answer

Solution code:
def main():
    a,b,c = map(int,input().split())
    s =[list(map(str,input()))for i in range(a)]
    cnt =0
    count=0
    for i in range(2*a):
        for j in range(2**b):
            cnt=0
            for ia in range(a):
                if i &(1<<ia):continue
                for ib in range(b):
                    if j&(1<<ib):continue
                    if s[ia][ib] =='#':
                        cnt+=1
            if cnt ==c:
                count+=1
    print(count)
if __name__ =='__main__':
    main()

Submission status: Wrong Answer

Solution code:
h, w, k = map(int, input().split(' '))
print(h, w, k)
c = [input() for x in range(h)]
cnt = 0
for m in range(2**(h+w)):
    cc = c.copy()
    for ij in range(h+w):
        if ((m >> ij) & 1):
            if ij in range(h):
                cc[ij] = '.'*w
            if ij in range(h,h+w):
                for t in range(h):
                    cc[t] = cc[t][:ij-h]+'.'+cc[t][ij+1-h:]
    num = sum(cc[s].count('#') for s in range(h))
    if num == k:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
H, W, K, = list(map(int, input().split()))
C = [0] * H
for i in range(H):
  C[i] = input()
  C[i] = [1 if(C[i][j] == "#") else 0 for j in range(W)]
h = 2 ** H
w = 2 ** W
ans = 0
cnt = 0
for i in range(2 ** H):
  w = 2 ** W
  for j in range(2 ** W):
    cnt = 0
    for k in range(H):
      for l in range(W):
        if(bin(h)[k + 3] == "0" and bin(w)[l + 3] == "and"):
          cnt += int(D[k][l])
    ans += (cnt == K)
    w += 1
  h += 1
print(ans)

Submission status: Wrong Answer

Solution code:
H, W, K, = list(map(int, input().split()))
C = [0] * H
for i in range(H):
  C[i] = input()
  C[i] = [1 if(C[i][j] == "#") else 0 for j in range(W)]
h = 2 ** H
w = 2 ** W
ans = 0
cnt = 0
for i in range(2 ** H):
  w = 2 ** W
  for j in range(2 ** W):
    cnt = 0
    for k in range(H):
      for l in range(W):
        if(bin(h)[k + 3] == "0" and bin(w)[l + 3] == "and"):
          cnt += D[k][l]
    ans += (cnt == K)
    w += 1
  h += 1
print(ans)

Submission status: Wrong Answer

Solution code:
S =input()
if S[1] =='B':
    print('R')
else:
    print('B')

Submission status: Wrong Answer

Solution code:
from itertools import product

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

ans = 0

for row_bit in product(range(2), repeat=h):
  for col_bit in product(range(2), repeat=w):
    cnt = 0
    for row in range(h):
      for col in range(w):
        if c[row][col] == '#' and (row_bit[row] | col_bit[col]) == 1:
          cnt += 1
    if cnt == k:
      ans += 1
    
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
a = input().split()
H = int(a[0])
W = int(a[1])
K = int(a[2])

C=np.zeros((H,W),dtype=str)
for i in range(H):
    C[i,:]= np.array(list(input()))

count =0

for S in range(2**(H+W)-1):
    p = np.zeros(H+W)
    s = np.append(p,np.array(list(bin(S))))

    ans = 0
    for i in range(H):
        for n in range(W):
            if  s[-n]== '0' or s[-n]== 'b':
               continue
            if  s[-(W+i)] == '0' or s[-(W+i)] == 'b':
               continue
            if C[i,n]=='#':
                ans+=1
    if ans == K:
        count+=1

print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#C for submisstion
import numpy as np
from itertools import combinations
H, W, K = map(int, input().split())
C=[input() for i in range(H)]
C_list=[list(C[i]) for i in range(H)]
C_cols=['c'+str(i) for i in range(H)]
C_rows=['r'+str(i) for i in range(W)]
C_comb=C_cols + C_rows

Comb=[]
for i in range(1, H+W):
    Comb+=combinations(C_comb,i)
    
result=0
for i in range(len(Comb)):
    C_array=np.array(C_list)
    for j in Comb[i]:
        if j[0]=='c':
            c_r=int(j[1:])
            C_array[c_r,:]='r'
        else:
            c_r=int(j[1:])
            C_array[:,c_r]='r'
    df_bool = (C_array=='#')
    result+= df_bool.sum()==K
    
if result==0 and (np.array(C_list) =='#').sum() ==K:
    result+=1
    
print(result)

Submission status: Wrong Answer

Solution code:
#C for submisstion
import numpy as np
from itertools import combinations
H, W, K = map(int, input().split())
C=[input() for i in range(H)]
C_list=[list(C[i]) for i in range(H)]
C_cols=['c'+str(i) for i in range(H)]
C_rows=['r'+str(i) for i in range(W)]
C_comb=C_cols + C_rows

Comb=[]
for i in range(1, H+W):
    Comb+=combinations(C_comb,i)
    
result=0
for i in range(len(Comb)):
    C_array=np.array(C_list)
    for j in Comb[i]:
        if j[0]=='c':
            c_r=int(j[1:])
            C_array[c_r,:]='r'
        else:
            c_r=int(j[1:])
            C_array[:,c_r]='r'
    array_bool = (C_array=='#')
    result+= array_bool.sum()==K
if result==0 and (np.array(C_list) =='#').sum() ==K:
    result=1
print(result)

Submission status: Wrong Answer

Solution code:
#C for submisstion
import numpy as np
from itertools import combinations
H, W, K = map(int, input().split())
C=[input() for i in range(H)]
C_list=[list(C[i]) for i in range(H)]
C_cols=['c'+str(i) for i in range(H)]
C_rows=['r'+str(i) for i in range(W)]
C_comb=C_cols + C_rows

Comb=[]
for i in range(1, H+W):
    Comb+=combinations(C_comb,i)
    
result=0
for i in range(len(Comb)):
    C_array=np.array(C_list)
    for j in Comb[i]:
        if j[0]=='c':
            c_r=int(j[1:])
            C_array[c_r,:]='r'
        else:
            c_r=int(j[1:])
            C_array[:,c_r]='r'
    array_bool = (C_array=='#')
    result+= array_bool.sum()==K
print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from itertools import combinations as comb
from itertools import chain
import numpy as np

# form bisect import bisect_left, bisect_right, insort_left, insort_right
# from collections import Counter


def solve(H, W, K, C):
    answer = 0
    for hn in range(min(K + 1, H + 1)):
        for wn in range(min(K + -hn + 1, W + 1)):
            for h_idxs in comb(range(H), hn):
                for w_idxs in comb(range(W), wn):
                    cs = C.copy()
                    cs[h_idxs,:] = 0
                    cs[:, w_idxs] = 0
                    answer += cs.sum() == K
    return answer

def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    H = int(next(tokens))
    W = int(next(tokens))
    K = int(next(tokens))
    C = np.array(
        [
            list(map(lambda x: {"#": 1, ".": 0}[x], line))
            for line in tokens
        ]
    )
    answer = solve(H, W, K, C)
    print(answer)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#ABC 173 C - H and V
import numpy as np

h,w,k = map(int,input().split())
c = np.zeros((h,w)).astype('str')
for i in range(h):
    s = input()
    for j,a in enumerate(s):
        c[i,j] = a
    
print(c)
cnt = 0
for o in range(2**h):
    for l in range(2**w):
        black = 0
        for m in range(h):
            for n in range(w):
                if ((o>>m)&1==0) and ((l>>n)&1==0) and (c[m,n]=='#'):
                    black += 1
        if black == k:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
from itertools import product

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

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

ans = 0

for row_bit in product(range(2), repeat = H):
    for col_bit in product(range(2), repeat = W):
        cnt = 0
        for row in range(H):
            for col in range(W):
                if C[row][col] == "#" and (row_bit[row] and col_bit[col]):
                    cnt += 1
            if cnt == K:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

in_=input().split()
H=int(in_[0])
W=int(in_[1])
K=int(in_[2])

c=np.zeros([H,W])
for i in range(H):
  in_=input()
  for j in range(len(in_)):
    if(in_[j]=='#'):
      c[i][j]=1
#print(c)
K_count=0
test=c
if(np.sum(test)==K):
  print(1)
else:
  N=2**(H+W)
  for n in range(N):
    test=np.array(c)
    num=bin(n)[2:]
    num='{:0>12}'.format(num)
    num=num[12-(H+W):]
    count=0
    for i in num[:H]:
      if(i=='0'):
        test[count]=np.zeros([1,W])
      count+=1
    
    count=0
    for i in num[H:]:
      if(i=='0'):
        test[:,count]=np.zeros([H])
      count+=1
    if(np.sum(test)==K):
      K_count+=1
      #print('OK')
    #print(test)
  print(K_count)

Submission status: Wrong Answer

Solution code:
from itertools import product

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

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

ans = 0

for row_bit in product(range(2), repeat = H):
    for col_bit in product(range(2), repeat = W):
        cnt = 0
        for row in range(H):
            for col in range(W):
                if C[row][col] == '#' and (row_bit[row] and col_bit[col]):
                    cnt += 1
            if cnt == K:
                ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
#take input from user
from itertools import product
from copy import deepcopy
h,w,k = map(int,input().split())
rows = [i for i in range(h)]
cols = [i for i in range(w)]
testLst = list(product(rows,cols))
newArr=[]

def testBlack(arrs,target):
    black = 0
    for arr in arrs:
        black+=arr.count('#')
    return True if black == target else False
        
for i in range(h):
    s = input()
    newArr.append([i for i in s])

ways = 0
if testBlack(newArr,k):
    ways+=1
for row,col in testLst:
    #Change the row
    i = row
    rowcopy = deepcopy(newArr)
    for j in range(w):
        rowcopy[i][j] = '$'
    if(testBlack(rowcopy,k)):
        ways+=1
    #Change the col
    colcopy = deepcopy(newArr)
    j = col
    for i in range(h):
        colcopy[i][j] = '$'
    if(testBlack(colcopy,k)):
        ways+=1
    #Change both 
    bothcopy = deepcopy(newArr)
    i = row
    for j in range(w):
        bothcopy[i][j] = '$'
    j = col 
    for i in range(h):
        bothcopy[i][j] = '$'
    if(testBlack(bothcopy,k)):
        ways+=1
print(ways)

Submission status: Wrong Answer

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

row = [0]*W + [0]
col = [0]*H + [0]

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

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

ans = 0
for i in range(H):
    for j in range(W):
        if col[i]+row[j] == K:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
h,w,k=map(int,input().split())
lst=[]
col=[]
row=[]
for i in range(h):
    c=input()
    row.append(c.count("#"))
    arr=[]
    for j in range(w):
        arr.append(c[j])
    lst.append(arr)

for i in range(h):
    for j in range(w):
        if(i==0):
            if(lst[i][j]=="#"):
                col.append(1)
            else:
                col.append(0)
        else:
            if(lst[i][j]=="#"):
                col[j]+=1

total=sum(col)
ct=0
for i in range(h):
    for j in range(w):
        if(lst[i][j]=="#"):
            left=total-row[i]-col[j]+1
        else:
            left=total-row[i]-col[j]
        if (left == k):
            ct += 1

for i in range(h):
    left=total-row[i]
    if(left==k):
        if(k%2==0):
            ct+=2
        else:
            ct+=1
for i in range(w):
    left=total-col[i]
    if(left==k):
        if(k%2==0):
            ct+=2
        else:
            ct+=1
if(total==k):
    ct+=1
print(ct)

Submission status: Wrong Answer

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

def count_num(m, target, goal):
    for i in range(h):
        count = sum(map(lambda x: x.count(target), m))
    
    return count == goal

def change_row(m, i_row_0):
    m[i_row_0] = 'r'*w    
    return m

def change_col(m, j_col_0):
    for i in range(h):
        if j_col_0 < w:
            m[i] = m[i][:j_col_0]+'r'+ m[i][j_col_0+1:]
    return m




for idx_h in range(2**h):
    for idx_w in range(2**w):
        m = masu.copy()
        for i_row, row in enumerate(m):
            if idx_h & (2 ** i_row) > 0:
                m = change_row(m, i_row)

            for j_col, col in enumerate(row):
                if idx_w & (2 ** j_col) > 0:
                    m = change_col(m, j_col)
        
        print(m)
        if count_num(m, '#', 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())
  
def countb(c):
  num = 0
  for i in range(h):
    num += c[i].count("#")
  return(num)

def printb(c, row, col):
  c = c[:]
  #print(row,col)
  cnt = 0
  while row != 0:
    if row  & 0b1:
     
      c[cnt] = "."*w
    cnt += 1
    row = row >> 1
  
  cnt = 0
  while col != 0:
    #print(col&0b1)
    if col & 0b1:
      for i in range(h):
        c[i] = c[i][:cnt]+"."+c[i][cnt+1:]
    cnt += 1
    col = col >> 1
    
  #print("\n".join(c))
  return countb(c)

if countb(c) == k:
  print(1)
else:
  ans = 0
  for i in range(2**h):
    for j in range(2**w):
      if printb(c,i,j) == 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())
  
def countb(c):
  num = 0
  for i in range(h):
    num += c[i].count("#")
  return(num)

def printb(c, row, col):
  c = c[:]
  #print(row,col)
  cnt = 0
  while row != 0:
    if row  & 0b1:
     
      c[cnt] = "."*w
    cnt += 1
    row = row >> 1
  
  cnt = 0
  while col != 0:
    #print(col&0b1)
    if col & 0b1:
      for i in range(h):
        c[i] = c[i][:cnt]+"."+c[i][cnt+1:]
    cnt += 1
    col = col >> 1
    
  #print("\n".join(c))
  return countb(c)

if countb(c) == k:
  print(0)
else:
  ans = 0
  for i in range(2**h):
    for j in range(2**w):
      if printb(c,i,j) == k:
        ans += 1
  print(ans)

Submission status: Wrong Answer

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

masu = [input() for _ in range(h)]

ans = 0
for idx_h in range(2 ** h):
    for idx_w in range(2 ** w):
        m = masu.copy()
        for i_row, row in enumerate(m):
            for j_col, col in enumerate(row):
                if idx_h & (2 ** i_row) > 0 and idx_w & (2 ** j_col) > 0:
                    # m[i_row][j_col] = 'r'
                    m[i_row] = m[i_row][:j_col] + 'r' + m[i_row][j_col+1:]
        
        count_black = sum(map(lambda x: x.count('#'), m))
        if count_black == k:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import copy

N = list(map(int,input().split(' ')))
X =[input() for i in range(N[0])] 
X1 = []
A_count = 0
for i in X:
    T = list(i)
    X1.append(T)

def p(X):
    print(X)


def change(z,X1):
    if z==0:
        pass
    elif z <= N[0]:
        for a in range(N[1]):
            X1[z-1][a] = '赤'

    else :
        for b in range(N[0]):
            X1[b][z-N[0]-1] ='赤'

for c in range(N[0]+N[1]+1):
    for d in range(c,N[0]+N[1]+1):
        if (c != 0 and d!=0)  and  c==d:
            pass
        else:
            X2=copy.deepcopy(X1)
            change(c,X2)
            change(d,X2)
            K_count = 0
            for e in X2:
                K_count += e.count('#')
            
            if K_count == N[2]:
                A_count += 1




p(A_count)

Submission status: Wrong Answer

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

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

for rows in range(1 << h):
    for cols in range(1 << w):
        black = 0
        for i in range(h):
            for j in range(w):
                if ((rows << i) & 1) == 0 and ((cols << j) & 1) == 0 and c[i][j] == '#':
                    black += 1

        if black == k:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
# input here
_INPUT = """\
2 3 2
..#
###
"""

def main():
    H, W, K = map(int, input().split())
    grid = [input() for _ in range(H)]
    print(grid)

    n = H + W
    ans = 0
    for i in itertools.product(range(2), repeat=H):
        for j in itertools.product(range(2), repeat=W):
            cnt = 0            
            for y in range(H):
                if i[y]:
                    continue
                for x in range(W):
                    if j[x]:
                        continue
                    if grid[y][x] == "#":
                            cnt += 1
            if cnt == K:
                ans += 1
    print(ans)

if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools

    # sys.stdin = io.StringIO(_INPUT)
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# import sys
# input = sys.stdin.readline
import itertools
import collections
from decimal import Decimal
from functools import reduce


# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    H, W, k = input_list()
    maze = [list(input()) for _ in range(H)]
    ans = 0
    for row_bit in itertools.product(range(2), repeat=H):
        for col_bit in itertools.product(range(2), repeat=W):
            print(row_bit, col_bit)
            cnt = 0
            for row in range(H):
                for col in range(W):
                    if maze[row][col] == "#" and (row_bit[row] and col_bit[col]):
                        cnt += 1
            if cnt == k:
                ans += 1
    print(ans)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def bfs(H, W, black_cells, dist):
    d = 0
    while black_cells:
        h, w = black_cells.popleft()
        d = dist[h][w]
        for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
            new_h = h + dy
            new_w = w + dx
            if new_h < 0 or H <= new_h or new_w < 0 or W <= new_w:
                continue
            if dist[new_h][new_w] == -1:
                dist[new_h][new_w] = d + 1
                black_cells.append((new_h, new_w))
    return d


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


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

pin=0
for i in range(h):
  pin+=lst[i].count('#')

ans=0

for hei in itertools.product(range(2),repeat=h):
  for wid in itertools.product(range(2),repeat=w):
    cnt=0
    for i in range(h):
      for j in range(w):
        if hei[i]==1 and wid[j]==1 and lst[i][j]=="#":
          cnt+=1
    
    if cnt==k:
      ans+=1

Submission status: Wrong Answer

Solution code:
H,W,K=map(int,input().split())
L=[[x for x in input()] for i in range(H)]
ans=0
for i in range(2**H):
    for j in range(2**W):
        C=L[:]
        for k in range(H):
            if (i>>k&1):
                C[k]=["r"]*W
        for l in range(W):
            if (j>>l&1):
                for m in range(H):
                    C[m][l]="r"
        count=0
        for p in range(H):
            for q in range(W):
                if C[p][q]=="#":
                    count+=1
        if count==K:
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import product

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())
  
H,W,K=input2()
c=[list(input()) for _ in range(H)]

ans=0
print(c)

for row_line in product(range(2),repeat=H): #[行]0:そのまま，1:赤く塗る
	for col_line in product(range(2), repeat=W): #[列]0:そのまま，1:赤く塗る
		# 黒("#")の数え上げ
		cnt=0
		for row in range(H):
			for col in range(W):
				if c[row][col]=="#" and row_line[row]==0 and col_line[col]==0:
					cnt+=1

		if cnt==K:
			ans+=1
print(ans)