Input
The first line contains an integer T indicating the total number of test cases.
First line of each test case is a line with two integers n,m.
The n lines
that follow describe the array of Nyanko-san's blueprint, the i-th
of these lines has m integers ci,1,ci,2,...,ci,m,
separated by a single space.

1≤T≤50
1≤n,m≤50
0≤ci,j≤1000

 
Output
For each test case, please output the number of glass units you need to collect to meet Nyanko-san's requirement in one line.
 
Sample Input
2
3 3
1 0 0
3 1 2
1 1 0
3 3
1 0 1
0 0 0
1 0 1
 
Sample Output
30
20

题意:给你n*m的地方,每个点有一个数组x代表这的高度,求这个立体的表面积

思路:求出顶部面积,在计算每个柱子比周围柱子高多少即可

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <vector>
#include <algorithm>
#include <functional>
typedef long long ll;
using namespace std; int tmap[55][55];
int dir[][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; int main()
{
int T,n,m;
scanf("%d",&T);
while(T--)
{
ll ans = 0;
scanf("%d%d",&n,&m);
memset(tmap,0,sizeof(tmap));
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= m; j++)
{
scanf("%d",&tmap[i][j]);
if(tmap[i][j] > 0)
ans ++;
}
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= m; j++)
{
for(int k = 0;k < 4;k++)
{
int tx = i+dir[k][0];
int ty = j+dir[k][1];
if(tmap[i][j] > tmap[tx][ty])
ans += tmap[i][j] - tmap[tx][ty];
}
}
printf("%lld\n",ans);
}
return 0;
}

  

hdu 5538(水)的更多相关文章

  1. HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Subm ...

  2. HDU 5538 L - House Building 水题

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

  3. hdu 5538 House Building(长春现场赛——水题)

    题目链接:acm.hdu.edu.cn/showproblem.php?pid=5538 House Building Time Limit: 2000/1000 MS (Java/Others)   ...

  4. HDU 5538 (水不水?)

    House Building Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) ...

  5. HDU 5538/ 2015长春区域 L.House Building 水题

    题意:求给出图的表面积,不包括底面 #include<bits/stdc++.h> using namespace std ; typedef long long ll; #define ...

  6. hdu 4464 水

    http://acm.hdu.edu.cn/showproblem.php?pid=4464 现场赛总会有水题,这就是最水的一道,预计也就是能当高校的上机题,保研用,呵呵~~~ #include &l ...

  7. HDU 5538 House Building(模拟——思维)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5538 Problem Description Have you ever played the vi ...

  8. HDU 5391 水题。

    E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  9. hdu 1544 水题

    水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...

随机推荐

  1. Django 模版语法

    一.简介 模版是纯文本文件.它可以产生任何基于文本的的格式(HTML,XML,CSV等等). 模版包括在使用时会被值替换掉的 变量,和控制模版逻辑的 标签. {% extends "base ...

  2. Session的过期时间如何计算?

    在生成session的时候,会设置一个session过期时间.session的过期时间并不是从生成session对象开始计算,超过过期时间,session就失效了. 而是每当一个浏览器请求,sessi ...

  3. IDEA之Jrebel插件激活

    问题: 码农日常中,热部署是必不可少的,而jrebel插件很好的实现热部署功能. IDEA下载jrebel插件,可以免费试用15天,但之后就无法使用.因为Jrebel是收费的. 解决方法: 楼主也是百 ...

  4. CentOS7 防火墙firewalld详细操作

    1.firewalld的基本使用 启动: systemctl start firewalld 查看状态: systemctl status firewalld  停止: systemctl disab ...

  5. clang++ 链接问题 和 VS Code

    clang++ 链接问题 和 VS Code 如果你在windows上使用clang 并且同时安装有vs和mingw, clang链接是会自动使用msvs, 链接时会有LINK error LINK ...

  6. 【转】支持向量机(SVM)

    什么是支持向量机(SVM)? SVM 是一种有监督的机器学习算法,可用于分类或回归问题.它使用一种称为核函数(kernel)的技术来变换数据,然后基于这种变换,算法找到预测可能的两种分类之间的最佳边界 ...

  7. 《网络》:设置三个密码:通过console口连接设备,进入特权模式,登录Telnet

    软件:Cisco Packet Tracer Instructor 软件下载链接在上一篇文章中. 内容:通过设置三个密码,熟悉采用Telnet方式配置交换机的方法. 细节说明:计算机的IP地址和交换机 ...

  8. GIT入门笔记(13)- GUI GIT

  9. api-gateway实践(04)新服务网关 - 新手入门

    一.网关引擎环境 1.下载代码 2.搭建环境 3.打包部署 二.配置中心环境 1.下载代码 2.搭建环境 3.打包部署 三.创建业务实例 1.以租户身份登录配置中心,注册 group.version. ...

  10. docker实践4

    我的docker学习笔记4-守护式容器   $docker run -i -t ubuntu /bin/bash $ctrl-p 或 ctrl-q # 转到后台   $docker ps $docke ...