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

你可能感兴趣的文章
mqtt broker服务端
查看>>
MQTT 保留消息
查看>>
MQTT 持久会话与 Clean Session 详解
查看>>
MQTT介绍及与其他协议的比较
查看>>
MQTT工作笔记0007---剩余长度
查看>>
MQTT工作笔记0008---服务质量
查看>>
MQTT工作笔记0009---订阅主题和订阅确认
查看>>
Mqtt搭建代理服务器进行通信-浅析
查看>>
MS COCO数据集介绍
查看>>
MS Edge浏览器“STATUS_INVALID_IMAGE_HASH“兼容性问题
查看>>
ms sql server 2008 sp2更新异常
查看>>
MS SQL查询库、表、列数据结构信息汇总
查看>>
MS UC 2013-0-Prepare Tool
查看>>
MSBuild 教程(2)
查看>>
msbuild发布web应用程序
查看>>
MSB与LSB
查看>>
MSCRM调用外部JS文件
查看>>
MSCRM调用外部JS文件
查看>>
MSEdgeDriver (Chromium) 不适用于版本 >= 79.0.313 (Canary)
查看>>
MsEdgeTTS开源项目使用教程
查看>>