sdut 2158:Hello World!(第一届山东省省赛原题,水题,穷举)
Hello World!
Time Limit: 1000MS Memory limit: 65536K
题目描述
“We need a programmer to help us for some projects. If you show us that you or one of your friends is able to program, you can pass the first hurdle.
I will give you a problem to solve. Since this is the first hurdle, it is very simple.”
We all know that the simplest program is the “Hello World!” program. This is a problem just as simple as the “Hello World!”
In a large matrix, there are some elements has been marked. For every marked element, return a marked element whose row and column are larger than the showed element’s row and column respectively. If there are multiple solutions, return the element whose row is the smallest; and if there are still multiple solutions, return the element whose column is the smallest. If there is no solution, return -1 -1.
Saya is not a programmer, so she comes to you for help
Can you solve this problem for her?
输入
The first line of input in each test case contains one integer N (0<N≤1000), which represents the number of marked element.
Each of the next N lines containing two integers r and c, represent the element’s row and column. You can assume that 0<r, c≤300. A marked element can be repeatedly showed.
The last case is followed by a line containing one zero.
输出
示例输入
3
1 2
2 3
2 3 0
示例输出
Case 1:
2 3
-1 -1
-1 -1
提示
来源
简单题,穷举即可。
代码:
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
int n;
int Count =;
while(cin>>n){
if(n==) break;
int a[][]={};
int r[]={};
int c[]={};
int MaxR=,MaxC=;
for(int i=;i<=n;i++){
cin>>r[i]>>c[i];
a[r[i]][c[i]] = ;
if(r[i]>MaxR)
MaxR = r[i];
if(c[i]>MaxC)
MaxC = c[i];
}
cout<<"Case "<<Count++<<':'<<endl;
for(int i=;i<=n;i++){
int R = r[i],C = c[i];
int j,k;
if(R+>MaxR || C+>MaxC){
cout<<-<<' '<<-<<endl;
continue;
}
for(j=R+;j<=MaxR;j++)
for(k=C+;k<=MaxC;k++)
if(a[j][k]==)
goto label;
label:
if(j>MaxR && k>MaxC)
cout<<-<<' '<<-<<endl;
else
cout<<j<<' '<<k<<endl;
}
cout<<endl;
}
return ;
}
Freecode : www.cnblogs.com/yym2013
sdut 2158:Hello World!(第一届山东省省赛原题,水题,穷举)的更多相关文章
- sdut 2154:Shopping(第一届山东省省赛原题,水题)
Shopping Time Limit: 1000MS Memory limit: 65536K 题目描述 Saya and Kudo go shopping together.You can ass ...
- sdut 2152:Balloons(第一届山东省省赛原题,DFS搜索)
Balloons Time Limit: 1000MS Memory limit: 65536K 题目描述 Both Saya and Kudo like balloons. One day, the ...
- sdut 2153:Clockwise(第一届山东省省赛原题,计算几何+DP)
Clockwise Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Saya have a long necklace with ...
- sdut 2163:Identifiers(第二届山东省省赛原题,水题)
Identifiers Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Identifier is an important c ...
- sdut 2159:Ivan comes again!(第一届山东省省赛原题,STL之set使用)
Ivan comes again! Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 The Fairy Ivan gave Say ...
- sdut 2162:The Android University ACM Team Selection Contest(第二届山东省省赛原题,模拟题)
The Android University ACM Team Selection Contest Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里 ...
- sdut 2165:Crack Mathmen(第二届山东省省赛原题,数论)
Crack Mathmen Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Since mathmen take securit ...
- sdut 2610:Boring Counting(第四届山东省省赛原题,划分树 + 二分)
Boring Counting Time Limit: 3000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 In this problem you a ...
- sdut 2411:Pixel density(第三届山东省省赛原题,字符串处理)
Pixel density Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Pixels per inch (PPI) or pi ...
随机推荐
- 【UNIX网络编程】FIFO
管道作为进程间通信的最古老方式,它的缺点是没有名字,因此仅仅能用在有亲缘关系的父子进程之间.对于无亲缘关系的进程间.无法用管道进行通信.FIFO能够完毕无亲缘关系的进程间的通信.FIFO也被称为命名管 ...
- jquery uploadify文件上传插件用法精析
jquery uploadify文件上传插件用法精析 CreationTime--2018年8月2日11点12分 Author:Marydon 一.参数说明 1.参数设置 $("#fil ...
- windows 磁盘加密
windows 磁盘加密 CreateTime--2018年4月25日18:37:45 Author:Marydon 以win10为例 选中磁盘-->你会发现上面的管理BitLocker是置 ...
- js&jquery避免报错的方法
CreateTime--2016年12月8日15:28:40Author:Marydonjs&jquery规避报错信息的两种方式 <script type="text/ja ...
- 统计时间段内周分类SQL语句
declare @datefrom as datetime,@dateto as datetime set @datefrom='2015-04-12' set @dateto='2015-08-13 ...
- 转mosquitto auth plugin 编译配置
配置使用 mysql 作为 be (back end) 使用config.mk 配置编译参数 cp config.mk.in config.mk 修改 安装 mysql sudo apt-get in ...
- IO多路复用之poll
1.基本知识 poll的机制与select类似,与select在本质上没有多大差别,管理多个描述符也是进行轮询,根据描述符的状态进行处理,但是poll没有最大文件描述符数量的限制.poll和selec ...
- 非常简单的一个函数 竟然一直没有使用 find()
find: 在非string类型的容器里,可以直接找出所对应的元素. find函数需要几个参数:迭代器,下标值,所要找的元素 vector<int> a; find(a.begin(),a ...
- android自定义控件(1)-自定义控件属性
那么还是针对我们之前写的自定义控件:开关按钮为例来说,在之前的基础上,我们来看看有哪些属性是可以自定义的:按钮的背景图片,按钮的滑块图片,和按钮的状态(是开还是关),实际上都应该是可以在xml文件中直 ...
- ngBind {{}} ngBindTemplate
1.首先我们最常使用的一个绑定表达式的指令是ngBind,比如在一个div标签中我们可以这样使用: <div ng-bind="vm.info"></div> ...