Sdut 2409 The Best Seat in ACM Contest(山东省第三届ACM省赛 H 题)(模拟)
题目描述
Cainiao is a university student who loves ACM contest very much. It is a festival for him once when he attends ACM Asia Regional Contest because he always can find some famous ACMers there.
Cainiao attended Asia Regional Contest Fuzhou Site on November 20, 2011. After he got seat map, he wanted to know which seat is the best one.
Cainiao have joined so many QQ Group about ACM/ICPC that he is almost familiar with the strength of each team. In his mind, the value of a seat is defined as following:
1. Strength of each team can be expressed as a positive integer.
2. The value of a seat is related to the adjacent seat (up/down/left/right, only four directions being considering).
3. For an adjacent seat, if the strength of this team is stronger than yours, the absolute value of difference of two teams should be added to your seat, otherwise, the absolute value of difference should be subtracted from your seat.
4. If the adjacent seat is empty (which means you are located at the most left/right/up/down), the value of your seat should be subtracted 1.
5. The best one in a contest is the seat that has the highest value.
6. The initial value of the seat is ZERO.
For example, there are 12 ( 3 X 4 ) teams in a contest, the strength of each team is as figure (a), and then you can calculate the value of each seat as figure (b).
输入
Input contain a positive integer T( T <=50 ) in the first line, which means T cases.
The first line of each case contains two positive integers N and M (3 <= N, M <= 20) which means the row and column number of the teams, then N rows following, each line contains M positive integers that represent the strengths of the teams.
输出
For each case, first output the case number, and then output the value and row number and column number of the best seat in one line for each case.
If there are multiple solutions for one case, you should output the seat whose row number is largest and only output the seat whose column number is largest if still overlapping.
示例输入
- 13 41 5 3 46 3 3 44 3 2 1
示例输出
- Case 1: 7 1 1
提示
来源
- #include <iostream>
- #include<string.h>
- #include<stdio.h>
- using namespace std;
- const int MAX = 30;
- int num[MAX][MAX];
- int figure[MAX][MAX];
- int main()
- {
- int t,m,n,i,j,h;
- cin>>t;
- for(h = 1;h<=t;h++)
- {
- cin>>m>>n;
- memset(num,0,sizeof(num));
- memset(figure,0,sizeof(figure));
- for(i = 1;i<=m;i++)
- for(j = 1;j<=n;j++)
- {
- cin>>num[i][j];
- }
- /// 边界处理
- for(i = 1;i<=m;i++)
- {
- num[i][0] = num[i][1]-1;
- num[i][n+1] = num[i][n]-1;
- }
- for(i = 1;i<=n;i++)
- {
- num[0][i] = num[1][i]-1;
- num[m+1][i] = num[m][i]-1;
- }
- for(i = 1;i<=m;i++)
- {
- for(j = 1;j<=n;j++)
- {
- int sum = num[i+1][j] + num[i-1][j] + num[i][j+1] + num[i][j-1];/// 思路中代码实现
- figure[i][j] = sum - num[i][j]*4;
- }
- }
- int ans = -99999999,r,c;
- for(i = 1;i<=m;i++)
- {
- for(j = 1;j<=n;j++)
- {
- if(ans<figure[i][j])
- {
- ans = figure[i][j];
- r = i;c = j;
- }
- }
- }
- cout<<"Case "<<h<<": "<<ans<<" "<<r<<" "<<c<<endl;
- }
- return 0;
- }
- /**************************************
- Problem id : SDUT OJ 2409
- User name : CY_
- Result : Accepted
- Take Memory : 476K
- Take Time : 0MS
- Submit Time : 2014-04-28 09:27:04
- **************************************/
Sdut 2409 The Best Seat in ACM Contest(山东省第三届ACM省赛 H 题)(模拟)的更多相关文章
- [2012山东省第三届ACM大学生程序设计竞赛]——n a^o7 !
n a^o7 ! 题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2413 Time Lim ...
- [2012山东省第三届ACM大学生程序设计竞赛]——Mine Number
Mine Number 题目:http://acm.sdut.edu.cn/sdutoj/problem.php? action=showproblem&problemid=2410 Time ...
- 山东省第三届ACM省赛
Solved ID PID Title Accepted Submit A 2407 Impasse (+) 0 0 B 2415 Chess 0 0 C 2414 An interest ...
- Sdut 2416 Fruit Ninja II(山东省第三届ACM省赛 J 题)(解析几何)
Time Limit: 5000MS Memory limit: 65536K 题目描述 Haveyou ever played a popular game named "Fruit Ni ...
- [ACM]2013山东省“浪潮杯”省赛 解题报告
题目地址:http://acm.upc.edu.cn/problemset.php?page=13 2217~2226 A.Rescue The Princess 一个等边三角形告诉前2个点,求逆时 ...
- ACM: NBUT 1105 多连块拼图 - 水题 - 模拟
NBUT 1105 多连块拼图 Time Limit:1000MS Memory Limit:65535KB 64bit IO Format: Practice Appoint ...
- 2012年"浪潮杯"山东省第三届ACM大学生程序设计竞赛--n a^o7 ! 分类: 比赛 2015-06-09 17:16 14人阅读 评论(0) 收藏
n a^o7 ! Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 All brave and intelligent fighte ...
- hdu 4438 第37届ACM/ICPC 天津赛区现场赛H题
题意:Alice和Bob两个人去打猎,有两种(只)猎物老虎和狼: 杀死老虎得分x,狼得分y: 如果两个人都选择同样的猎物,则Alice得分的概率是p,则Bob得分的概率是(1-p): 但是Alice事 ...
- sdut2408 pick apples (贪心+背包)山东省第三届ACM省赛
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/svitter/article/details/24642587 本文出自:http://blog.c ...
随机推荐
- IE-“无法浏览网页” 教你十招解决疑难杂症
“无法浏览网页” 教你十招解决疑难杂症 相信大家也有遇到过像IE不能上网浏览的问题.下面就来给大家介绍一下常见原因和解决方法: 一.网络设置的问题 这种原因比较多出现在需要手动指定IP.网关.DNS服 ...
- [三]JFreeChart实践二
功能: 1.设置带色彩的柱状图 2.可以设置多组数据的展示 3.可以设置图标的背景色 4.可以设置柱与柱之间的距离 5.可以设置柱子上边是否显示具体的数值
- Xcode7 低版本iOS系统上下有黑边的问题
在使用Xcode7开发时,默认的启动页改成了 Launch Screen storyboard.通常情况下还是习惯使用 LaunchImage,介绍下Xcode7 下如何改为启动页是LaunchIma ...
- 杭电ACM1218——Blurred Vision
题目有点长,并且比較难懂.看了非常久.也看的不是非常懂,仅仅知道输入输出的格式. 直到看了最后的一句话,也就是output那里的最后一句话,题目的意思就非常明白了,就是输出的每个点的像素是原始的四个像 ...
- Android5.0之Toobar的使用
总体上来说,Toolbar的使用可以分为两个方面,一方面是将ToolBar当作ActionBar来用,另一方面就是将Toolbar当成一个单独的控件来用,不过到目前为止我见到的大部分情况都是把Tool ...
- 使用摘要流获取文件的MD5
摘要流是过滤流的一种,使用它可以再读取和写入流时获取流的摘要信息(MD5/SHA). 使用摘要流包装流时,需要额外传递一个MessageDigest对象, MessageDigest md=Messa ...
- hysdk代码解析
navigator 1. navigator.userAgent 浏览器的用户代理字符串 2. navigator.platform 浏览器所在的系统平台 window 1. window.devic ...
- Linux C —— 多线程
为了防止无良网站的爬虫抓取文章,特此标识,转载请注明文章出处.LaplaceDemon/ShiJiaqi. http://www.cnblogs.com/shijiaqi1066/p/5769417. ...
- 简单的实现QQ通信功能(三)
第三部分:登陆界面的设计及代码 一:效果图及界面设计 1. 效果图: 2. 界面设计: (1)仿照QQ的登陆界面,右上角放了三个Label,用来做关闭.最小化和设置,使用了它们的Click事件当做按钮 ...
- break continue return 区别
break语句: break语句会使运行的程序立刻退出包含在最内层的循环或者退出一个switch语句.由于它是用来退出循环或者switch语句,所以只有当它出现在这些语句时,这种形式的break语句才 ...