注意:
求一个立方体堆积的多面体的全部表面积。不能简单通过前后左右上下6个面的投影得到,要考虑中间可能有凹陷,凹陷部分会多出表面积。
应当使用减法:先求出所有小方块的6表面积之和,假设它们前后左右不重叠,然后遍历行和列,按照前后和左右,相邻两个方块,高度小的一边会被重叠掉(记高度小的高度为x),应减去2*x。
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
int Solution(int n, int m, std::vector<std::vector<int> > &vec){
int s