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 ...
随机推荐
- Mac安装Myeclipse2015开发环境
1.下载Myeclipse2015 链接: http://pan.baidu.com/s/1jHe8mFk 密码: qgeb 下载下来后,在安装的时候需要自己设置下安装目标,不然在破解的时候不是太好找 ...
- JAVA实现zip压缩需要注意的问题
近来对院社二维码平台进行2.0升级改造.于昨日踩到一个巨坑.特此记录... 需求源于院社编辑在批量下载二维码的时候,系统后台需要对所要下载的二维码进行重命名和zip打包压缩. 系统测试的时候发现:首次 ...
- Appium完整安装教程
Appium安装教程 发布时间: 2014-12-11 10:34 作者: 柒月 来源: 51Testing软件测试网采编 字体: 小 中 大 | 上一篇 下一篇 | 打印 | ...
- Python -- 函数对象
转自:http://www.cnblogs.com/vamei/archive/2012/07/10/2582772.html 秉承着一切皆对象的理念,我们再次回头来看函数(function).函数也 ...
- 流类库继承体系(IO流,文件流,串流)和 字符串流的基本操作
一.IO.流 数据的输入和输出(input/output简写为I/O) 对标准输入设备和标准输出设备的输入输出简称为标准I/O 对在外存磁盘上文件的输入输出简称为文件I/O 对内存中指定的字符串存储空 ...
- javascript 相等运算符
相等运算符 JavaScript提供两个相等运算符:==和===. 简单说,它们的区别是相等运算符(==)比较两个值是否相等,严格相等运算符(===)比较它们是否为“同一个值”.如果两个值不是同一类型 ...
- linux学习规划
- Ubuntu 14.04主机上部署k8s集群
部署结构 3台虚拟机,其中1台作为master,2台作为minion,都安装了最新版本的docker engine(目前是1.11.2) k8s版本是1.3.0 主要问题 部署步骤基本按照官方文档:h ...
- CentOS安装使用git
yum install git yum install git-gui (可选) git config --global user.name "gg" git config --g ...
- 基于注解的ssh框架之spring配置文件
<?xml version="1.0" encoding="UTF-8"?> com.mysql.jdbc.Driver jdbc:mysql:// ...