当前位置:网站首页>2022 Hangdian Multi-School Seven Black Magic (Sign-in)
2022 Hangdian Multi-School Seven Black Magic (Sign-in)
2022-08-10 19:25:00 【AC__dream】
Title link: Hangdian Multi-School 7 - Virtual Judge

Sample input:
31 1 1 11 2 3 43 4 5 6Sample output:
2 44 88 16Abstract meaning: multiple sets of samples, each set of samples is given four numbers e, l, r, b, representing the numbers of 11, 01, 10, 00 respectively, of which
11: The bricks are white on both sides
01: The brick is black on the left and white on the right
10: The left side of the brick is white and the right side is black
00: The brick is black on both sides
When the adjacent faces of two bricks are black, then the two bricks will be combined into one brick. We place the above bricks in a certain order, and ask us the minimum number of bricks and the maximum number of bricks.number.
Analysis: This is a greedy problem. Let's talk about the minimum number of bricks first. We make the bricks of 10 and 01 match as much as possible.Neighbor , then this can reduce one brick each time, and if there are 10 or 01 bricks, we can also put 00 bricks in one and then combine with 01 or 10 bricksThe blocks are adjacent, so that the 00 bricks will all disappear. We select a 10 and a 01 adjacent each time, so that the minimum value can be obtained. It should be noted that there is no 00 brick, and special judgment is required.
Let's talk about the case with the most values. This is also very simple. According to the greedy strategy, we Put the 01 bricks on the leftmost and connect them together, and thenPut 10 bricks together on the far right, and finally use 11 bricks to cross and place 00 bricks in the middle, so we only need to discuss the relationship between the number of 00 bricks and the number of 11 bricks, if 00 bricksIf the number is greater than the number of 11 bricks + 1, then there will be several 00 bricks connected together, otherwise there will be no black and black connection.
Here is the code:
#include#include#include#include#include 边栏推荐
猜你喜欢

【知识分享】在音视频开发领域中SEI到底是个啥?

Major upgrade of MSE Governance Center - Traffic Governance, Database Governance, Same AZ Priority

基于 RocksDB 实现高可靠、低时延的 MQTT 数据持久化

2022-08-09 学习笔记 day32-IO流

RS-485多主机通信的组网方式评估

多种深度模型实现手写字母MNIST的识别(CNN,RNN,DNN,逻辑回归,CRNN,LSTM/Bi-LSTM,GRU/Bi-GRU)

2022-08-09 Study Notes day32-IO Stream

剖析Framework面试—>>>冲击Android高级职位

【深度学习前沿应用】图像风格迁移

基于GAMS的电力系统优化分析
随机推荐
Keras deep learning combat (17) - image segmentation using U-Net architecture
从 GAN 到 WGAN
The Biotin-PEG3-Br/acid/NHS ester/alcohol/amine collection that everyone wants to share
flask的配置文件
弘玑Cyclone与风变科技达成战略合作:优势互补聚焦数字化人才培养
FPGA工程师面试试题集锦61~70
About npm/cnpm/npx/pnpm and yarn
从企业的视角来看,数据中台到底意味着什么?
第四届“传智杯”全国大学生IT技能大赛(初赛A组) 补题
PG中的Index-Only Scans解密
第14章_MySQL事务日志
服务器上行带宽和下行带宽指的是什么
003-序列图(一)
宝塔部署flask项目
Thoughts on Technology Sharing
CAS:190598-55-1_Biotin sulfo-N-hydroxysuccinimide ester生物素化试
L2-035 完全二叉树的层序遍历
postgis空间数据导入及可视化
VoLTE基础自学系列 | 3GPP规范解读之Rx接口(上集)
redis.exceptions.DataError: Invalid input of type: ‘dict‘. Convert to a byte, string or number first