sdut 2158:Hello World!(第一届山东省省赛原题,水题,穷举)
Hello World!
Time Limit: 1000MS Memory limit: 65536K
题目描述
“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 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.
输出
示例输入
3
1 2
2 3
2 3 0
示例输出
Case 1:
2 3
-1 -1
-1 -1
提示
来源
简单题,穷举即可。
代码:
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
int n;
int Count =;
while(cin>>n){
if(n==) break;
int a[][]={};
int r[]={};
int c[]={};
int MaxR=,MaxC=;
for(int i=;i<=n;i++){
cin>>r[i]>>c[i];
a[r[i]][c[i]] = ;
if(r[i]>MaxR)
MaxR = r[i];
if(c[i]>MaxC)
MaxC = c[i];
}
cout<<"Case "<<Count++<<':'<<endl;
for(int i=;i<=n;i++){
int R = r[i],C = c[i];
int j,k;
if(R+>MaxR || C+>MaxC){
cout<<-<<' '<<-<<endl;
continue;
}
for(j=R+;j<=MaxR;j++)
for(k=C+;k<=MaxC;k++)
if(a[j][k]==)
goto label;
label:
if(j>MaxR && k>MaxC)
cout<<-<<' '<<-<<endl;
else
cout<<j<<' '<<k<<endl;
}
cout<<endl;
}
return ;
}
Freecode : www.cnblogs.com/yym2013
sdut 2158:Hello World!(第一届山东省省赛原题,水题,穷举)的更多相关文章
- sdut 2154:Shopping(第一届山东省省赛原题,水题)
Shopping Time Limit: 1000MS Memory limit: 65536K 题目描述 Saya and Kudo go shopping together.You can ass ...
- sdut 2152:Balloons(第一届山东省省赛原题,DFS搜索)
Balloons Time Limit: 1000MS Memory limit: 65536K 题目描述 Both Saya and Kudo like balloons. One day, the ...
- sdut 2153:Clockwise(第一届山东省省赛原题,计算几何+DP)
Clockwise Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Saya have a long necklace with ...
- sdut 2163:Identifiers(第二届山东省省赛原题,水题)
Identifiers Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Identifier is an important c ...
- sdut 2159:Ivan comes again!(第一届山东省省赛原题,STL之set使用)
Ivan comes again! Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 The Fairy Ivan gave Say ...
- sdut 2162:The Android University ACM Team Selection Contest(第二届山东省省赛原题,模拟题)
The Android University ACM Team Selection Contest Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里 ...
- sdut 2165:Crack Mathmen(第二届山东省省赛原题,数论)
Crack Mathmen Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Since mathmen take securit ...
- sdut 2610:Boring Counting(第四届山东省省赛原题,划分树 + 二分)
Boring Counting Time Limit: 3000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 In this problem you a ...
- sdut 2411:Pixel density(第三届山东省省赛原题,字符串处理)
Pixel density Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Pixels per inch (PPI) or pi ...
随机推荐
- if-else用法
CreateTime--2016年10月31日14:22:25Author:Marydonif-else的多种用法: //方式一 function test1 (t) { var bl = t | ...
- adb详解
adb详解 分类: android开发工具相关 2012-10-24 18:27 2822人阅读 评论(0) 收藏 举报 ADB全称Android Debug Bridge,是android sdk里 ...
- 【php写日志】php将日志写入文件
php 写内容到文件,把日志写到log文件 <?php header("Content-type: text/html; charset=utf-8"); /******** ...
- python --标准库 路径与文件 (os.path包, glob包)
os.path包 os.path包主要是处理路径字符串,提取出有用信息. #coding:utf-8 import os.path path = 'D:\\Python7\\test\\data.tx ...
- 用Reflector for .NET反编译dll文件(.net),把整个dll导出个cs插件
Reflector for .NET 下载地址: http://www.aisto.com/roeder/dotnet/ Reflector.FileDisassembler.zip下载地址: htt ...
- centos7下mysqldump+crontab自动备份数据库
1.创建文件夹(存放备份数据) mkdir /bak mkdir /bak/mysqldata 2.编写脚本 vi /usr/sbin/bakmysql.sh 脚本内容如下 DATE=`date +% ...
- Node Redis 小试
Redis 是一个高性能的 key-value 数据库,为了保证效率,数据都是缓存在内存中,在执行频繁而又复杂的数据库查询条件时,可以使用 Redis 缓存一份查询结果,以提升应用性能. 背景 如果一 ...
- Atitit.软件仪表盘(2)--vm子系统--资源占用监测
Atitit.软件仪表盘(2)--vm子系统--资源占用监测 1. Jvisualvm.exe 2. jprofile 3. Heap //permgen monitor 作者::老哇的爪子At ...
- [svc]salt-grains
用途 1,匹配客户端 2,配置文件里使用 3,资产管理 定义grains方法1: 方法2:
- xUtils工具实现下载功能
private String download_url="http://192.168.2.8:80/DownZip/*****.zip";//下载的路径 public Stri ...