VJ组队赛->House Building(5538)
来源:互联网 发布:Java毫秒和日期的换算 编辑:程序博客网 时间:2024/05/17 04:35
额..... 题目太长我就不贴了,就是给你一个二维数组,a[i][j]代表(i,j)位置木块的高度,然后让你求 i x j 这个范围内所有木块的表面积之和,具体如下图
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 integersn,m .
Then 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
First line of each test case is a line with two integers
The
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
23 31 0 03 1 21 1 03 31 0 10 0 01 0 1
Sample Output
其实这道题,,,比赛的时候看了一段时间,结果没想到怎么做,不过很快就被队长一发解决了~我知道要扫描每个坐标的上下左右和顶部,不过我真的没想到,,原来扫描完直接加上高度差就是面积啊(@_@),第一次这样求表面积... 一道水题吧... QAQ3020
#include <iostream>#include <cstring>using namespace std;const int N = 1e3 + 5;int main(){int a[N][N];int t,n,m;cin >> t;while(t--){cin >> n >> m;memset(a,0,sizeof(a));int sum = 0;int i,j;for(i = 1; i <= n; i++)for(j = 1; j <= m; j++){cin >> a[i][j];if(a[i][j] > 0) //顶部sum ++;}for(i = 1; i <= n; i++)for(j = 1; j <= m; j++){if(a[i][j] > a[i][j-1]) //左边sum += a[i][j]-a[i][j-1];}for(i = 1; i <= n; i++)for(j = 1; j <= m; j++){if(a[i][j] > a[i][j+1]) //右边sum += a[i][j]-a[i][j+1];}for(i = 1; i <= n; i++)for(j = 1; j <= m; j++){if(a[i][j] > a[i-1][j]) //上边sum += a[i][j]-a[i-1][j];}for(i = 1; i <= n; i++)for(j = 1; j <= m; j++){if(a[i][j] > a[i+1][j]) //下边sum += a[i][j]-a[i+1][j];}cout << sum << "\n";}return 0;}
阅读全文
0 0
- VJ组队赛->House Building(5538)
- VJ 122106 C-House Building
- VJ组队赛->Chip Factory(5536)
- VJ组队赛->Almost Sorted Array(5532)
- VJ组队赛->Dancing Stars on Me(5533)
- hdu 5538House Building(长春现场赛)
- hdu 5538 House Building(长春现场赛)
- hdu 5538 House Building(水)
- HDU 5538 House Building (简单模拟)
- HDU 5538 House Building(分类暴力)
- HDU 5538 House Building (水题)
- HDU 5538 House Building (水)
- HDU 5538 House Building (求表面积)
- hdu 5538 House Building
- HDU 5538 house building
- 【HDU】 5538 House Building
- HDU 5538 House Building
- HDOJ 5538 House Building
- SIFT、SURF 、HOG 讲解博文
- springmvc简单使用
- Unity官方实例教程 Roll-a-Ball 学习笔记
- java @Override错误的解决办法
- 基于PYTHON requests包,代理ip+header+延时爬取的简单实现
- VJ组队赛->House Building(5538)
- 百度编辑器上传视频以及视频编辑器预览bug解决
- java中protect属性用法总结
- java多态理解
- 显示一个饼图
- Tensorflow基础知识总结(2)
- jsp验证码
- All of LeetCode
- ScrollView与其子控件事件冲突的解决,以及怎样去禁止ScrollView的惯性滑动