Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=5538
Test instructions: There is a three-dimensional graph, first give the plan is a n*m rectangle, each position has a different number of squares, a[i][j] represents the current position has a[i][j] a block, is the height of the three-dimensional graphics, the surface area, the side length of the block is 1;
Simple water problem, a direct look at each location of the block has several faces can be leaked out on it;
#include <stdio.h>#include<string.h>#include<algorithm>#include<iostream>#include<vector>#include<queue>#include<Set>using namespacestd;#defineMet (A, b) memset (A, B, sizeof (a))#defineN 105#defineINF 0x3f3f3f3ftypedefLong LongLL;intdir[4][2] = { {1,0}, {-1,0}, {0,1}, {0,-1} };intA[n][n];intMain () {intT, N, M; LL ans; scanf ("%d", &T); while(t--) {Met (A,0); scanf ("%d%d", &m, &N); for(intI=1; i<=m; i++) { for(intj=1; j<=n; J + +) scanf ("%d", &A[i][j]); } ans=0; for(intI=1; i<=m; i++) { for(intj=1; j<=n; J + +) { if(A[i][j] = =0)Continue; Ans+=1;///one of the top layers; for(intk=0; k<4; k++) { intx = i+dir[k][0]; inty = j+dir[k][1]; Ans+ = Max (0, A[i][j]-A[x][y]); }}} printf ("%i64d\n", ans); } return 0;}
View Code
House Building---hdu5538 (for surface water problems)