House Building---hdu5538 (for surface water problems)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.