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 ...
随机推荐
- php 多进程中的信号问题
1.以下代码sleep时间远小于20 <?php // 当子进程退出时,会触发该函数 function sig_handler($sig) { switch($sig) { case SIGCH ...
- 为什么 as sysdba着陆方法oracle数据库,为什么刚刚输入username和password我们都可以登录?
事实上,这是oracle问题数据库的身份验证方法 该 sqlnet.ora在文件 SQLNET.AUTHENTICATION_SERVICES= (NTS) 变 SQLNET.AUTHENTICATI ...
- ARM架构和编程-4
ARM中断异常处理: ARM系统中止品种:按中断处理降序排列优先级:重置.数据访问中止.高速中断请求.外部中断请求.预取中止.令.软件中断. ARM体系中的异常中断向量表: 0x0 复位 0x4 没有 ...
- [cocos2dx-lua]"Hello Lua"分析
一年之前学的cocos2dx,那时候还是用C++编写的.但学完之后就找的一个新的方向--Unity3D开发的岗位,对我而言是一个新方向,那时候经过了几个月的每天熬夜奋战,从"0"基 ...
- atitit.java方法属性赋值and BeanUtils 1.6.1 .copyProperty的bug
atitit.java分配给属性值方法and BeanUtils 1.6.1 .copyProperty的bug 1. core.setProperty(o, "materialId&quo ...
- C++用于修饰的keyword
1.const修饰指针 (1)const int *p=&x:不可改动*p的内容,但能够让指针p指向还有一个地址,和int const *p一样 (2)int *const p=&x: ...
- plist文件读写
- (void)viewDidLoad { [super viewDidLoad]; NSDictionary *dictionary1 = [NSDictionary dictionaryWithO ...
- 一般报java.lang.NullPointerException的原因有以下几种
一般报java.lang.NullPointerException的原因有以下几种: ·字符串变量未初始化: ·接口类型的对象没有用具体的类初始化,比如: List lt; 会报错 List lt = ...
- (九)通过几段代码,理清angularJS中的$injector、$rootScope和$scope的概念和关联关系
$injector.$rootScope和$scope是angularJS框架中比較重要的东西,理清它们之间的关系,对我们兴许学习和理解angularJS框架都很实用. 1.$injector事实上是 ...
- POJThe Doors AND NYIST 有趣的问题
POJThe Doors AND NYIST 有趣的问题 题目链接:pid=227" target="_blank">Click Here~ 题目分析: 给你横纵坐 ...