Hello World!

Time Limit: 1000MS Memory limit: 65536K

题目描述

We know that Ivan gives Saya three problems to solve (Problem F), and this is the first problem.
“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 input consists of several test cases.
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.

输出

For each case, print the case number (1, 2 …), and for each element’s row and column, output the result. Your output format should imitate the sample output. Print a blank line after each test case.

示例输入

3
1 2
2 3
2 3 0

示例输出

Case 1:
2 3
-1 -1
-1 -1

提示

 

来源

 2010年山东省第一届ACM大学生程序设计竞赛

  简单题,穷举即可。

  代码:

 #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!(第一届山东省省赛原题,水题,穷举)的更多相关文章

  1. sdut 2154:Shopping(第一届山东省省赛原题,水题)

    Shopping Time Limit: 1000MS Memory limit: 65536K 题目描述 Saya and Kudo go shopping together.You can ass ...

  2. sdut 2152:Balloons(第一届山东省省赛原题,DFS搜索)

    Balloons Time Limit: 1000MS Memory limit: 65536K 题目描述 Both Saya and Kudo like balloons. One day, the ...

  3. sdut 2153:Clockwise(第一届山东省省赛原题,计算几何+DP)

    Clockwise Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Saya have a long necklace with ...

  4. sdut 2163:Identifiers(第二届山东省省赛原题,水题)

    Identifiers Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述  Identifier is an important c ...

  5. sdut 2159:Ivan comes again!(第一届山东省省赛原题,STL之set使用)

    Ivan comes again! Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 The Fairy Ivan gave Say ...

  6. sdut 2162:The Android University ACM Team Selection Contest(第二届山东省省赛原题,模拟题)

    The Android University ACM Team Selection Contest Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里 ...

  7. sdut 2165:Crack Mathmen(第二届山东省省赛原题,数论)

    Crack Mathmen Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述  Since mathmen take securit ...

  8. sdut 2610:Boring Counting(第四届山东省省赛原题,划分树 + 二分)

    Boring Counting Time Limit: 3000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述     In this problem you a ...

  9. sdut 2411:Pixel density(第三届山东省省赛原题,字符串处理)

    Pixel density Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Pixels per inch (PPI) or pi ...

随机推荐

  1. android开发之数据库游标未关闭导致

    replacements=[Ljava.lang.String;@4192fea8HARDWARE=hw7d501lmatchers=[Ljava.lang.String;@4192fe28RADIO ...

  2. jquery获取json对象中的key小技巧,遍历json串所有key,value

    比如有一个json var json = {"name" : "Tom", "age" : 18}; 想分别获取它的key 和 value ...

  3. 音视频技术 即时通讯SDK

    视频流中的DTS/PTS究竟是什么?      DTS(解码时间戳)和PTS(显示时间戳)各自是解码器进行解码和显示帧时相对于SCR(系统參考)的时间戳.SCR能够理解为解码器应该開始从磁盘读取数据时 ...

  4. TensorFlow 安装 Ubuntu14.04

    1.Install pip (or pip3 for python3) if it is not already installed: # Ubuntu/Linux 64-bit $ sudo apt ...

  5. 迭代器适配器{(插入迭代器back_insert_iterator)、IO流迭代器(istream_iterator、ostream_iterator)}

    一.迭代器适配器 反向迭代器 插入迭代器 IO流迭代器 其中反向迭代器可以参考以前的文章. 二.插入迭代器 插入迭代器实际上是一个输出迭代器(*it=; ++) back_insert_iterato ...

  6. 浅谈LZSS与游戏图片破解

      业余游戏制作者最头疼的就是没有美工的支持了.很多业余游戏制作所使用的图片都是来自于网上的很有限的一些图片资源,然而这些图片并不能完整配套,所以业余游戏的画面往往显得单调或者搭配不协调(使用多个不属 ...

  7. java语言国际化--ResouceBundle、struts

    一.Java国际化 我们使用java.lang.Locale来构造Java国际化的情境. java.lang.Locale代表特定的地理.政治和文化.需要Locale来执行其任务的操作叫语言环境敏感的 ...

  8. tp数据库操作

    1.常见的数据库操作//插入记录// $insert=Db::execute("insert into tp_user (username,password) values ('dome', ...

  9. css 只改变父元素的透明度,不改变子元素透明度rgba+opacity

    给元素加透明度时,通常写法为:opacity:0.5,filter:alpha(opacity=50); 我们通常也会遇到,在给父元素背景设置透明度时,子元素内容继承了父元素的透明度. 如何让子元素脱 ...

  10. sso单点登录研究

    iframe跨域通信的通用解决方案http://www.alloyteam.com/2012/08/lightweight-solution-for-an-iframe-cross-domain-co ...