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 ...
随机推荐
- UDP网络程序实例
根据前面所讲的网络编程的基础知识,以及UDP网络编程的特点,下面创建一个广播数据报程序.广播数据报是一种较新的技术,类似于电台广播,广播电台需要在指定的波段和频率上广播信息,收听者也要将收音机调到指定 ...
- 《Java编程的逻辑》第一部分 编程基础与二进制
- [Windows Server 2003] 服务器安全加固
★ 欢迎来到[护卫神·V课堂],网站地址:http://v.huweishen.com★ 护卫神·V课堂 是护卫神旗下专业提供服务器教学视频的网站,每周更新视频.★ 本节我们将带领大家:服务器安全加固 ...
- Eclipse 使用前的配置
一,修改eclipse对jdk的依赖项 1.查看设置的编译器编译版本:设置成本地jdk一致的版本 点击窗口->首选项 找到java 选择编辑器,查看现在的编译jdk版本 改成本地jdk版本 jd ...
- UpLoadify在IE下兼容问题
一.在IE9.IE10不能点击的问题解决 解决方法:进入uploadify的js文件中,搜索SWFUpload.prototype.getFlashHTML,找到它对应的语句,将方法全部替换为以下内容 ...
- c++ map: 根据value逆向查找key
#include <iostream> #include <map> #include <algorithm> #include <vector> #i ...
- Bequeath Connection and SYS Logon
The following example illustrates how to use the internal_logon and SYSDBA arguments to specify the ...
- Django 初学
一.什么是web框架 框架,即framework ['fremwɝk],特指为解决一个开放性问题而设计的具有一定约束性的支撑结构,使用框架可以帮你快速开发特定的系统,简单地说,就是你用别人搭建好的舞 ...
- Problem 28
Problem 28 https://projecteuler.net/problem=28 Starting with the number 1 and moving to the right in ...
- flask_model防止循环引用
1 首先介绍app-model的循环引用 https://www.cnblogs.com/fuzzier/p/7920645.html 2 解决方式 https://www.cnblogs.com/f ...