题意:求给出图的表面积,不包括底面

///
#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 水题的更多相关文章

  1. HDU 5538 L - House Building 水题

    L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  2. HDU 5534/ 2015长春区域H.Partial Tree DP

    Partial Tree Problem Description In mathematics, and more specifically in graph theory, a tree is an ...

  3. Travel(HDU 5441 2015长春区域赛 带权并查集)

    Travel Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Su ...

  4. HDU 5536/ 2015长春区域 J.Chip Factory Trie

    Chip Factory Problem Description John is a manager of a CPU chip factory, the factory produces lots ...

  5. 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 ...

  6. hdu 5288||2015多校联合第一场1001题

    pid=5288">http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a ar ...

  7. HDU 5832 A water problem (带坑水题)

    A water problem 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5832 Description Two planets named H ...

  8. HDU 5889 Barricade(最短路+最小割水题)

    Barricade Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total ...

  9. hdu 5443 (2015长春网赛G题 求区间最值)

    求区间最值,数据范围也很小,因为只会线段树,所以套了线段树模板=.= Sample Input3110011 151 2 3 4 551 21 32 43 43 531 999999 141 11 2 ...

随机推荐

  1. <form> 标签

    <form method="传送方式" action="服务器文件"> action :浏览者输入的数据被传送到的地方,比如一个PHP页面(save ...

  2. Jupyter(Ipython) Notebook 入门

    upyter Notebook(此前被称为 IPython notebook)是一个交互式笔记本,支持运行 40 多种编程语言. 一般用来编写漂亮的交互式文档. 文学编程的读者不是机器,而是人. 我们 ...

  3. 【PostgreSQL-9.6.3】触发器实例

    1. 创建一个触发器,表中的行在任何时候被插入或更新时,当前用户名和时间也会被标记在该行中.并且它会检查雇员的姓名以及薪水. --创建测试表 CREATE TABLE emp ( empname te ...

  4. servlet-请求重定向

    package servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.ser ...

  5. Tcl之looping

    1 While loop while test body The while command evaluates test as an expression. If test is true, the ...

  6. CaffeMFC:caffe.pb.h(2525): error C2059: syntax error : 'constant'

    下边的语句会报 syntax error : 'constant'. static const DimCheckMode STRICT = V1LayerParameter_DimCheckMode_ ...

  7. Address space layout randomization

    Address space layout randomization (ASLR) is a computer security technique involved in preventing ex ...

  8. Python操作数据库及hashlib模块

    一.hashlib模块 hashlib模块,主要用于加密相关的操作,在python3的版本里,代替了md5和sha模块,主要提供 SHA1, SHA224, SHA256, SHA384, SHA51 ...

  9. chrome浏览器 快捷键设置

    如何设置谷歌浏览器在新窗口中打开链接?如何设置谷歌浏览器在新标签页中打开链接?一.快捷键方式: 1.左键单击 ==> 在当前窗口中打开目标网页. 2.Shift + 左键单击 ==> 在新 ...

  10. JavaFX桌面应用开发-Button(按钮)与事件

    1:Button样式的操作原始代码: package application; import javafx.application.Application;import javafx.scene.Gr ...