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

题意:求给出图的表面积,不包括底面

///1085422276
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll;
#define mem(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,127,sizeof(a));
#define TS printf("111111\n");
#define FOR(i,a,b) for( int i=a;i<=b;i++)
#define FORJ(i,a,b) for(int i=a;i>=b;i--)
#define READ(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define inf 100000
inline ll read()
{
    ll x=0,f=1;
    char ch=getchar();
    while(ch<‘0‘||ch>‘9‘)
    {
        if(ch==‘-‘)f=-1;
        ch=getchar();
    }
    while(ch>=‘0‘&&ch<=‘9‘)
    {
        x=x*10+ch-‘0‘;
        ch=getchar();
    }
    return x*f;
}
//****************************************
#define maxn 100+5
int ss[4][2]={-1,0, 0,-1, 1,0, 0,1};
int a[maxn][maxn],n,m;
bool check(int x,int y){
if(x<=0||y<=0||x>n||y>m)return 1;
else return 0;
}
int main(){

   int T;
   scanf("%d",&T);
   while(T--){
        mem(a);
       ll sum=0;
        ll tmp=0;
       ll ans=0;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            scanf("%d",&a[i][j]);
            if(a[i][j])
            tmp=tmp+(a[i][j]-1);
            sum+=a[i][j];
            if(a[i][j])ans++;
        }
    }
    sum*=6;
   sum-=ans;
   ans=0;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
                if(a[i][j]!=0)
            for(int k=0;k<4;k++){
                int xx=i+ss[k][0];
                int yy=j+ss[k][1];
                if(check(xx,yy))continue;
                if(a[xx][yy]) {ans+=(min(a[i][j],a[xx][yy]));}
            }
        }
    }
  //  cout<<sum<<endl;
  //cout<<ans/2+tmp<<endl;
     ans/=2;
    ans+=tmp;
    ans*=2;
    //cout<<ans<<endl;
    sum=sum-ans;
    printf("%I64d\n",sum);
   }
  return 0;
}

代码

时间: 2024-08-05 13:54:52

HDU 5538/ 2015长春区域 L.House Building 水题的相关文章

Travel(HDU 5441 2015长春区域赛 带权并查集)

Travel Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2404    Accepted Submission(s): 842 Problem Description Jack likes to travel around the world, but he doesn’t like to wait. Now, he is tr

HDU 5533/ 2015长春区域 G.Dancing Stars on Me 暴力

Dancing Stars on Me Problem Description The sky was brushed clean by the wind and the stars were cold in a black sky. What a wonderful night. You observed that, sometimes the stars can form a regular polygon in the sky if we connect them properly. Yo

HDU 5328(2015多校4)-Problem Killer(水题)

题目地址:HDU 5328 题意:在一个长度为n的序列中取出连续的k个数,让这k个数组成等差数列或者等比数列,问这样的k最大可以是多少. Ps:注意用double搞,因为等比数列求公比相除可能为小数. #include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <sstream> #i

hdu 5288||2015多校联合第一场1001题

http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now OO want to know ∑i

hdu 1012:u Calculate e(数学题,水题)

u Calculate e Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 28686    Accepted Submission(s): 12762 Problem Description A simple mathematical formula for e iswhere n is allowed to go to infinit

HDU 5135 Little Zu Chongzhi&#39;s Triangles(简单水题)

题目链接: 戳我 题目大意: 给一堆 木棍,用这些木棍组成三角形,要组成的所有的三角形的面积和最大,不一定要用完所有的木棍. 样例解释: 3 //三个棍子 1 1 20   // 每个棍子的长度,自然,这三个棍子不可能组成三角形,故输出 0.00 7          // 7个棍子 3 4 5 3 4 5 90 // 组成两个三角形(3, 3 4)和(4, 4, 5),面积和即为13.64 0   // 输出 0 退出 解题思路: 本来不想写题解的,因为太水了,,,,,,, 可是看到 谷歌搜出

HDU 5131 Song Jiang&#39;s rank list(水题)

Song Jiang's rank list Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others) Total Submission(s): 259    Accepted Submission(s): 134 Problem Description <Shui Hu Zhuan>,also <Water Margin>was written by Shi Nai'

2015长春区域赛赛后总结

比赛时间:2015.10.18 队名:哆啦小黄埋(alone kampai UMR) 成员:ST,QL,WC 解出题目:两道 网络赛的时候并没有出线,老师争取到了女队名额,才有了参加区域赛的机会(谢谢老师么么哒~ 这次的比赛打铁没有什么可怨的,实力不足+比赛策略不当+心里素质差,每一条都是超级致命的(哭 过了的两道水题,L和F,L是经过ST和WC讨论之后1A的,F是我和ST讨论过敲得,ST去看其他题,而我就在一直卡题.由于代码奇葩,队友都看不懂,只能干着急+出数据,所以只能自己调试,WA好多发,

hdu 5443 (2015长春网赛G题 求区间最值)

求区间最值,数据范围也很小,因为只会线段树,所以套了线段树模板=.= Sample Input3110011 151 2 3 4 551 21 32 43 43 531 999999 141 11 22 33 3 Sample Output1002344519999999999991 1 # include <iostream> 2 # include <cstdio> 3 # include <cstring> 4 # include <algorithm>