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 30

示例输出

Case 1:
2 3
-1 -1
-1 -1
#include <bits/stdc++.h>
using namespace std;
struct list1{int x,y;}a[1111],b[1111];
bool cmp(list1 a,list1 b)
{if(a.x!=b.x) return a.x<b.x;return a.y<b.y;
}
int main()
{int n,k=1;while(scanf("%d",&n),n){for(int i=1;i<=n;i++)scanf("%d%d",&a[i].x,&a[i].y),b[i].x=a[i].x,b[i].y=a[i].y;sort(a+1,a+1+n,cmp);printf("Case %d:\n",k++);for(int i=1;i<=n;i++){int f=0;for(int j=1;j<=n;j++)if(a[j].x>b[i].x && a[j].y>b[i].y){printf("%d %d\n",a[j].x,a[j].y);f=1;break;}if(!f) printf("-1 -1\n");}printf("\n");}return 0;
}

山东省第一届ACM省赛 H SDUT 2158 Hello World!(穷举)相关推荐

  1. 山东省第一届ACM省赛 C SDUT 2153 Clockwise

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

  2. 第一届 ACM省赛山东省 Emergency

    Emergency Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Kudo's real name is not Kudo. H ...

  3. [2010山东省第一届ACM大学生程序设计竞赛]——Greatest Number

    Greatest Number 题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2157 题 ...

  4. CQUPT第九届ACM校赛 H 锦鱼突刺 题解

    题目: Description CC公主被抓走了,为了救回她,你要通过九个关卡的考验. 在这一关中,你要通过一座浮桥.浮桥由多块漂浮的木板组成.不幸的是,水里生存着一种凶残的锦鱼,锦鱼的突刺会刺穿木板 ...

  5. CQUPT第九届ACM校赛 H 夺命毒奶

    1524: 夺命果奶 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 187  Solved: 16 [Submit][Status][Web Boar ...

  6. CQUPT第十三届ACM网赛 H. 活动图 题解

    输入样例 6 7 3 1 4 1 5 9 1 2 7 1 3 11 2 3 13 3 4 1 3 6 19 4 5 20 5 6 1 输出样例 5 我们需要走遍整张图,故求最小生成树即可,想复杂了. ...

  7. SDNU 1136.Balloons【山东省第一届ACM】【7月20】

    Balloons 原题贴上,不给链接了啊. Description Both Saya and Kudo like balloons. One day, they heard that in the ...

  8. 2021-SZTU第一届acm校赛总结

    关于题目: 我们队上来找到签到题,一个上去签,我和另外一个继续看题,我从后往前,他从前往后.后边的题目普遍是中文,难度也更高.然后他们两个就讨论一题签一题,干掉四题.我看了一道区间操作相关的题目,最近 ...

  9. [2010山东ACM省赛] Greatest Number(数的组合+二分搜索)

    Greatest Number Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Saya likes math, because ...

最新文章

  1. 程序员如何讲清楚技术方案
  2. hadoop2 作业执行过程之作业提交
  3. php查询每个小时的数据,php – MySQL显示表中每小时的条目数
  4. 代码编译delphi条件编译
  5. Python语言学习之数值、小数、空格那些事:python和数值、小数、空格的使用方法之详细攻略
  6. 深刻感知运营之“痛”,我们推出了新产品——神策智能运营
  7. PCB线宽与电流的关系
  8. 计算机技术题目,计算机技术题目.doc
  9. [react] react16的reconciliation和commit分别是什么?
  10. dede plus ad js.php,织梦dedecms/plus/文件夹的功能介绍
  11. 将S所指的字符串中下标为偶数同时ASCⅡ值为奇数的字符删除,所指串中剩余的字符形成新的串放在t所指的数组中
  12. findbugs 接口文档_Java代码审查工具findbugs的使用总结
  13. linux video属性_Linux 下Video 的制作方法
  14. python 通过逗号分割字符串_「Python 秘籍」使用多个界定符分割字符串
  15. 柒微自动发卡系统源码
  16. SRC漏洞挖掘之信息收集
  17. Ubuntu上aplay不能播放MP3, 使用sox
  18. Kaavi and Magic Spell
  19. Java ques:Client does not support authentication protocol requested by server;Access denied user‘roo
  20. php牛牛发牌算法,分享一个牛牛算法

热门文章

  1. 南邮 | Linux实验五:Linux/C 开发环境 gcc 编译和 make 项目管理
  2. 参照阿波罗自己实现的分布式配置中心
  3. 惠普战66系统还原后,在桌面右击鼠标很卡处理
  4. B站动漫排行数据获取(樱雪动漫推荐项目源码)
  5. python身份证识别仪_C#身份证识别相关技术功能详解
  6. 基于3G手机的移动云计算和云存储
  7. 猿创征文|对象比较“==”与“hashCode()”的孽缘(java 小虚竹)
  8. PTA:7-31 期刊收费
  9. pid是滞后超前校正_超前校正,滞后校正,超前滞后校正三种校正方法的比较
  10. linux哪些程序需要指定终端,Linux程序员福利 - 追女友神奇(Linux终端运行炫酷程序)...