SDUT 2409:The Best Seat in ACM Contest

316人阅读 评论(0) 收藏 举报
分类:

The Best Seat in ACM Contest

Time Limit: 1000MS Memory limit: 65536K

题目描述

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.

示例输入

1
3 4
1 5 3 4
6 3 3 4
4 3 2 1

示例输出

Case 1: 7 1 1

每一块的数字等于它周围四个块的和-4*当前块!边界以外块的值=其相邻-1;

#include<stdio.h>  
#include<iostream>  
#include<string.h>  
#include<algorithm>  
using namespace std;  
int main()  
{  
    int T;  
    cin>>T;  
    int a[105][105],bb[105][105];  
    for(int i=1;i<=T;i++)  
    {  
        memset(a,0,sizeof(a));  
        memset(bb,0,sizeof(bb));  
        int n,m;  
        cin>>n>>m;  
        for(int j=1;j<=n;j++)  
            for(int k=1;k<=m;k++)  
        {  
            cin>>a[j][k];  
            if(j==1)a[j-1][k]=a[j][k]-1;  
            if(j==n)a[j+1][k]=a[j][k]-1;  
            if(k==1)a[j][k-1]=a[j][k]-1;  
            if(k==m)a[j][k+1]=a[j][k]-1;  
        }  
        int maxx=0,mi=0,mj=0;  
        for(int j=1;j<=n;j++)  
        {  
            for(int k=1;k<=m;k++)  
            {  
                bb[j][k]=a[j-1][k]+a[j+1][k]+a[j][k-1]+a[j][k+1]-4*a[j][k];  
                if(bb[j][k]>maxx)  
                {  
                    maxx=bb[j][k];  
                    mi=j;  
                    mj=k;  
                }  
            }  
        }  
        printf("Case %d: %d %d %d\n",i,maxx,mi,mj);  
    }  
    return 0;  
}  


查看评论

[2012山东省第三届ACM大学生程序设计竞赛]——The Best Seat in ACM Contest

2012山东省第三届ACM大学生程序设计竞赛 The Best Seat in ACM Contest 山东省赛 ACM sdut2409...
  • lx417147512
  • lx417147512
  • 2014-04-27 15:57:10
  • 1287

2013山东省第三届ACM省赛 The Best Seat in ACM Contest

题意:计算每个座位的value值,根据坐在该座位的队伍长度与其上下左右方向的四个队伍长度比较。若该位置的队伍长度比一个方向的长度大,则权值减去长度差的绝对值;反之则加长度差的绝对值。 #includ...
  • u014552756
  • u014552756
  • 2016-05-02 22:10:50
  • 264

The best seat in ACM contest

目录 问题描述 样例输入输出 问题分析 代码实现 问题描述 Cainiao is a university student who loves ACM contest v...
  • lishang6257
  • lishang6257
  • 2018-03-22 20:43:23
  • 4

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...
  • zhao_1566
  • zhao_1566
  • 2014-04-28 09:46:05
  • 672

SOJ 2409 The Best Seat in ACM Contest (BFS)

题目描述 Cainiao is a university student who loves ACM contest very much. It is a festival for him once...
  • u010857889
  • u010857889
  • 2014-03-19 13:06:33
  • 368

The Best Seat in ACM Contest

一开始把行和列弄反了,结果总是不对,到最后总是找出来了。#include int y[107][107]; int z[107][107]; int m,n; int count=0,number=0...
  • Dinivity123
  • Dinivity123
  • 2013-02-24 13:36:19
  • 466

[ACM]The Best Seat in ACM Contest

题目描述 Cainiao is a university student who loves ACM contest very much. It is a festival for him ...
  • sr19930829
  • sr19930829
  • 2013-06-01 20:43:54
  • 1243

sdut2409 The Best Seat in ACM Contest

The Best Seat in ACM Contest Time Limit: 1000MS Memory limit: 65536K 题目描述 Cainiao is a universit...
  • a197p
  • a197p
  • 2015-04-12 21:12:49
  • 361

第三届山东省ACM The Best Seat in ACM Contest

#include #include #include using namespace std; int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}}; int mai...
  • u014665013
  • u014665013
  • 2016-05-04 15:14:57
  • 532

省赛 The Best Seat in ACM Contest

The Best Seat in ACM Contest Time Limit: 1000MS Memory limit: 65536K 题目描述 Cainiao is a universit...
  • fghdvbgt
  • fghdvbgt
  • 2013-02-24 14:19:41
  • 408
    个人资料
    专栏达人 持之以恒
    等级:
    访问量: 37万+
    积分: 1万+
    排名: 2000
    寻找 Qianqian 遇见 就是幸运
    博客专栏
    最新评论