2010年山东省第一届ACM大学生程序设计竞赛:Hello World!
来源:互联网 发布:单词社交网络 mp4 编辑:程序博客网 时间:2024/05/01 17:04
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?
“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 integerN (0<N≤1000), which represents the number of marked element.
Each of the nextN 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.
The first line of input in each test case contains one integerN (0<N≤1000), which represents the number of marked element.
Each of the nextN 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.
示例输入
31 22 32 30
示例输出
Case 1:2 3-1 -1-1 -1
提示
来源
2010年山东省第一届ACM大学生程序设计竞赛
#include <iostream>using namespace std;int map[301][301];int y[1001][2];void find(int r,int c){ int tag=0; for(int i=r+1; i<301; i++) { for(int j=c+1; j<301; j++) { if(map[i][j]==1&&tag==0) { tag=1; cout<<i<<" "<<j<<endl; break; } } } if(tag==0) { cout<<-1<<" "<<-1<<endl; }}int main(){ int t,g=0,loop=0; while(cin>>t) { if(t==0) { break; } else { int m=0; for(int i=0; i<301; i++) { for(int j=0; j<301; j++) { map[i][j]=0; } } int q=t; g++; while(t--) { loop++; int r,c; cin>>r>>c; m++; y[m][0]=r; y[m][1]=c; map[r][c]=1; } if(g>1&&loop>=2) { cout<<endl; } cout<<"Case "<<g<<":"<<endl; for(int j=1; j<=q; j++) { find(y[j][0],y[j][1]); } } } return 0;}
0 0
- Hello World! 2010年山东省第一届ACM大学生程序设计竞赛
- 2010年山东省第一届ACM大学生程序设计竞赛:Hello World!
- [2010山东省第一届ACM大学生程序设计竞赛]——Hello World!
- 山东省第一届ACM大学生程序设计竞赛 hello world! 水模拟
- 2010年山东省第一届ACM大学生程序设计竞赛:shopping
- 2010年山东省第一届ACM大学生程序设计竞赛:Balloons
- 2010年山东省第一届ACM大学生程序设计竞赛——Balloons
- Phone Number 2010年山东省第一届ACM大学生程序设计竞赛
- Ivan comes again!(2010年山东省第一届ACM大学生程序设计竞赛)
- 2010年山东省第一届ACM大学生程序设计竞赛——Clockwise
- 2010年山东省第一届ACM大学生程序设计竞赛——Emergency
- 2010年山东省第一届ACM大学生程序设计竞赛——Fairy tale
- 2010年山东省第一届ACM大学生程序设计竞赛——Greatest Number
- 2010年山东省第一届ACM大学生程序设计竞赛——Ivan comes again!
- 2010年山东省第一届ACM大学生程序设计竞赛——Ivan comes again!
- 2010年山东省第一届ACM大学生程序设计竞赛——Shopping
- SDUT 2151 Phone Number 2010年山东省第一届ACM大学生程序设计竞赛
- SDUT 2157 Greatest Number (二分) 2010年山东省第一届ACM大学生程序设计竞赛
- lintcode:Minimum Adjustment Cost
- RabbitMQ消息队列(七):适用于云计算集群的远程调用(RPC)
- poj2367
- 2048游戏python版
- hihoCoder[Offer收割]编程练习赛3题目解析
- 2010年山东省第一届ACM大学生程序设计竞赛:Hello World!
- LeetCode *** 238. Product of Array Except Self
- 【Java】分析JAVA应用CPU占用过高的问题
- 采用Memcached实现分布式Session
- binder
- RabbitMQ消息队列的小伙伴(八): ProtoBuf(Google Protocol Buffer)
- 【bzoj2124】等差子序列 权值线段树维护hash
- 《Android第一行代码》学习笔记
- 自顶向下的归并排序和自底向上的归并排序