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 ...
随机推荐
- 获取Jenkins project build结果
当Jenkins管理的build project越来越多的时候,须要脚本收集每一个project的近期一次build结果,从而集中管理.依据业务规则,决定是否重算和何时重算. 以下的命令是利用curl ...
- jvm调优经验分享
当Java程序申请内存,超出VM可分配内纯的时候,VM首先可能会GC,假设GC完还是不够,或者申请的直接超够VM可能有的,就会抛出内 存溢出异常.从VM规范中我们能够得到,一下几种异常. java.l ...
- php 用递归实现的无限级别分类
<?php header("Content-type:text/html; charset=utf-8"); /** * * @category contry_cate ...
- SICP 解题集 — SICP 解题集
SICP 解题集 — SICP 解题集 SICP 解题集¶ 这个文档的目标是成为中文化的.完整的<计算机程序的构造和解释>一书的解题集. 这个解题集的特色是: 对于每道习题,除了习题答案之 ...
- 常用PHP中花括号使用规则详解
转自http://www.cnblogs.com/jayleke/archive/2011/11/08/2241609.html 1.简单句法规则(用花括号界定变量名,适用于PHP所有版本): $a ...
- AIX常用命令略记
■ 初始化端末时可能需要确认服务器端和端末时间是否匹配 ●cal 显示日历 ●date 显示服务前当前时间 ■ 显示当前目录,即显示当前所在目录的adress ●pwd(print workin ...
- js封装好的模仿qq消息弹窗代码
在我们的日常开发中,或者生活中.常常须要用到弹出窗.这里我们就用js模拟一下qq消息一样的弹出窗. 直接贴代码: <!DOCTYPE html PUBLIC "-//W3C//DTD ...
- Jersey框架二:Jersey对JSON的支持
Jersey系列文章: Jersey框架一:Jersey RESTful WebService框架简介 Jersey框架二:Jersey对JSON的支持 Jersey框架三:Jersey对HTTPS的 ...
- C#之网络
首先很不好意思,前段时间把评论的功能给关掉啦,BUT NOW 此功能以开放,欢迎小伙伴们拍砖. 1网络 在网络环境下,我们最感兴趣的两个名称空间是System.Net和System.Net.Socke ...
- iOS7 文本转语音 AVSpeechSynthesizer
OS7 的这个功能确实不错.我刚试了下,用官方提供的API ,简单的几句代码就能实现文本转语音! Xcode 5.0 工程建好后首先把AVFoundation.framework 加入到工程 AVSp ...