Hello World! 2010年山东省第一届ACM大学生程序设计竞赛
Hello World!
Time Limit: 1000MS Memory limit: 65536K
题目描述
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?
输入
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.
输出
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
#include<iostream>
#include<algorithm>
using namespace std;
struct T
{ int w,l,s;
}a[5010];
bool cmp(T a,T b)
{
if(a.l==b.l)
return a.w<b.w;
return a.l<b.l; }
int main()
{
bool p;
int i,j,n,k=1,m;
while(cin>>n&&n)
{ p=0;
for(i=0;i<n;i++)
{cin>>a[i].l>>a[i].w;a[i].s=i;}
sort(a,a+n,cmp);
// cout<<endl;
cout<<"Case "<<k<<':'<<endl;
k++;
for(j=0;j<n;j++)
{p=0;
for(i=0;i<n;i++)
{if(a[i].s==j)
{
for(m=i+1;m<n;m++)
if(a[m].l>a[i].l&&a[m].w>a[i].w)
{cout<<a[m].l<<' '<<a[m].w<<endl;p=1;break;}
if(p==0)
{cout<<-1<<' '<<-1<<endl;break;} }}
}
cout<<endl;
} return 0;
}
Hello World! 2010年山东省第一届ACM大学生程序设计竞赛的更多相关文章
- sdut 2153 Clockwise (2010年山东省第一届ACM大学生程序设计竞赛)
题目大意: n个点,第i个点和第i+1个点可以构成向量,问最少删除多少个点可以让构成的向量顺时针旋转或者逆时针旋转. 分析: dp很好想,dp[j][i]表示以向量ji(第j个点到第i个点构成的向量) ...
- sdut 2159 Ivan comes again!(2010年山东省第一届ACM大学生程序设计竞赛) 线段树+离散
先看看上一个题: 题目大意是: 矩阵中有N个被标记的元素,然后针对每一个被标记的元素e(x,y),你要在所有被标记的元素中找到一个元素E(X,Y),使得X>x并且Y>y,如果存在多个满足条 ...
- 2010年山东省第一届ACM大学生程序设计竞赛 Balloons (BFS)
题意 : 找联通块的个数,Saya定义两个相连是 |xa-xb| + |ya-yb| ≤ 1 ,但是Kudo定义的相连是 |xa-xb|≤1 并且 |ya-yb|≤1.输出按照两种方式数的联通块的各数 ...
- Phone Number 2010年山东省第一届ACM大学生程序设计竞赛
Phone Number Time Limit: 1000MS Memory limit: 65536K 题目描述 We know that if a phone number A is anothe ...
- [2011山东省第二届ACM大学生程序设计竞赛]——Identifiers
Identifiers Time Limit: 1000MS Memory limit: 65536K 题目:http://acm.sdut.edu.cn/sdutoj/problem.php?act ...
- Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)
Alice and Bob Time Limit: 1000ms Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...
- 2013年山东省第四届ACM大学生程序设计竞赛-最后一道大水题:Contest Print Server
点击打开链接 2226: Contest Print Server Time Limit: 1 Sec Memory Limit: 128 MB Submit: 53 Solved: 18 [Su ...
- 山东省第四届ACM大学生程序设计竞赛解题报告(部分)
2013年"浪潮杯"山东省第四届ACM大学生程序设计竞赛排名:http://acm.upc.edu.cn/ranklist/ 一.第J题坑爹大水题,模拟一下就行了 J:Contes ...
- [2012山东省第三届ACM大学生程序设计竞赛]——n a^o7 !
n a^o7 ! 题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2413 Time Lim ...
随机推荐
- GB2312引进和使用的字体
一个:先上图看到的结果,下面的屏幕截图android在测试的结果"SD卡测试".."GPS测试"和其他字符24x24字体进来. 二: 1)简单介绍 ...
- 解决org.hibernate.LazyInitializationException: could not initialize proxy - no Session懒载入问题
问题描写叙述: Struts Problem Report Struts has detected an unhandled exception: Messages: could not initia ...
- hdu 1536(博弈)
传送门:S-Nim 题意:给n个数的集合s, 再给m 组数据,每组表示 k 堆石子,每次可以取的个数只能是集合s中的数量.问先手胜还是输? 分析:sg函数的经典运用,先预处理出所有数量为0~10000 ...
- 那些年踩过的坑之:first-child伪类选择器
原文:那些年踩过的坑之:first-child伪类选择器 :first-child 选择器用于选取属于其父元素的首个子元素的指定选择器.——w3school 嗯,乍一看好像说的不是很明白,因此这个选择 ...
- git不同linux版本号说明
在确保你安装好git后,我们就能够通过git来下载linux kernel了,这时要先说一下linux的版本号分类. 在 Linux 内核官网上(https://www.kernel.org/),我们 ...
- 每天进步一点点——Linux磁盘管理LVM与RAID
转载请注明出处:http://blog.csdn.net/cywosp/article/details/38965799 1. 传统磁盘管理问题 当分区大小不够用时无法扩展其大小,仅仅能通过加入硬盘. ...
- Application.mk中APP_ABI 的含义
我们在编写JNI代码时有一个可选的文件Application.mk ,这个文件你可以不创建,但是有时候是有必要写一个这样的文件的. Application.mk文件用于描述应用程序本身的一些属性信息, ...
- (转)在 Visual Studio 2010 中创建 ASP.Net Web Service
很多人在论坛里说,在Visual Studio 2010中不能创建“ASP.Net Web Service”这种project了,下面跟帖者云云,有的说这是因为微软已经将Web Service整合进W ...
- 数字证书及CA的扫盲介绍(转)
★ 先说一个通俗的例子 考虑到证书体系的相关知识比较枯燥.晦涩.俺先拿一个通俗的例子来说事儿. ◇ 普通的介绍信 想必大伙儿都听说过介绍信的例子吧?假设 A 公司的张三先生要到 B 公司去拜访,但是 ...
- FluentData
FluentData微型ORM 最近在帮朋友做一个简单管理系统,因为笔者够懒,但是使用过的NHibernate用来做这中项目又太不实际了,索性百度了微型ORM,FluentData是第一个跳入我眼睛的 ...