博客
关于我
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/

你可能感兴趣的文章
Metasploit Web服务器渗透测试实战
查看>>
MFC模态对话框和非模态对话框
查看>>
Moment.js常见用法总结
查看>>
MongoDB出现Error parsing command line: unrecognised option ‘--fork‘ 的解决方法
查看>>
mxGraph改变图形大小重置overlay位置
查看>>
MongoDB可视化客户端管理工具之NoSQLbooster4mongo
查看>>
Mongodb学习总结(1)——常用NoSql数据库比较
查看>>
MongoDB学习笔记(8)--索引及优化索引
查看>>
mongodb定时备份数据库
查看>>
mppt算法详解-ChatGPT4o作答
查看>>
mpvue的使用(一)必要的开发环境
查看>>
MQ 重复消费如何解决?
查看>>
mqtt broker服务端
查看>>
MQTT 保留消息
查看>>
MQTT 持久会话与 Clean Session 详解
查看>>
MQTT工作笔记0007---剩余长度
查看>>
MQTT工作笔记0009---订阅主题和订阅确认
查看>>
Mqtt搭建代理服务器进行通信-浅析
查看>>
MS Edge浏览器“STATUS_INVALID_IMAGE_HASH“兼容性问题
查看>>
ms sql server 2008 sp2更新异常
查看>>