Gym - 101246B 3D City Model

Bellhop海底地形仿真入门:从MATLAB数据导入到3D可视化(附避坑指南) 本文详细介绍了Bellhop海底地形仿真的完整工作流程,从MATLAB数据导入、清洗与坐标转换,到构建.bty输入文件,再到生成高质量3D可视化结果。文章重点解析了数据格式、深度值正负、单位统一及坐标投影等关键环节的避坑指南,并提供了可复用的代码片段,帮助用户高效完成从原始数据到仿真成果的转换。 阅读详情
A题来自codeforces上的一题  原题地址
B. 3D City Model
time limit per test
1.0 s
memory limit per test
256 MB
input
input.txt
output
output.txt

A city is built on the top of a rectangular n × m grid where all the grid cells are equal squares. Each of the n·m grid cells can serve as a foundation of a single building in the city. A building is represented as a number of 1 × 1 × 1 cubes stacked on the top of each other. The cube that lays in the foundation of a building entirely occupies a single cell on the grid. It is clear that adjacent buildings can share a wall or a part of it. Typical cities can be seen on the image below.

The King of Berland has a 3D model of the capital city in his office. This model was made on a special 3D-printer out of plastic. It represents a layout of the capital city, but the scale is smaller, so it's very convenient for the King to examine the model without having to visit the city itself. The King is bored though because the model is colorless, so he wants to paint the model. To calculate the exact amount of required paint he should know the total area of the model's surface.

You have to help the King and write a program that will calculate the required surface area of the given model. While calculating the surface area you should count not only the side surfaces, but also the areas of the top and bottom facets.

The model is given to you as n × m matrix of digits. A digit in the j-th position of the i-th row stands for the height of the building with its foundation in cell (i, j) of the model. If the corresponding digit is equal to "0", it means there is no building built on the top of this cell.

Input

The first line of input contains a pair of integers n, m (1 ≤ n, m ≤ 100), where n — amount of rows in the given grid, m — amount of columns. The following n lines contain the description of the model. These n lines contain m digits each representing heights of the buildings. It's guaranteed that the given matrix contains at least one non-zero digit.

Output

Output the only positive integer — surface area of the model.

Examples
input
3 3
111
212
111
output
38
input
3 4
1000
0010
0000
output
12
Note

The first sample test corresponds to the leftmost picture from the problem statement.

大致题意就是 给出立方体的形状 求该几何体的表面积

我的思想是 (1)每次读入矩阵的时候 同时计数有多少个小立方体  记为sum

                   (2)用for循环去判断小立方体之间重合的有多少块  (三个方向都要判断) 记为ans

                   (3)运用数学公式  sum*6-ans*2 (每个小立方体的基础面积为6  一块重合面积使两方都各少一块)

下面放一下代码

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;
int x[1005][1005];
char y[1005][1005];
int main()
{
    int m,n;
    char a;
    int sum=0;
    int ans=0;
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    cin >> n >> m;
    memset(x,0,sizeof x);
    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++)//读入矩阵
        {
            cin>>a;
            a-='0';
            x[i][j]=a;
        }
    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++)//对小方块进行计数
        {
            sum=sum+x[i][j];
        }
    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++)//横向 如果有重合部分就计数
        {
            ans+=min(x[i][j],x[i][j+1]);//重合部分算两者中小的面积
        }
    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++)
        {
            ans+=min(x[i+1][j],x[i][j]);
        }
    for (int i=0; i<n; i++)
        for (int j=0; j<m; j++)
            if (x[i][j]>1)
                ans+=(x[i][j]-1);//高度大于1时 竖直方向的重合部分 为高度减一
    int h=sum*6-ans*2;//每一块基础表面积为6 减去重合部分的 *2
    cout << h <<endl;
    return 0;
}
前一次交题的时候卡在 test 10 
想了好久不知道错哪里了
后来 一个学长给了一个他的样例 
我测试了一下 发现...我的行列标记反了 唉( ̄m ̄)
以后 再遇到矩阵题目要注意一下了...
高级技能-高可用和容灾-两地三中心、异地多活架构 两地三中心和异地多活是当前主流的跨地域高可用架构方案。两地三中心通过生产中心、同城灾备和异地灾备的组合,提供多级容灾能力,适合对数据安全要求高的行业。异地多活则采用单元化设计,多个站点同时服务,提升资源利用率,但需解决网络延迟、数据冲突等挑战。两种架构在RTO/RPO、一致性、改造成本等方面各具特点,企业应根据业务规模、一致性要求和预算进行选择,可考虑从同城双活起步,逐步向异地多活演进。混合架构可能是平衡容灾与多活的务实方案。 阅读详情

相关推荐

目标检测——布匹缺陷检测数据集

结构瑕疵指的是布料本身的缺陷,包括嵌结、抽纱、错纱、断纱、预缩等问题,这些问题通常是在布料生产过程中出现的。而质量瑕疵则是指布料在使用过程中出现的问题,如污渍、断裂、鼓囊、针眼等,这些问题可能由生产过程中的结构瑕疵导致,也可能是在运输、存放和使用过程中引起的。布匹瑕疵如缺纬、断纬、粗纬、松纬、缺经、断经、粗经、筘痕、污点、破损等,若未得到及时有效的检测,这些瑕疵产品可能会流向市场,导致消费者的不满和退货,严重影响企业的声誉和品牌形象。织疵包括缺经、缺纬、跳花、弓纱、错纱、厚薄段、油污渍等;

zzjlhlcd的博客 619

B - 3D City Model

A city is built on the top of a rectangular n × m grid where all the grid cells are equal squares. Each of the n·m grid cells can serve as a foundation of a single building in the city. A building is ...

七九河开的博客 470

Frida实战:如何用HashMap.put拦截法快速定位安卓App加密参数(附完整脚本)

本文详细介绍了如何使用Frida拦截HashMap.put方法快速定位安卓App加密参数,提供完整脚本和实战案例。通过动态分析技术,相比传统静态分析大幅提升效率,适用于电商、社交、金融等场景的加密参数定位。

jump7的博客 268

Gym 101246(ACM ICPC 2010-2011, NEERC, Southern Subregional Contest Russia, Saratov)

PROBLEM B D ARE INCLUDED(E F are planned) Problem B. 3D City Model 题意:         用积木搭成 N * M 的物体,并给出每块的高度求表面积。 思路:         对于每一块区域,有基础面积 4 * H + 2         再分别减去与上下左右的重合面积(两个区域的最小高度) 代码: #inclu

DT2131 1076

告别Keil,在Windows上用VSCode + arm-none-eabi-gcc + Makefile搭建国产MCU开发环境(附JLink配置避坑)

本文详细介绍了如何在Windows上使用VSCode、arm-none-eabi-gcc和Makefile搭建国产MCU开发环境,替代传统的Keil和IAR。内容涵盖工具链配置、工程结构设计、Makefile编写、VSCode集成调试以及高效开发工作流,特别针对国产MCU如复旦微FM33系列提供了优化方案和避坑指南。

weixin_28729205的博客 444

使用再生龙还原镜像文件到硬盘

1. 把制作好的再生龙光盘插入需要的电脑,开机按F4使用再生龙启动2. 选择默认的:Clonezailla live(Default settings,VGA 800*600),然后等待几分钟 3. 选择语言:简体中文 4. 选择不修改键盘映射 5. 选择使用再生龙          6. 选择硬盘/分区(存到/来自)镜像文件,此选项既可以制作镜像,也可以恢复镜像。 7. 使用本机的分区     ...

weixin_42168893的博客 1万+

SGU - 519 - 3D City Model (模拟)

519. 3D City Model Time limit per test: 0.25 second(s) Memory limit: 262144 kilobytes input: standard output: standard A city is built on the top of a rectangular n x m grid where all t

Never say never 773

信息安全管理与评估赛题解析-单机取证(含环境)

链接:https://pan.baidu.com/s/1OMzIq884dW2vAiUp0k2Ppg。链接:https://pan.baidu.com/s/1i5daMqhD53wYeQ6hYzRK6Q。链接:https://pan.baidu.com/s/1QFAjdQZK4sJ-gGRP42XPKA。链接:https://pan.baidu.com/s/1BSXvqN2ZGCQXewgFULoeyQ。链接:https://pan.baidu.com/s/1g9zu5ngBz_KMjW1eBMkJAw。

Brucye 1840

sgu - 519 - 3D City Model

题意:给出一个n*m的矩阵,也是由1*1*1的小立方体组成的几何体的俯视图,求这个几何体的表面积(1 题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=519 ——>>原想分角、边、中间3部分求,不过写着写着即发现,自己想复杂啦,可以不分类,一起求。 对于矩阵中的每一个元素,求与其上、下、左、右的高度差,这个差值就是能看见的正侧面,求

无节操 1405

OpenClaw赚钱实录:从“养龙虾“到可持续变现的实践指南——OpenClaw的赚钱底层逻辑与“记忆”革命

AI 的商业价值不在于替代思考,而在于沉淀关系。当 Agent 记住你的偏好、你的历史、你的目标,它就不再是冷冰冰的软件,而是成为数字化的关系资产。这种资产的稀缺性不在于技术复杂度,而在于时间无法被压缩——你无法用更好的算法替代 3 个月的协作记忆。在这场“记忆革命”中,护城河不是模型参数,而是用户与 AI 共同书写的历史。OpenClaw 用一套优雅的文件系统架构,将这种历史转化为可积累、可复用、可变现的数字资产。从“计算即服务”(CaaS)到“记忆即服务”(MaaS)。

冯·诺依曼 1354

Hermes Agent 桌面版安装部署完全指南:一步步安装自进化Agent智能体

是由开发的开源自主 AI 智能体(MIT 协议)。它不是绑定在集成编辑器上的编码助手,也不是围绕单一 API 的聊天机器人封装——它是一个越用越强大的自主智能体,拥有独一无二的闭环学习系统特性说明自主技能创建在复杂任务后自动生成可复用的 Skills(技能)技能自我改进使用过程中持续优化已有技能持久化记忆跨会话记住你的项目、偏好和解决方案用户画像建模通过 Honcho 方言式推理,逐步构建对你的深度理解20+ 平台接入。

大模型与Agent智能体 7833

CF:3D City Model(小思维)

链接:http://codeforces.com/gym/101246/problem/B B. 3D City Model time limit per test 1 second memory limit per test 256 megabytes input input.txt output output.txt A

junior19的博客 428

Easy系列PLC远程IO模块的安装配置和地址访问(EtherCAT总线)

EtherCAT分布式时钟DC(SOEM源码解析)EtherCAT分布式时钟DC(SOEM源码解析)_soem dc同步-CSDN博客文章浏览阅读1.2k次。分布式时钟(DC,Dsitributed Clock)可以使所有 EtherCAT设备使用相同的系统时间,从而控制各设备任务的同步执行。_soem dc同步1200PLC连接分布式IO组态编程应用(ES200SP固件版本不同解决方法)

RXXW_Dor的博客 191

sgu 519. 3D City Model

519. 3D City ModelTime limit per test: 0.25 second(s)Memory limit: 262144 kilobytesinput: standardoutput: standardA city is built on the top of a rectangular n x m grid where all the grid cells are eq...

superkunn的博客 223

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

2018深圳杯数学建模A题

  做的还不是很完善,还请大家多多提意见 2018思特奇杯数学建模竞赛题目 (请严格遵守对论文格式的统一要求)   A题-人才吸引力评价模型研究       在世界各国和全国各地都加大争夺人才的背景下,一个城市要保持其竞争活力和创新力,必须与时俱进地但不盲目地调整相关人才吸引政策。2018年深圳市将加大营商环境改革力度作为一项重要工作,以吸引更多优秀的高新企业和优秀的人才。    吸...

Tyella的博客 23万+

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

Gym - 101246A Bencoding【模拟】

题目链接:https://vjudge.net/problem/Gym-101246A 题意:有三种形式的变量,分别为 整数:i数字e,字符串:字符串长度n:n个字符,列表:l列表内容e,字典:d字典内容e,注意整数中间不能出现其他的字符,也不能有前导零,也不能为负数,列表里面可以出现列表也可以出现整数和字符,字典里面的key可以重复,字典和列表都可以充当key和value,首先判断给出的字符串

22h's Blog 572

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

Polya定理及例题

概念 先讲Burnside定理: 百度百科的传送门:https://baike.baidu.com/item/burnside%E5%BC%95%E7%90%86/1505996  再放一个例题:    重点还是Polya定理 百度百科的传送门:https://baike.baidu.com/item/Polya/11020869 Polya定理在Burnside定...

OneLine_的博客 8678

2019湖北省省赛 D题题解

湖北省网络赛D题题解 D. Dandelion time limit per test 1.0 s memory limit per test 256 MB input standard input output standard output "O dandelion, yellow as gold, What do you do all day?" "I just wa...

OneLine_的博客 1016

Gym 101028C A or B Equals C

原题地址:http://codeforces.com/gym/101028/problem/CRami went back from school and he had an easy homework about bitwise operations (and,or,..) The homework was like this : You have an equation : " A | B =...

OneLine_的博客 833

鸽巢定理和容斥定理 (POJ 2356 、POJ 3370 + HDU 1796)

  真的好久没写博客了 之前是考试周就没怎么做题 后来考试后回家 去厦门玩耍了三四天 19号回学校 20号开始集训 emmmm 结束碎碎念 开始进入正题吧~   目录 鸽巢定理: POJ  2356 POJ  3370 &amp;&amp; HDU 1808 容斥定理: HDU 1796 鸽巢定理: 也叫 抽屉定理, 抽屉原理的一般含义为:“如果每个抽屉代表一个集合,每...

OneLine_的博客 615

HDU 6216 (2017icpc青岛网络赛)

A Cubic number and A Cubic Number Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 2478    Accepted Submission(s): 1015   Problem Description ...

OneLine_的博客 508

CSU - 2135 Appositive Body

当时在现场赛的时候 学长说这题可以做做看因为其他队伍有马上AC的 但是是全英文的,又不是很理解,只能说了解了一个大概吧......DescriptionYuki Nagato is an alien created by the Data Overmind, and possesses supernatural powers as a result. Two of her abilities ar...

OneLine_的博客 411

HDU 6665 离散化 + dfs OR 用交集矩形求分块

2019暑期多校第八场1009 两种方法解决 离散化+dfs 或者 用交集矩形求分块

OneLine_的博客 388

CSU 2164 2018 组合数

CSU 21642018 组合数 在省赛之前看看往届的题目,做题的时候有想到种类相乘,但是没有写... 补题的时候看了许多大佬的题解也没有完全理解 所以 差不多理解了之后写一下博客 参考:https://blog.csdn.net/a465798176/article/details/89947130 https://blog.csdn.net/songziqi98/article/d...

OneLine_的博客 367

CSU - 2130 Permutations

周日 毫无准备地被拉去打了一场现场赛书包里装的是

OneLine_的博客 358
下一篇: CSUFT OJ 1142 及 1141
OneLine_
博客等级 码龄9年 48粉丝 72原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址