【hdu5538】【2015ACM/ICPC亞洲區長春站 】House Building 題意&題解&程式碼
題目連結:
http://acm.hdu.edu.cn/showproblem.php?pid=5538
題意:
給你積木圖的俯檢視,輸入資料表示(i,j)位置放了一個高度為h[i][j]的積木,求表面積(不算下表面!!!)。
題解:
水題一個,像我這樣的蒟蒻都能快速想到題解。。。具體看程式碼實現就懂了。
程式碼:
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int T,n,m,h[55 ][55];
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&m);
memset(h,0,sizeof(h));
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
scanf("%d",&h[i][j]);
int ans=0;
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
{
if (h[i][j]!=0) ans++;
if (h[i][j]>h[i-1][j]) ans+=h[i][j]-h[i-1][j];
if (h[i][j]>h[i+1][j]) ans+=h[i][j]-h[i+1][j];
if (h[i][j]>h[i][j-1]) ans+=h[i][j]-h[i][j-1];
if (h[i][j]>h[i][j+1]) ans+=h[i][j]-h[i][j+1 ];
//cout<<i<<' '<<j<<' '<<ans<<endl;
}
printf("%d\n",ans);
}
}
相關推薦
【hdu5538】【2015ACM/ICPC亞洲區長春站 】House Building 題意&題解&程式碼
題目連結: http://acm.hdu.edu.cn/showproblem.php?pid=5538 題意: 給你積木圖的俯檢視,輸入資料表示(i,j)位置放了一個高度為h[i][j]的積木,
【hdu5534】【2015ACM/ICPC亞洲區長春站】Partial Tree 題意&題解&程式碼
題目連結: http://acm.hdu.edu.cn/showproblem.php?pid=5534 題意: 構造一棵有n個節點的數,f[i]表示度數(入度+出度)為i的節點的點權,給出所有的
【hdu 5527】 [2015ACM/ICPC亞洲區長春站] Too Rich 貪心
Too Rich Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 673 Accept
【套題】2015ACM/ICPC亞洲區長春站 HDU5532 5533 5534 5536 5538
水幾個題,熟悉一下鍵盤。。。 HDU5532AlmostSortedArray 題意:ASA定義為,僅去掉一個(OneandOnlyOne)元素後陣列是非降序或者非升序。 題解:很明顯,判斷一個序列是否有序可以通過判斷其LongestNonDecreasing
@2015ACM/ICPC亞洲區長春站-重現賽(感謝東北師大) @HDU5534 (Dp,完全揹包)
題目描述 In mathematics, and more specifically in graph theory, a tree is an undirected graph in which any two nodes are connected by exactly
HDU 5532 Almost Sorted Array(最長非遞減子序列 模板題)——2015ACM/ICPC亞洲區長春站
Almost Sorted Array Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Problem Description We are
[hdu 5521][2015ACM/ICPC亞洲區長春站] House Building
House Building Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 624
HDU 5531 Rebuild(三分)——2015ACM/ICPC亞洲區長春站
傳送門 RebuildTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 2483 Accep
[hdu 5534]2015ACM/ICPC亞洲區長春站 Partial Tree 完全揹包
Partial Tree Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 674 Ac
【解題報告】2015ACM/ICPC亞洲區瀋陽站
題目連結 B. Bazinga(HDU5510) 思路 設第i個字串儲存在ss[i][]中。本題最直觀最樸素的做法是列舉兩個字串ss[i]和ss[j] (i+1≤j),再用KMP演算法匹配這兩個字串。首先從大到小列舉j,若對某個ss[j]存在某個s
2015ACM/ICPC亞洲區上海站【solved:4 / 12】
A是。抽空要寫掉的bronze-silver題!!! D是左偏樹並查集。以後有空再看吧。 -update:2017年10月25日14:59:07。 A - An Easy Physics Problem HDU - 5572(計算幾何) //先
HDU 5512 Pagodas(2015ACM/ICPC亞洲區瀋陽站-重現賽(感謝東北大學))
Pagodas Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3502 &nb
2015ACM/ICPC亞洲區瀋陽站-——Pagodas(簡單博弈)
nn pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 11 to nn. However, only
2015ACM/ICPC亞洲區瀋陽站---重現賽感想
今天打的差極了,,就A了兩個題,,今早九點開始,還真是有點困困的、、今天來的還有點晚。 先看的BD題,兩題並行,然後先敲的B,未果,D替代紙上完成。然後敲了D題,,A了之後就在做B和M,我先做的M,果然存圖沒想到,,然後就亂交了一發,,想象的T,結果RE了,,,遂放棄。
2015ACM/ICPC亞洲區瀋陽站---題解
思路:就暴力匹配就好了,然後加一個剪枝,如果這個字串是某個字串的子串的話,就不用檢查他了就是個思維,還用了KMP,,其實不用也可以,用strstr()過的時間更短。。 程式碼: #inclu
hdu5512 Pagodas(2015ACM/ICPC亞洲區瀋陽站-重現賽(感謝東北大學) )
n pagodas were standing erect in Hong Jue Si between the Niushou Mountain and the Yuntai Mountain, labelled from 1 to n. However, only two of them (labe
【BestCoder Round #81 (div.2)】【HDU5670&5671&5672】題意&題解&程式碼(C++)
第一次bc做了3道題,雖然最後一道題是聽了別人的思路,果然我還是太弱。。。 div2t1(hdu5670): 題意: 有一個機器,它有 m(2≤m≤30) 個彩燈和一個按鈕。每按下按鈕時,最右邊的彩燈會發生一次變換。變換為: 如果當前狀態為紅色,它將變
2015ACM/ICPC亞洲區瀋陽站 HDU
Ladies and gentlemen, please sit up straight.Don't tilt your head. I'm serious. For n given strings S1,S2,⋯,Sn, labelled from 1 to n, you should find
HDU 5538 House Building(2015ACM/ICPC亞洲區長春&&幾何體表面積)
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 o
【推導】計蒜客17116 2017 ACM-ICPC 亞洲區(西安賽區)網絡賽 C. Sum
數位 std acm-icpc 多少 icp 正整數 cst space 超過 題意:S(x)被定義為x的十進制表示下的數位之和。給你x,讓你找一個正整數k,使得S(kx)能被233整除。k不超過2千位。 由於x不超過1000000,不論x是多少,10000000重復23