POJ 1719 Shooting Contest
来源:互联网 发布:隔壁老王淘宝 编辑:程序博客网 时间:2024/05/18 11:49
Shooting Contest
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 2279 Accepted: 809 Special Judge
Description
Welcome to the Annual Byteland Shooting Contest. Each competitor will shoot to a target which is a rectangular grid. The target consists of r*c squares located in r rows and c columns. The squares are coloured white or black. There are exactly two white squares and r-2 black squares in each column. Rows are consecutively labelled 1,..,r from top to bottom and columns are labelled 1,..,c from left to right. The shooter has c shots.
A volley of c shots is correct if exactly one white square is hit in each column and there is no row without white square being hit. Help the shooter to find a correct volley of hits if such a volley exists.
Example
Consider the following target:
Volley of hits at white squares in rows 2, 3, 1, 4 in consecutive columns 1, 2, 3, 4 is correct.
Write a program that: verifies whether any correct volley of hits exists and if so, finds one of them.
A volley of c shots is correct if exactly one white square is hit in each column and there is no row without white square being hit. Help the shooter to find a correct volley of hits if such a volley exists.
Example
Consider the following target:
Volley of hits at white squares in rows 2, 3, 1, 4 in consecutive columns 1, 2, 3, 4 is correct.
Write a program that: verifies whether any correct volley of hits exists and if so, finds one of them.
Input
The first line of the input contains the number of data blocks x, 1 <= x <= 5. The following lines constitute x blocks. The first block starts in the second line of the input file; each next block starts directly after the previous one.
The first line of each block contains two integers r and c separated by a single space, 2 <= r <= c <= 1000. These are the numbers of rows and columns, respectively. Each of the next c lines in the block contains two integers separated by a single space. The integers in the input line i + 1 in the block, 1 <= i <= c, are labels of rows with white squares in the i-th column.
The first line of each block contains two integers r and c separated by a single space, 2 <= r <= c <= 1000. These are the numbers of rows and columns, respectively. Each of the next c lines in the block contains two integers separated by a single space. The integers in the input line i + 1 in the block, 1 <= i <= c, are labels of rows with white squares in the i-th column.
Output
For the i-th block, 1 <= i <= x, your program should write to the i-th line of the standard output either a sequence of c row labels (separated by single spaces) forming a correct volley of hits at white squares in consecutive columns 1, 2, ..., c, or one word NO if such a volley does not exists.
Sample Input
24 42 43 41 31 45 51 52 43 42 42 3
Sample Output
2 3 1 4NO
Source
CEOI 1997
- POJ 1719 Shooting Contest
- poj 1719 Shooting Contest
- poj 1719 Shooting Contest
- poj 1719Shooting Contest
- poj 1719 Shooting Contest
- poj 1719 Shooting Contest 二分匹配
- [二分匹配]poj 1719 Shooting Contest
- POJ 1719 Shooting Contest 二分匹配
- POJ 1719 Shooting Contest 二分匹配
- poj 1719 Shooting Contest 二分匹配 匈牙利
- POJ 1719 Shooting Contest(KM,4级)
- POJ 1719 Shooting Contest 二分图最大匹配
- POJ 1719 Shooting Contest(二分图匹配)
- POJ题目1719 Shooting Contest(二分图)
- POJ - 1719 Shooting Contest 二分图最大匹配
- Shooting Contest(POJ-1719)(二分最大匹配)
- POJ 1719 Shooting Contests
- POJ--1719[Shooting Contest] 有源汇上下界可行流或二分匹配
- 项目所遇到的一些管理问题解决方法
- POJ1003
- 好生意一年历程(8/10)
- 马云送给正在奋斗的人的经典语句
- WIN7 VS2005+sp1 无法调试代码了!
- POJ 1719 Shooting Contest
- Asp.net网页播放视频
- SMTP、ESMTP、POP3发送接收邮件
- java Properties的读,写操作
- 第二天:集成spring
- 学好java思想的王道
- Ubuntu无线共享上网
- Linux下查看系统信息的常用命令
- 在C#中利用ActiveX控件进行视频采集