博客
关于我
AtCoder Beginner Contest 173 English C - H and V 二进制枚举
阅读量:146 次
发布时间:2019-02-28

本文共 1253 字,大约阅读时间需要 4 分钟。

题目链接:

因为我不会而且还是看了队友的代码才明白有二进制有这种所以发个文章记录一下错题

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≤i≤H,1≤j≤W) is given to you as a character ci,j: the square is white if ci, is., and black if ci,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≤H,W≤6

1≤K≤HW
ci,j is . or #.

题意:

在h*w的矩阵中含有‘.’和‘#’分别代表白色和黑色格子,现在你可以选择某一行或者某一列让格子变成红色,求有多少种可能使得染成红色后,还恰好剩下k个黑色格子。

题解:

for(int i=0;i<(1<<h);i++)

for(int j=0;j<(1<<w);j++)
二进制每次+1就可以暴力遍历每种情况出现的可能性

#include
using namespace std;#define ll long long#define endl "\n"int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n,m,k; cin>>n>>m>>k; int ans=0; bool ar[n][m]; for(int i=0;i
>x; ar[i][j]= x == '#'; } for(int i=0;i<(1<

转载地址:http://hdld.baihongyu.com/

你可能感兴趣的文章
MySQL 日期时间类型的选择
查看>>
Mysql 时间操作(当天,昨天,7天,30天,半年,全年,季度)
查看>>
MySQL 是如何加锁的?
查看>>
MySQL 是怎样运行的 - InnoDB数据页结构
查看>>
mysql 更新子表_mysql 在update中实现子查询的方式
查看>>
MySQL 有什么优点?
查看>>
mysql 权限整理记录
查看>>
mysql 权限登录问题:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
查看>>
MYSQL 查看最大连接数和修改最大连接数
查看>>
MySQL 查看有哪些表
查看>>
mysql 查看锁_阿里/美团/字节面试官必问的Mysql锁机制,你真的明白吗
查看>>
MySql 查询以逗号分隔的字符串的方法(正则)
查看>>
MySQL 查询优化:提速查询效率的13大秘籍(避免使用SELECT 、分页查询的优化、合理使用连接、子查询的优化)(上)
查看>>
mysql 查询数据库所有表的字段信息
查看>>
【Java基础】什么是面向对象?
查看>>
mysql 查询,正数降序排序,负数升序排序
查看>>
MySQL 树形结构 根据指定节点 获取其下属的所有子节点(包含路径上的枝干节点和叶子节点)...
查看>>
mysql 死锁 Deadlock found when trying to get lock; try restarting transaction
查看>>
mysql 死锁(先delete 后insert)日志分析
查看>>
MySQL 死锁了,怎么办?
查看>>