博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sdut 2158:Hello World!(第一届山东省省赛原题,水题,穷举)
阅读量:6262 次
发布时间:2019-06-22

本文共 2468 字,大约阅读时间需要 8 分钟。

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<N1000), 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, c300. 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.

示例输入

31 22 32 30

示例输出

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

提示

 

来源

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

 


 

  简单题,穷举即可。

  代码:

1 #include 
2 #include
3 using namespace std; 4 int main() 5 { 6 int n; 7 int Count =1; 8 while(cin>>n){ 9 if(n==0) break;10 int a[310][310]={
0};11 int r[1001]={
0};12 int c[1001]={
0};13 int MaxR=0,MaxC=0;14 for(int i=1;i<=n;i++){15 cin>>r[i]>>c[i];16 a[r[i]][c[i]] = 1;17 if(r[i]>MaxR)18 MaxR = r[i];19 if(c[i]>MaxC)20 MaxC = c[i];21 }22 cout<<"Case "<
<<':'<
MaxR || C+1>MaxC){27 cout<<-1<<' '<<-1<
MaxR && k>MaxC)36 cout<<-1<<' '<<-1<

 

Freecode :

转载地址:http://guzpa.baihongyu.com/

你可能感兴趣的文章
Premiere Pro & After Effects插件开发调试方法
查看>>
墨西哥短暂生活杂谈
查看>>
第四篇:R语言数据可视化之折线图、堆积图、堆积面积图
查看>>
异步编程之Javascript Promises 规范介绍
查看>>
EnumRemarkAttribute,获取属性值
查看>>
GCC扩展(转--对看kernel代码有帮助
查看>>
MVC3中使用RadioButtonFor()
查看>>
单元测试的概念
查看>>
Android特效 五种Toast详解
查看>>
phpcms(4) V9 栏目管理
查看>>
php多进程pcntl学习(采集新浪微博)
查看>>
[转]ListView学习笔记(一)——缓存机制
查看>>
【完全跨域】异步上传文件并获得返回值
查看>>
【TCP/IP详解 卷一:协议】第二章:链路层
查看>>
AWS开发人员认证考试样题解析
查看>>
Linux_DHCP服务搭建
查看>>
日请求亿级的 QQ 会员 AMS 平台 PHP7 升级实践
查看>>
【Coursera】Security Introduction -Eighth Week(2)
查看>>
Vue系列:如何将百度地图包装成Vue的组件
查看>>
Charles 从入门到精通
查看>>