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的棋盘, ...
随机推荐
- Mysql 正则表达式 判断字段值不包含数字
SELECT * FROM (select replace(FlightId_IaTa,LEFT(FlightId_IaTa,2),'') as aa,FlightId_IaTa,FlightIdfr ...
- JavaScript基础(简介、语法)
一.JavaScript简介 1.JavaScript是个什么东西? 它是个脚本语言,需要有宿主文件,它的宿主文件是HTML文件. 2.它与Java什么关系? 没有什么直接的联系,Java是Sun公司 ...
- WINFORM Tootip使用小结
toolTip1.Active = true; //激活工具提示,只有激活才会显示提示 toolTip1.IsBalloon = true; //toolTip以气泡形式出现 toolTip ...
- BZOJ 1497: [NOI2006]最大获利( 最大流 )
下午到周六早上是期末考试...但是我还是坚守在机房....要挂的节奏啊.... 这道题就是网络流 , 建图后就最大流跑啊跑啊跑... --------------------------------- ...
- MySQL 事物
BEGIN DECLARE result INTEGER DEFAULT 0; -- 标记是否出错 DECLARE t_error INTEGER DEFAULT 0; -- 如果出现sql异常,则将 ...
- cocos2d-x Android环境搭建
1.Java虚拟机.分32位和64位.64位: jdk-8u11-windows-x64-8.0.11.12.1406275777 环境变量配置,我的电脑右击->属性->高级系统设置-&g ...
- QT不让windows休眠的方法
对于一些Windows应用程序,必须要保证os不能休眠才能有效工作,如迅雷下载软件,如果os进入休眠,则会导致网络不正常,从而导致不能下载东西.那木有没有1种机制,当打开软件的时候,就自动将os设为不 ...
- 【Java线程】Lock、Condition
http://www.infoq.com/cn/articles/java-memory-model-5 深入理解Java内存模型(五)——锁 http://www.ibm.com/develope ...
- 【剑指Offer学习】【面试题36:数组中的逆序对】
题目:在数组中的两个数字假设前面一个数字大于后面的数字.则这两个数字组成一个逆序对.输入一个数组.求出这个数组中的逆序对的总数. 举例分析 比如在数组{7, 5, 6, 4 中, 一共存在5 个逆序对 ...
- IOS_OC_id ,NSObject, id<NSObject>差别
我们常常会混淆下面三种申明(我是没有留意过): 1. id foo1; 2. NSObject *foo2; 3. id<NSObject> foo3; 第 ...