HDU 5538 L - House Building 水题
L - House Building
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://acm.hdu.edu.cn/showproblem.php?pid=5538
Description
Have you ever played the video game Minecraft? This game has been one of the world's most popular game in recent years. The world of Minecraft is made up of lots of blocks in a 3D map. Blocks are the basic units of structure in Minecraft, there are many types of blocks. A block can either be a clay, dirt, water, wood, air, ... or even a building material such as brick or concrete in this game.
Figure 1: A typical world in Minecraft.
Nyanko-san is one of the diehard fans of the game, what he loves most is to build monumental houses in the world of the game. One day, he found a flat ground in some place. Yes, a super flat ground without any roughness, it's really a lovely place to build houses on it. Nyanko-san decided to build on a big flat ground, so he drew a blueprint of his house, and found some building materials to build.
While everything seems goes smoothly, something wrong happened. Nyanko-san found out he had forgotten to prepare glass elements, which is a important element to decorate his house. Now Nyanko-san gives you his blueprint of house and asking for your help. Your job is quite easy, collecting a sufficient number of the glass unit for building his house. But first, you have to calculate how many units of glass should be collected.
There are rows and columns on the ground, an intersection of a row and a column is a square,and a square is a valid place for players to put blocks on. And to simplify this problem, Nynako-san's blueprint can be represented as an integer array . Which indicates the height of his house on the square of -th row and -th column. The number of glass unit that you need to collect is equal to the surface area of Nyanko-san's house(exclude the face adjacent to the ground).
⋅1. If you touch a buoy before your opponent, you will get one point. For example if your opponent touch the buoy #2 before you after start, he will score one point. So when you touch the buoy #2, you won't get any point. Meanwhile, you cannot touch buoy #3 or any other buoys before touching the buoy #2.
⋅2. Ignoring the buoys and relying on dogfighting to get point.
If you and your opponent meet in the same position, you can try to
fight with your opponent to score one point. For the proposal of game
balance, two players are not allowed to fight before buoy #2 is touched by anybody.
There are three types of players.
Speeder:
As a player specializing in high speed movement, he/she tries to avoid
dogfighting while attempting to gain points by touching buoys.
Fighter:
As a player specializing in dogfighting, he/she always tries to fight
with the opponent to score points. Since a fighter is slower than a
speeder, it's difficult for him/her to score points by touching buoys
when the opponent is a speeder.
All-Rounder: A balanced player between Fighter and Speeder.
There will be a training match between Asuka (All-Rounder) and Shion (Speeder).
Since the match is only a training match, the rules are simplified: the game will end after the buoy #1 is touched by anybody. Shion is a speed lover, and his strategy is very simple: touch buoy #2,#3,#4,#1 along the shortest path.
Asuka is good at dogfighting, so she will always score one point by dogfighting with Shion, and the opponent will be stunned for T seconds after dogfighting.
Since Asuka is slower than Shion, she decides to fight with Shion for
only one time during the match. It is also assumed that if Asuka and
Shion touch the buoy in the same time, the point will be given to Asuka
and Asuka could also fight with Shion at the buoy. We assume that in
such scenario, the dogfighting must happen after the buoy is touched by
Asuka or Shion.
The speed of Asuka is V1 m/s. The speed of Shion is V2 m/s. Is there any possibility for Asuka to win the match (to have higher score)?
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
HINT
题意
给你一个n*m的空地,空地上有些地方有高为ai的建筑,然后让你在这些建筑的表面涂颜色,问你得花费多少?
底面不算
题解:
直接暴力,水题
代码
#include<iostream>
#include<stdio.h>
#include<cstring>
using namespace std; int a[][];
int dx[]={,-,,};
int dy[]={,,,-};
int main()
{
int t;scanf("%d",&t);
for(int cas=;cas<=t;cas++)
{
memset(a,,sizeof(a));
int n,m;scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
for(int j=;j<=m;j++)
scanf("%d",&a[i][j]);
int ans = ;
for(int i=;i<=n;i++)
{
for(int j=;j<=m;j++)
{
if(a[i][j])
ans++;
for(int k=;k<;k++)
{
int x = i+dx[k];
int y = j+dy[k];
if(a[i][j]>a[x][y])
ans+=a[i][j]-a[x][y];
}
}
}
printf("%d\n",ans);
}
}
HDU 5538 L - House Building 水题的更多相关文章
- HDU 5538/ 2015长春区域 L.House Building 水题
题意:求给出图的表面积,不包括底面 #include<bits/stdc++.h> using namespace std ; typedef long long ll; #define ...
- HDU 5578 Friendship of Frog 水题
Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- HDU 5590 ZYB's Biology 水题
ZYB's Biology Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...
- hdu 1051:Wooden Sticks(水题,贪心)
Wooden Sticks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- hdu 1005:Number Sequence(水题)
Number Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- hdu 1018:Big Number(水题)
Big Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- hdu 2041:超级楼梯(水题,递归)
超级楼梯 Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Su ...
- HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)
Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or ...
- HDOJ(HDU) 2090 算菜价(简单水题、)
Problem Description 妈妈每天都要出去买菜,但是回来后,兜里的钱也懒得数一数,到底花了多少钱真是一笔糊涂帐.现在好了,作为好儿子(女儿)的你可以给她用程序算一下了,呵呵. Input ...
随机推荐
- 【Servlet】doGet()与doPost()的区别
doGet与doPost的区别 .Servlet接口只定义了一个服务方法--service .当发出客户端请求时,调用service方法并传递一个请求和响应对象 .使用时经常在doPost()中调用d ...
- POJ 1423 Big Number
题意:求n阶乘的位数. 解法:斯特林公式,,然后取log10就是位数了,因为精度问题需要化简这个式子,特判1. 代码: #include<stdio.h> #include<iost ...
- 浅谈Linux容器和镜像签名
导读 从根本上说,几乎所有的主要软件,即使是开源软件,都是在基于镜像的容器技术出现之前设计的.这意味着把软件放到容器中相当于是一次平台移植.这也意味着一些程序可以很容易就迁移,而另一些就更困难. 我大 ...
- [Papers]MHD, $\pi$, Lorentz space [Suzuki, DCDSA, 2011]
$$\bex \sen{\pi}_{L^{s,\infty}(0,T;L^{q,\infty}(\bbR^3))} +\sen{{\bf b}}_{L^{\gamma,\infty}(0,T;L^{\ ...
- [Everyday Mathematics]20150115
试计算积分 $$\bex \int_{-\pi}^\pi \frac{\sin nx}{(1+2^x)\sin x}\rd x, \eex$$ 其中 $n$ 是自然数.
- div模拟的下拉框特效jquery
从网上找来的,感觉不错就拿来分享下 <style type="text/css"> body, ul, li { margin: 0; padding: 0; font ...
- springmvc基础知识
springmvc框架,类似于struts,主要用于MVC的控制层 spring的简单配置(非注解): spring-mvc.xml文件(springMVC框架的基本文件) web.xml文件 ja ...
- XNA Game Studio 4.0 Programming 随便读,随便记 “Rendering Text”
在游戏中,通常要与玩家交流,比如分数,提示等.这就需要一种新的精灵, 它就叫SpritFont.下面先将其增加到项目中: 项目 -----> 添加新项-----> Sprite Font ...
- 《Genesis-3D开源游戏引擎完整实例教程-2D射击游戏篇05:角色中弹》
5.角色中弹 概述: 为了使游戏具有挑战性,大部分游戏设定中,游戏角色都有生命限制.即在游戏中,由于玩家的操控操控不当,导致游戏角色死亡游戏终止.打飞机游戏也不例外,当敌人击中角色的时候,角色宣判死亡 ...
- Jquery类级别与对象级别插件开发
jQuery插件的开发包括两种: 一种是类级别的插件开发,即给jQuery添加新的全局函数,相当于给jQuery类本身添加方法.jQuery的全局函数就是属于jQuery命名空间的函数,另一种是对象级 ...