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:
def main():
    R, C, K = map(int, input().split())
    grid = []
    for r in range(R):
        grid.append([1 if c == '#' else 0 for c in input()])
                
    n_configs = 0

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

    print(n_configs, flush=True)

Submission status: Wrong Answer

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

result = 0
for i in range(1 << h):
  for j in range(1 << w):
    cnt = 0
    for n in range(h):
      if i >> n & 1:
        continue

      for m in range(w):
        if j >> m & 1:
          continue

        if C[n][m] == '#':
          cnt += 1

      if cnt == k:
      	result += 1

print(result)

Submission status: Wrong Answer

Solution code:
h, w, k = map(int, input().split())
grid = [input() for _ in range(h)]
ans = 0
for i in range(1<<h):
  for j in range(1<<w):
    count = 0
    for x in range(h):
      for y in range(w):
        if grid[x][y] == '#':
          count += 1 
    if count == k:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
# do a search over the total space of [br, er), [bc, ec)
# compile all cumulative counts of black squares
# record the total number of black squares

def cumul(grid):
  # cumu[r][c] = number of black squares in rectangle ending at
  # cell r-1, c-1
  R, C = len(grid), len(grid[0])
  cumu = [[0 for _ in range(C+1)] for _ in range(R+1)]
  for r in range(R):
    pr = 0
    for c in range(C):
      nb = 1 if grid[r][c] == '#' else 0
      cr = pr + nb
      cumu[r+1][c+1] = cr + cumu[r][c+1]
      pr = cr
  
  return cumu

def ct_black(cu, rb, re, cb, ce):
  # count number of remaining black after painting
  # this intersection
  ul = cu[rb][cb]
  ll = cu[-1][cb] - cu[re][cb]
  ur = cu[rb][-1] - cu[rb][ce]
  lr = cu[-1][-1] - cu[re][-1] - cu[-1][ce] + cu[re][ce]
  return ul + ll + ur + lr


def row_ranges(nrows):
  for rb in range(nrows):
    for re in range(rb + 1, nrows+1):
      yield rb, re
  yield 0, 0
  

def main():
  R, C, K = map(int, input().split())
  grid = []
  for r in range(R):
    grid.append(list(input()))
                
  cumu = cumul(grid)

  n_configs = 0

  for rb, re in iter(row_ranges(R)):
    for cb, ce in iter(row_ranges(C)):
      nb = ct_black(cumu, rb, re, cb, ce)
      # print(rb, re, cb, ce, nb)
      if nb == K:
        n_configs += 1
  
  
  print(n_configs, flush=True)
  return

Submission status: Wrong Answer

Solution code:
# do a search over the total space of [br, er), [bc, ec)
# compile all cumulative counts of black squares
# record the total number of black squares

def cumul(grid):
  # cumu[r][c] = number of black squares in rectangle ending at
  # cell r-1, c-1
  R, C = len(grid), len(grid[0])
  cumu = [[0 for _ in range(C+1)] for _ in range(R+1)]
  for r in range(R):
    pr = 0
    for c in range(C):
      nb = 1 if grid[r][c] == '#' else 0
      cr = pr + nb
      cumu[r+1][c+1] = cr + cumu[r][c+1]
      pr = cr
  
  return cumu

def ct_black(cu, rb, re, cb, ce):
  # count number of remaining black after painting
  # this intersection
  ul = cu[rb][cb]
  ll = cu[-1][cb] - cu[re][cb]
  ur = cu[rb][-1] - cu[rb][ce]
  lr = cu[-1][-1] - cu[re][-1] - cu[-1][ce] + cu[re][ce]
  return ul + ll + ur + lr


def row_ranges(nrows):
  for rb in range(nrows):
    for re in range(rb + 1, nrows+1):
      yield rb, re
  yield 0, 0
  

def main():
  R, C, K = map(int, input().split())
  grid = []
  for r in range(R):
    grid.append(list(input()))
                
  cumu = cumul(grid)

  n_configs = 0

  for rb, re in iter(row_ranges(R)):
    for cb, ce in iter(row_ranges(C)):
      nb = ct_black(cumu, rb, re, cb, ce)
      print(rb, re, cb, ce, nb)
      if nb == K:
        n_configs += 1
  
  
  print(n_configs, flush=True)

Submission status: Wrong Answer

Solution code:
# do a search over the total space of [br, er), [bc, ec)
# compile all cumulative counts of black squares
# record the total number of black squares

def cumul(grid):
  R, C = len(grid), len(grid[0])
  cumu = [[0 for _ in range(C+1)] for _ in range(R+1)]
  for r in range(R):
    pr = 0
    for c in range(C):
      nb = 1 if grid[r][c] == '#' else 0
      cr = pr + nb
      cumu[r+1][c+1] = cr + cumu[r][c+1]
      pr = cr
  
  return cumu

def ct_black(cu, rb, re, cb, ce):
  # count number of remaining black after painting
  # this intersection
  ul = cu[rb][cb]
  ll = cu[-1][cb] - cu[re-1][cb]
  ur = cu[rb][-1] - cu[rb][ce]
  lr = cu[-1][-1] - cu[re][-1] - cu[-1][ce] + cu[re][ce]
  return ul + ll + ur + lr

  
  

def main():
  R, C, K = map(int, input().split())
  grid = []
  for r in range(R):
    grid.append(list(input()))
                
  cumu = cumul(grid)

  n_configs = 0
  for rb in range(R+1):
    for re in range(rb, R+1):
      for cb in range(C+1):
        for ce in range(cb, C+1):
          if ct_black(cumu, rb, re, cb, ce) == K:
            n_configs += 1
  
  
  print(n_configs, flush=True)

Submission status: Wrong Answer

Solution code:
# do a search over the total space of [br, er), [bc, ec)
# compile all cumulative counts of black squares
# record the total number of black squares

def cumul(grid):
  R, C = len(grid), len(grid[0])
  cumu = [[0 for _ in range(C)] for _ in range(R)]
  for r in range(R):
    pr = 0
    for c in range(C):
      nb = 1 if grid[r][c] == '#' else 0
      cr = pr + nb
      cumu[r][c] = cr if r == 0 else cr + cumu[r-1][c]
      pr = cr
  
  return cumu

def ct_black(cu, rb, re, cb, ce):
  # count number of remaining black after painting
  # this intersection
  ul = cu[rb][cb]
  ll = cu[-1][cb] - cu[re-1][cb]
  ur = cu[rb][-1] - cu[rb][ce-1]
  lr = cu[-1][-1] - cu[re-1][-1] - cu[-1][ce-1] + cu[re-1][ce-1]
  return ul + ll + ur + lr

  
  

def main():
  R, C, K = map(int, input().split())
  grid = []
  for r in range(R):
    grid.append(list(input()))
                
  cumu = cumul(grid)

  n_configs = 0
  for rb in range(R):
    for re in range(rb, R):
      for cb in range(C):
        for ce in range(cb, C):
          if ct_black(cumu, rb, re, cb, ce) == K:
            n_configs += 1
  
  
  print(n_configs, flush=True)

Submission status: Wrong Answer

Solution code:
# do a search over the total space of [br, er), [bc, ec)
# compile all cumulative counts of black squares
# record the total number of black squares

def cumul(grid):
  R, C = len(grid), len(grid[0])
  cumu = [[0 for _ in range(R)] for _ in range(C)]
  for r in range(R):
    pr = 0
    for c in range(C):
      nb = 1 if grid[r][c] == '#' else 0
      cr = pr + nb
      cumu[r][c] = cr if r == 0 else cr + cumu[r-1][c]
      pr = cr
  
  return cumu

def ct_black(cu, rb, re, cb, ce):
  # count number of remaining black after painting
  # this intersection
  ul = cu[rb][cb]
  ll = cu[-1][cb] - cu[re-1][cb]
  ur = cu[rb][-1] - cu[rb][ce-1]
  lr = cu[-1][-1] - cu[re-1][-1] - cu[-1][ce-1] + cu[re-1][ce-1]
  return ul + ll + ur + lr

  
  

def main():
  R, C, K = map(int, input().split())
  grid = []
  for r in range(R):
    grid.append(list(input()))
                
  cumu = cumul(grid)

  n_configs = 0
  for rb in range(R):
    for re in range(rb, R):
      for cb in range(C):
        for ce in range(cb, C):
          if ct_black(cumu, rb, re, cb, ce) == K:
            n_configs += 1
  
  
  print(n_configs, flush=True)

Submission status: Wrong Answer

Solution code:
# do a search over the total space of [br, er), [bc, ec)
# compile all cumulative counts of black squares
# record the total number of black squares

def cumul(grid):
  R, C = len(grid), len(grid[0])
  cumu = [[0 for _ in range(R)] for _ in range(C)]
  for r in range(R):
    pr = 0
    for c in range(C):
      nb = 1 if grid[r][c] == '#' else 0
      cr = pr + nb
      cumu[r][c] = cr if r == 0 else cr + cumu[r-1][c]
  
  return cumu

def ct_black(cu, rb, re, cb, ce):
  # count number of remaining black after painting
  # this intersection
  ul = cu[rb][cb]
  ll = cu[-1][cb] - cu[re-1][cb]
  ur = cu[rb][-1] - cu[rb][ce-1]
  lr = cu[-1][-1] - cu[re-1][-1] - cu[-1][ce-1] + cu[re-1][ce-1]
  return ul + ll + ur + lr

  
  

def main():
  R, C, K = map(int, input().split())
  grid = []
  for r in range(R):
    grid.append(list(input()))
                
  cumu = cumul(grid)

  n_configs = 0
  for rb in range(R):
    for re in range(rb, R):
      for cb in range(C):
        for ce in range(cb, C):
          if ct_black(cumu, rb, re, cb, ce) == K:
            n_configs += 1
  
  
  print(n_configs, flush=True)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import copy
import itertools

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

def check(c, k):
  cnt = 0
  for i in range(len(c)):
    cnt += c[i].count('#')
  if cnt == k:
    return True
  else:
    return False

def make_list(c, h, w):
  for h_ in h:
    c[h_] = ['*'] * len(c[h_])
  for w_ in w:
    for i in range(len(c)):
      c[i][w_] = '*'
  return c

if check(c, k):
  cnt = 1
else:
  cnt = 0

for i in range(h):
  h_comb = list(itertools.combinations(range(h), i))
  for j in range(w):
    w_comb = list(itertools.combinations(range(w), j))
    for h_ in h_comb:
      for w_ in w_comb:
        c_ = copy.deepcopy(c)
        c_ = make_list(c_, h_, w_)
        if check(c_, k):
          cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
H, W, K = map(int, input().split())
c = [input() for i in range(H)]
"""                                                                                                                                  
H = 6                                                                                                                                
W = 6                                                                                                                                
K = 3                                                                                                                                
c = ['...#.#',                                                                                                                       
     '...###',                                                                                                                       
     '#.....',                                                                                                                       
     '...#..',                                                                                                                       
     '...###',                                                                                                                       
     '...##.']                                                                                                                       
"""
ret = 0
for i in range(2**H):
    for j in range(2**W):
        num = 0
        mask_h = str(bin(i))[2:].zfill(H)
        mask_w = str(bin(j))[2:].zfill(W)
        for  k in range(H):
            if mask_h[k] == '0': continue
            for l in range(W):
                if mask_w[l] == '0': continue
                if c[k][l] == '#':
                    num += 1
        if num == K:
            ret += 1
        print('num',num)

print (ret)

Submission status: Wrong Answer

Solution code:
h, w, k=map(int, input(). split())
table=[0]*h

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


cnt=0
ans=0

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


print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

lis = np.array(lis)
total_black = np.count_nonzero(lis == "#")
row_black = np.count_nonzero(lis == "#", axis=1)
column_black = np.count_nonzero(lis == "#", axis=0)
ans = 0

if total_black == K:
  ans += 1

ans += np.count_nonzero(row_black == total_black-K)
ans += np.count_nonzero(column_black == total_black-K)

for k in range(H):
  for l in range(k+1, H):
    black = row_black[k] + row_black[l]
    if K == total_black - black:
      ans += 1
      
for m in range(W):
  for n in range(m+1, W):
    black = column_black[m] + column_black[n]
    if K == total_black - black:
      ans += 1

for o in range(H):
  for p in range(W):
    black = row_black[o] + column_black[p] - np.count_nonzero(lis[o][p] == "#")
    if K == total_black - black:
      ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

lis = np.array(lis)
total_black = np.count_nonzero(lis == "#")
row_black = np.count_nonzero(lis == "#", axis=1)
column_black = np.count_nonzero(lis == "#", axis=0)
ans = 0

ans += np.count_nonzero(row_black == total_black-K)
ans += np.count_nonzero(column_black == total_black-K)

for k in range(H):
  for l in range(k+1, H):
    black = row_black[k] + row_black[l]
    if K == total_black - black:
      ans += 1
      
for m in range(W):
  for n in range(m+1, W):
    black = column_black[m] + column_black[n]
    if K == total_black - black:
      ans += 1

for o in range(H):
  for p in range(W):
    black = row_black[o] + column_black[p] - np.count_nonzero(lis[o][p] == "#")
    if K == total_black - black:
      ans += 1
      
print(ans)

Submission status: Wrong Answer

Solution code:
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
H,W,K = map(int,readline().split())
grid = [list(readline().decode().rstrip()) for _ in range(H)]
black_cnt = 0
for i in range(H):
  for j in range(W):
    if grid[i][j] == '#':
      black_cnt += 1
erase_cnt = black_cnt - K
ans = 0
for bit_H in range(1 << H):
    for bit_W in range(1 << W):
        cnt = 0 
        for i in range(H):
            for j in range(W):
                if ((bit_H >> i) & 1) and ((bit_W >> j) & 1) and grid[i][j] == '#':
                    cnt += 1                 
        if erase_cnt == cnt:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy

def kaijo(n):
    if n==0:
        return 1
    if n==1:
        return n
    return n*kaijo(n-1)

def Comb(n,r):
    if n==0:
        return 1
    return kaijo(n)/(kaijo(r)*kaijo(n-r))

H,W,K = map (int,input().split())
bector = []
for i in range(H):
    bec=[]
    bec = list(input())
    bector.append(bec)
count = 0
Q = deepcopy(bector)
for i in range(W+1):
    A = deepcopy(Q)
    if i != 0:
        for j in range(H):
            for iA in range(i):
                A[j][iA] = "+"
    #これでi列分すべて赤になる

    for k in range(H+1):
        B = deepcopy(A)
        if k != 0:
            x=list("+"*W)
            for l in range(k):
                B[l]=x
        C = [num for alist in B for num in alist]

        #これでk行分すべて赤になる
        if C.count("#") == K:
            count += Comb(H,k)*Comb(W,i)
    A = deepcopy(Q)
print(int(count))

Submission status: Wrong Answer

Solution code:
from copy import deepcopy

def kaijo(n):
    if n==0:
        return 1
    if n==1:
        return n
    return n*kaijo(n-1)

def Comb(n,r):
    if n==0:
        return 1
    return kaijo(n)/(kaijo(r)*kaijo(n-r))

H,W,K = map (int,input().split())
bector = []
for i in range(H):
    bec=[]
    bec = list(input())
    bector.append(bec)
count = 0
Q = deepcopy(bector)
for i in range(W+1):
    A = deepcopy(Q)
    if i != 0:
        for j in range(H):
            for iA in range(i):
                A[j][iA] = "+"
    #これでi列分すべて赤になる

    for k in range(H+1):
        B = deepcopy(A)
        if k != 0:
            x=list("+"*W)
            for l in range(k):
                B[l]=x
        C = [num for alist in B for num in alist]

        #これでk行分すべて赤になる
        if C.count("#") == K:
            count += Comb(H,k)*Comb(W,i)
    A = deepcopy(Q)
print(count)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy

def kaijo(n):
    if n==0:
        return 1
    if n==1:
        return n
    return n*kaijo(n-1)

def Comb(n,r):
    if n==0:
        return 1
    return kaijo(n)/(kaijo(r)*kaijo(n-r))

H,W,K = map (int,input().split())
bector = []
for i in range(H):
    bec=[]
    bec = list(input())
    bector.append(bec)
count = 0
Q = deepcopy(bector)
for i in range(W+1):
    A = deepcopy(Q)
    if i != 0:
        for j in range(H):
            for iA in range(i):
                A[j][iA] = "+"
    #これでi列分すべて赤になる

    for k in range(H+1):
        B = deepcopy(A)
        if k != 0:
            x=list("+"*W)
            for l in range(k):
                B[l]=x
        C = [num for alist in B for num in alist]
        print(C)
        print(C.count("#"))
        #これでk行分すべて赤になる
        if C.count("#") == K:
            count += Comb(H,k)*Comb(W,i)
    A = deepcopy(Q)
print(count)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

for h in range(1 << H):
    for w in range(1 << W):
        black = 0
        for i in range(H):
            if (h >> i) % 2 == 1:
                continue
            for j in range(W):
                if (w >> j) % 2 == 1:
                    continue
                if table[i][j] == '#':
                    black += 1
            if black == K:
                ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from itertools import combinations
import numpy as np

rm = lambda: map(int, sys.stdin.readline().split())
rr = lambda: sys.stdin.readline().rstrip()

h, w, k = rm()
li = np.array([np.array(list(rr())) for _ in range(h)])
cnt = 0

for i in range(h+1):
    for a in np.array(list(combinations(li, i))):
        a = a.T
        for j in range(w+1):
            for b in np.array(list(combinations(a, j))):
                t = np.count_nonzero(b == '#')
                print(b)
                if t == k:
                    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
h, w, k = map(int, input().split())
chw = [input() for _ in range(h)]
  
answer = 0
for col in range(2**h):
  for row in range(2**w):
    black = 0
    for i in range(h):
      for j in range(w):
        print(col,col >> i)
        print(row,row >> j)
        if ((col >> i) & 1) and ((row >> j) & 1) and (chw[i][j] == "#"):
          black = black +1

    if black == k:
      answer += 1
print(chw)
print(answer)

Submission status: Wrong Answer

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

counter = 0	
ans = 0
b = 0
for (i,j) in itertools.product(range(h), range(w)):
	if c[i][j] == '#':
		b += 1
if b == k:
	ans += 1
C = c
for hl in range(1,h+1):
	for wl in range(1,w+1):
		for	hi in itertools.combinations(range(h),hl):
			for wj in itertools.combinations(range(w),wl):
				print(wj)
				for i in hi:
					for j in range(w):
						if c[i][j] == '#':
							counter += 1
							c[i][j] == '.'
				for j in wj:
					for i in range(h):
						if c[i][j] == '#':
							counter += 1
				if b - counter == k:
					ans += 1
				counter = 0
				c = C
print(ans)
for hl in range(1,h+1):
	for	hi in itertools.combinations(range(h),hl):
			for i in hi:
				for j in range(w):
					if c[i][j] == '#':
						counter += 1
			if b - counter == k:
				ans += 1
			counter = 0
print(ans)
for wl in range(1,w+1):
	for	wj in itertools.combinations(range(w),wl):
			for j in wj:
				for i in range(h):
					if c[i][j] == '#':
						counter += 1
			if b - counter == k:
				ans += 1
			counter = 0
print(ans)

Submission status: Wrong Answer

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

lit = []
for i in range(2 ** H):
    for j in range(2 ** W):
        row = str(bin(i))[2:].zfill(H)
        col = str(bin(j))[2:].zfill(W)
        lit.append([row, col])
print(len(lit))
# print(lit)

black = sum([c.count('#') for c in C])
# print(black)

# 000011 000111 4 6 8 NG
res = 0
for row, col in lit:
# for row, col in [['000011', '000111']]:
    ans = black
    black_row = 0
    black_col = 0
    for i, r in enumerate(row):
        if r == '1':
            ans -= C[i].count('#')
            black_row += C[i].count('#')
        # print(ans)

    for j, c in enumerate(col):
        if c == '1':
            for k in range(H):
                if row[k] == '1':
                    continue
                if C[k][j] == '#':
                    ans -= 1
                    black_col += 1
    # print(row, col, black_row, black_col, ans)
    if ans == K:
        res += 1

print(res)

Submission status: Wrong Answer

Solution code:
import itertools
c = 0
h,w,k = map(int, input().split())
g = []
for _ in range(h):
  i = input()
  g.append(i)
  c+=i.count('#')
ans = 0
for i in list(itertools.product([0,1], repeat=h)):
  for j in list(itertools.product([0,1], repeat=w)):
    e = c
    for x in range(h):
      for y in range(w):
        if i[x] == 1 and j[y] == 1 and g[x][y]=='#':
          e-=1
    if e==k:
      ans+=1
print(ans)

Submission status: Wrong Answer

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

counter = 0	
ans = 0
b = 0
for (i,j) in itertools.product(range(h), range(w)):
	if c[i][j] == '#':
		b += 1
if b == k:
	ans += 1
C = c
for hl in range(1,h+1):
	for wl in range(1,w+1):
		for	hi in itertools.combinations(range(h),hl):
			for wj in itertools.combinations(range(w),wl):
				for i in hi:
					for j in range(w):
						if c[i][j] == '#':
							counter += 1
							c[i][j] == '.'
				for j in wj:
					for i in range(h):
						if c[i][j] == '#':
							counter += 1
				if b - counter == k:
					ans += 1
				counter = 0
				c = C
for hl in range(1,h+1):
	for	hi in itertools.combinations(range(h),hl):
			for i in hi:
				for j in range(w):
					if c[i][j] == '#':
						counter += 1
			if b - counter == k:
				ans += 1
			counter = 0

for wl in range(1,w+1):
	for	wj in itertools.combinations(range(w),wl):
			for j in wj:
				for i in range(h):
					if c[i][j] == '#':
						counter += 1
			if b - counter == k:
				ans += 1
			counter = 0
print(ans)

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

Solution code:
import itertools
import copy

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

if list(itertools.chain.from_iterable(cl)).count('#') == K:
    print(1)
    exit()

rows = []
for i in range(H):
    for v in itertools.combinations(range(H),i):
        rows.append(v)

columns = []
for i in range(W):
    for v in itertools.combinations(range(W),i):
        columns.append(v)

ans = 0
tmp_cl = copy.deepcopy(cl)
for i in range(len(rows)):
    for j in range(len(columns)):
        row = rows[i]
        column = columns[j]
        for a in range(len(row)):
            for b in range(W):
                tmp_cl[row[a]][b] = '.'
        for c in range(H):
            for d in range(len(column)):
                tmp_cl[c][column[d]] = '.'

        if list(itertools.chain.from_iterable(tmp_cl)).count('#') == K:
            ans += 1
        tmp_cl = copy.deepcopy(cl)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
'''
K = 2
H, W = 5, 5
a = np.array([
	[0, 0, 0, 0, 1],
	[0, 0, 0, 1, 1],
	[0, 0, 1, 1, 1],
	[0, 1, 1, 1, 1],
	[1, 1, 1, 1, 1]
])
'''

def conv(c):
	return int(c=='#')
H, W, K = map(int, input().split())
a = np.array([list(map(conv, input().split())) for _ in range(H)])
count = 0
for i in range(2 ** H):
	b = np.delete(a.copy(), [j for j in range(H) if ((i >> j) & 1)], 0)
	blen = b.shape[1]
	for i in range(2 ** W):
		c = np.delete(b, [j for j in range(blen) if ((i >> j) & 1)], 1)
		#print(np.sum(c))
		if K==np.sum(c):
			count += 1
print(count)
print()

Submission status: Wrong Answer

Solution code:
h,w,k = map(int, input().split())
g = []
for i in range(h):
  g.append(list(input())+["."])
g.append(["."]*(w+1))
ans = 0
F = g
for H in range(h+1):
  for W in range(w+1):
    G = F
    print(G)
    n = 0
    G[H] = ["r"]*(w+1)
    for i in range(h+1):
      G[i][W] = "r"
    for i in range(h):
      n += G[i].count("#")
    if n == k:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
'''
K = 2
H, W = 5, 5
a = np.array([
	[0, 0, 0, 0, 1],
	[0, 0, 0, 1, 1],
	[0, 0, 1, 1, 1],
	[0, 1, 1, 1, 1],
	[1, 1, 1, 1, 1]
])
'''

def conv(c):
	return int(c=='#')
H, W, K = map(int, input().split())
a = np.array([list(map(conv, input().split())) for _ in range(H)])
count = 0
for i in range(2 ** H - 1):
	b = np.delete(a.copy(), [j for j in range(H) if ((i >> j) & 1)], 0)
	blen = b.shape[1]
	for i in range(2 ** W - 1):
		c = np.delete(b, [j for j in range(blen) if ((i >> j) & 1)], 1)
		#print(np.sum(c))
		if K==np.sum(c):
			count += 1
print(count)
print()

Submission status: Wrong Answer

Solution code:
import numpy as np
'''
K = 2
H, W = 5, 5
a = np.array([
	[0, 0, 0, 0, 1],
	[0, 0, 0, 1, 1],
	[0, 0, 1, 1, 1],
	[0, 1, 1, 1, 1],
	[1, 1, 1, 1, 1]
])
'''

def conv(c):
	return int(c=='#')
H, W, K = map(int, input().split())
a = np.array([list(map(conv, input().split())) for _ in range(H)])
count = 0
for i in range(2 ** H - 1):
	b = np.delete(a.copy(), [j for j in range(H) if ((i >> j) & 1)], 0)
	for i in range(2 ** W - 1):
		c = np.delete(b, [j for j in range(b.shape[1]) if ((i >> j) & 1)], 1)
		#print(np.sum(c))
		if K==np.sum(c):
			count += 1
print(count)
print()

Submission status: Wrong Answer

Solution code:
h,w,k = list(map(int,input().split()))
b=[]
c=0
for i in range(h):
	b.append(list(input()))
	for j in range(w):
		if b[i][j]=='#':
			b[i][j]=1
		else: b[i][j]=0	
black=0
for i in b:
	for j in i:
		if j==1:
			black+=1
def recurse(bl,o):
	global c
	if bl==k:
		c+=1
		return
	if bl<k:
		return
	for i in range(o,h):
		b1=bl
		r=list(b[i])
		for j in range(w):
			if b[i][j]:
				b1-=1
				b[i][j]=0
		recurse(b1,i+1)
		b[i]=r.copy()
	for i in range(max(o-h,0),w):
		r=list(b[j][i] for j in range(0,h))
		b1=bl
		for j in range(h):
			if b[j][i]:
				b1-=1
				b[j][i]=0
		recurse(b1,i+h+1)
		for j in range(h):
			b[j][i]=r[j]
recurse(black,0)
print(c)

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)]
clist = list(itertools.product([0, 1], repeat=H+W))
        
ans = 0
for q in clist:
  black = 0
  h = q[:H]
  w = q[H:]
  for i in range(H):
    for j in range(W):
      if h[i] == w[j] == 0 and C[i][j] == '#':
        black += 1
  if black == K:
    ans += 1
    print(q)

print(ans)

Submission status: Wrong Answer

Solution code:
h,v,k = map(int,input().split())
ini_state = [list(input()) for i in range(h)] 
state = ini_state
total = 0

for r in range(h):
  for c in range(v):
    count = 0
    nr, nc = r, c
    for i in range(h):
        for j in range(v):
            if nr != i and nc != j:
                if state[i][j] == "#":
                    count += 1
    if count == k:
      total += 1
      
for r in range(h):
    for nr in range(h):
        if r != nr:
            init = "".join(state[nr])
            if init.count("#") == k:
                total += 1
       
for r in range(h):
    newstate = []
    for c in range(v):
        for nc in range(v):
            if c != nc:
                newstate.append(state[r][c])
                init = "".join(newstate)
                if init.count("#") == k:
                    total += 1               
    
print(total)

Submission status: Wrong Answer

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

c = list(input() for i in range(h))

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


#いじってもいいやつを設定する
import copy
c_copy = copy.deepcopy(c)

#行の操作(h)
g = []
for i in range(2 ** h) :
    gyou = ["0"] * h
    for j in range(h):
        if ((i >> j) & 1):
            gyou[j] = "1"
    g.append(gyou)
#列の操作(w)
r = []
for p in range(2 ** w):
    retsu = ["0"] * w
    for q in range(w):
        if ((p >> q) & 1):
            retsu[q] = "1"
    r.append(retsu)

#行列を"."にする
def aka(a,b):
    #行を.にする
    for i in range(h) :
        if g[a][i] == "1" :
            for k in range(w) :
                c_copy[i][k] = "."
    #列を.にする
    for j in range(w) :
        if r[b][j] == "1" :
            for l in range(h) :
                c_copy[l][j] = "."
    return c_copy

import itertools

ans = 0
for a in range(2**h):
    for b in range(2**w):
        l = list(itertools.chain.from_iterable(aka(a,b)))
        if l.count('#') == 2 :
            ans += 1
        c_copy = copy.deepcopy(c)

print(ans)