HNU13028Attacking rooks (二分匹配,一行变多行,一列变多列)
| Attacking rooks |
| Time Limit: 20000ms, Special Time Limit:50000ms, Memory Limit:65536KB |
| Total submit users: 12, Accepted users: 7 |
| Problem 13028 : No special judgement |
| Problem description |
| Chess inspired problems are a common source of exercises in algorithms classes. Starting with the well known 8-queens problem, several generalizations and variations were made. One of them is the N-rooks problem, which consists of placing N rooks in an N by N chessboard in such a way that they do not attack each other. Professor Anand presented the N-rooks problem to his students. Since rooks only attack each other when they share a row or column, they soon discovered that the problem can be easily solved by placing the rooks along a main diagonal of the board. So, the professor decided to complicate the problem by adding some pawns to the board. In a board with pawns, two rooks attack each other if and only if they share a row or column and there is no pawn placed between them. Besides, pawns occupy some squares, which gives an additional restriction on which squares the rooks may be placed on. Given the size of the board and the location of the pawns, tell Professor Anand the maximum number of rooks that can be placed on empty squares such that no two of them attack each other. |
| Input |
| The first line contains an integer N (1 ≤ N ≤ 100) representing the number of rows and columns of the board. Each of the next N lines contains a string of N characters. In the i-th of these strings, the j-th character represents the square in the i-th row and j-th column of the board. The character is either "." (dot) or the uppercase letter "X", indicating respectively an empty square or a square containing a pawn. |
| Output |
| Output a line with an integer representing the maximum number of rooks that can be placed on the empty squares of the board without attacking each other. |
| Sample Input |
Sample input 1 |
| Sample Output |
Sample output 1 |
| Problem Source |
ICPC Latin American Regional 2013
#include<stdio.h> |
HNU13028Attacking rooks (二分匹配,一行变多行,一列变多列)的更多相关文章
- UVALive 6525 Attacking rooks 二分匹配 经典题
题目链接:option=com_onlinejudge&Itemid=8&page=show_problem&problem=4536">点击打开链接 题意: ...
- hive一行变多行及多行变一行
hive一行变多行及多行变一行 场景 name alias zhaoqiansun abc def ghi 处理数据时需要将上表处理成为下面的形式: name alias zhaoqiansun ab ...
- ASP.NET_正则表达式_匹配HTML中的一行或多行
一.匹配数字串/flash/([0-9]+).htm 二.匹配不含双引号的字符串<p class=\"w490\">([^\"]+)</p> 三. ...
- pandas dataframe 一行变多行 (query pv统计term pv)
关键字: 用jieba切词 用expand 一列变多列 用stack 列转行 用group by + aggr 相同term的pv求和 上效果: query pv 今日新鲜事 今日头条 北京天气 上海 ...
- [kuangbin带你飞]专题十 匹配问题 二分匹配部分
刚回到家 开了二分匹配专题 手握xyl模板 奋力写写写 终于写完了一群模板题 A hdu1045 对这个图进行 行列的重写 给每个位置赋予新的行列 使不能相互打到的位置 拥有不同的行与列 然后左行右列 ...
- [ACM_图论] The Perfect Stall 完美的牛栏(匈牙利算法、最大二分匹配)
描述 农夫约翰上个星期刚刚建好了他的新牛棚,他使用了最新的挤奶技术.不幸的是,由于工程问题,每个牛栏都不一样.第一个星期,农夫约翰随便地让奶牛们进入牛栏,但是问题很快地显露出来:每头奶牛都只愿意在她们 ...
- BZOJ 1191: [HNOI2006]超级英雄Hero 二分匹配
1191: [HNOI2006]超级英雄Hero Description 现在电视台有一种节目叫做超级英雄,大概的流程就是每位选手到台上回答主持人的几个问题,然后根据回答问题的多少获得不同数目的奖品或 ...
- 【HDU 2255】奔小康赚大钱 (最佳二分匹配KM算法)
奔小康赚大钱 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Subm ...
- hdu 1281棋盘游戏(二分匹配)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1281 Problem Description 小希和Gardon在玩一个游戏:对一个N*M的棋盘, ...
随机推荐
- 虎扯:小众玩物 webkit家的滚动条
前面的话:对只有一种浏览器支持的属性,就不要出来秀咱前端同学,就像是早些年手机们的充电口一样,集各家所长,咱今天说的是webkit的滚动条样式,视乎只有webkit支持此项定义,有见识的前辈来辩.这玩 ...
- Jquery 遍历数组之$().each方法与$.each()方法介绍
$().each() 对于这个方法,在dom处理上用的比较多,如果一个html页面上面有多个checkbox,这时用$().each来处理checkbox是比较不错的; $("input[t ...
- Ubuntu在ARM上建立NFS服务
先引用别人的做法: 1.进行NFS服务器端与客户端的安装: sudo apt-get install nfs-kernel-server nfs-common portmap 安装客户端的作用是可以在 ...
- MVC-07 案例1
>>>>>ContosoUniversity网站 ------------------------------------------- 一.并发冲突 1. 为什么会并发 ...
- 【图文教程】用“iz3d”软件将您的游戏打造为红蓝3D游戏。
iz3d是一款能将普通3D游戏转换为红蓝3D游戏的软件.基本上支持所有游戏,或许没用过的人会认为这只是类似于播放器中的一个小功能,将平面图形做成“伪3D”红蓝效果. 实际上不是的,游戏与平面图的结构不 ...
- Qt实现16进制unicode转utf-8以及国际音标编码问题
由于项目需要,需要对网络资源进行解码.遇到编码问题.研究了下基本编码原理.于是有了下面两个通用代码 1. 16进制unicode转换为utf-8中文显示 QString unicodeToUtf_8( ...
- 【源码】实现Android闹钟功能使用HTML+JS,并附带Alarm代码分享
先是开发手册中最终功能的实现函数,再是Alarm接口的源码. 参数: argu:型如“key1=value1;key2=value2;......”的参数表.首先,该参数表支持 rexseeNotif ...
- Node.cluster
nodejs是一个单进程单线程的引擎,只能利用到单个cpu进行计算,面对当今服务器性能的提高,cpu的利用率显然对node应有的性能大打折扣,面对这个问题,cluster应运而生. cluster介绍 ...
- hdu1395-2^x mod n = 1
http://acm.hdu.edu.cn/showproblem.php?pid=1395 原理为 a ^ b % n == d ; >>>>>> (( a % ...
- php单元測试
你是否在程序开发的过程中遇到下面的情况:当你花了非常长的时间开发一个应用后,你觉得应该是大功告成了,可惜在调试的时候,老是不断的发现bug,并且最可怕的是,这些bug是反复出现的,你可能发现这些bug ...