HDU 5538/ 2015长春区域 L.House Building 水题
题意:求给出图的表面积,不包括底面
///
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,127,sizeof(a));
#define TS printf("111111\n");
#define FOR(i,a,b) for( int i=a;i<=b;i++)
#define FORJ(i,a,b) for(int i=a;i>=b;i--)
#define READ(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define inf 100000
inline ll read()
{
ll x=,f=;
char ch=getchar();
while(ch<''||ch>'')
{
if(ch=='-')f=-;
ch=getchar();
}
while(ch>=''&&ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
}
//****************************************
#define maxn 100+5
int ss[][]={-,, ,-, ,, ,};
int a[maxn][maxn],n,m;
bool check(int x,int y){
if(x<=||y<=||x>n||y>m)return ;
else return ;
}
int main(){ int T;
scanf("%d",&T);
while(T--){
mem(a);
ll sum=;
ll tmp=;
ll ans=;
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
scanf("%d",&a[i][j]);
if(a[i][j])
tmp=tmp+(a[i][j]-);
sum+=a[i][j];
if(a[i][j])ans++;
}
}
sum*=;
sum-=ans;
ans=; for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
if(a[i][j]!=)
for(int k=;k<;k++){
int xx=i+ss[k][];
int yy=j+ss[k][];
if(check(xx,yy))continue;
if(a[xx][yy]) {ans+=(min(a[i][j],a[xx][yy]));}
}
}
}
// cout<<sum<<endl;
//cout<<ans/2+tmp<<endl;
ans/=;
ans+=tmp;
ans*=;
//cout<<ans<<endl;
sum=sum-ans;
printf("%I64d\n",sum);
}
return ;
}
代码
HDU 5538/ 2015长春区域 L.House Building 水题的更多相关文章
- HDU 5538 L - House Building 水题
L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- HDU 5534/ 2015长春区域H.Partial Tree DP
Partial Tree Problem Description In mathematics, and more specifically in graph theory, a tree is an ...
- Travel(HDU 5441 2015长春区域赛 带权并查集)
Travel Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Su ...
- HDU 5536/ 2015长春区域 J.Chip Factory Trie
Chip Factory Problem Description John is a manager of a CPU chip factory, the factory produces lots ...
- HDU 5533/ 2015长春区域 G.Dancing Stars on Me 暴力
Dancing Stars on Me Problem Description The sky was brushed clean by the wind and the stars were col ...
- hdu 5288||2015多校联合第一场1001题
pid=5288">http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a ar ...
- HDU 5832 A water problem (带坑水题)
A water problem 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5832 Description Two planets named H ...
- HDU 5889 Barricade(最短路+最小割水题)
Barricade Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total ...
- hdu 5443 (2015长春网赛G题 求区间最值)
求区间最值,数据范围也很小,因为只会线段树,所以套了线段树模板=.= Sample Input3110011 151 2 3 4 551 21 32 43 43 531 999999 141 11 2 ...
随机推荐
- Tomcat发布项目,域名访问
域名访问项目 1,去掉访问路径的端口号: 找到 Tomcat 下的 conf 文件中的 server.xml,找到 8080 修改成 80, 2,项目绑定域名: <Host name=" ...
- C# 多线程系列(六)
同步 当多个线程共享一些数据的时候,我们就需要使用同步技术,确保一次只有一个线程访问合改变共享状态.注意,同步问题与争用和死锁有关. 例: ; static void Add() { ; i < ...
- Android Studio 关于build.gradle配置问题
当导入一个Android Project时,会出现很多版本的问题,导入前先删除 .idea文件 .gradle文件 ,gradle文件(与.gradle区分,导入时Android Studio会提示重 ...
- drupal 8——图片组(list)在前台的显示顺序在登录状态和非登录状态不同
问题描述:该页面是通过view来输出的,然而,登录状态下其页面中的图片组输出顺序是乱序的,而非登录状态下则根据id值升序输出. 原因:在原view配置页面中,没有配置默认的排序字段 解决方案:在vie ...
- Centos永久路由添加教程
Centos 永久路由添加,一张图看懂全部 blog地址:http://www.cnblogs.com/caoguo
- R语言图表
条形图 在R语言中创建条形图的基本语法是 barplot(H, xlab, ylab, main, names.arg, col) H是包含在条形图中使用的数值的向量或矩阵 xlab是x轴的标签 yl ...
- CAD插入图块前修改图块文字
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...
- 一步一步教你用IntelliJ IDEA 搭建SSM框架(2)——配置mybatis-geneator
我们要搭建整个SSM框架,所以要继续上篇文章没有完成的工作,下面配置mybatis-geneator,自动生成mybatis代码. 在上篇文章中的pom.xml的配置文件中已经加了mybatis-ge ...
- springboot配置多数据源(JdbcTemplate方式)
在实际开发中可能会遇到需要配置多个数据源的情况,比如:需要使用多个host.需要使用多种数据库(MySql.Oracle.SqlServer…) 如果使用springboot开发,可做如下配置: Co ...
- [转载]java中Date,SimpleDateFormat
一.Java中的日期概述: 日期在Java中是一块非常复杂的内容,对于一个日期在不同的语言国别环境中,日期的国际化,日期和时间之间的转换,日期的加减运算,日期的展示格式都是非常复杂的问题. 在Java ...