博客
关于我
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 /*! 50100 ... */ 条件编译
查看>>
mudbox卸载/完美解决安装失败/如何彻底卸载清除干净mudbox各种残留注册表和文件的方法...
查看>>
mysql 1264_关于mysql 出现 1264 Out of range value for column 错误的解决办法
查看>>
mysql 1593_Linux高可用(HA)之MySQL主从复制中出现1593错误码的低级错误
查看>>
mysql 5.6 修改端口_mysql5.6.24怎么修改端口号
查看>>
MySQL 8.0 恢复孤立文件每表ibd文件
查看>>
MySQL 8.0开始Group by不再排序
查看>>
mysql ansi nulls_SET ANSI_NULLS ON SET QUOTED_IDENTIFIER ON 什么意思
查看>>
multi swiper bug solution
查看>>
MySQL Binlog 日志监听与 Spring 集成实战
查看>>
MySQL binlog三种模式
查看>>
multi-angle cosine and sines
查看>>
Mysql Can't connect to MySQL server
查看>>
mysql case when 乱码_Mysql CASE WHEN 用法
查看>>
Multicast1
查看>>
mysql client library_MySQL数据库之zabbix3.x安装出现“configure: error: Not found mysqlclient library”的解决办法...
查看>>
MySQL Cluster 7.0.36 发布
查看>>
Multimodal Unsupervised Image-to-Image Translation多通道无监督图像翻译
查看>>
MySQL Cluster与MGR集群实战
查看>>
multipart/form-data与application/octet-stream的区别、application/x-www-form-urlencoded
查看>>