当前位置:网站首页>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 6
Sample output:
2 44 88 16
Abstract 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
边栏推荐
- 网络拓扑管理
- 003-序列图(一)
- CAS:190598-55-1_Biotin sulfo-N-hydroxysuccinimide ester生物素化试
- AIRIOT答疑第8期|AIRIOT的金字塔服务体系是如何搞定客户的?
- CAS:2055042-70-9_N-(叠氮基-PEG4)-生物素
- pyspark columns merge into one row
- 类型和id对应的两个数组
- Redis persistence mechanism
- [TAPL] 概念笔记
- When selecting a data destination when creating an offline synchronization node - an error is reported in the table, the database type is adb pg, what should I do?
猜你喜欢
随机推荐
Introduction to 3 d games beginners essential 】 【 modeling knowledge
mysql 中大小写问题
钻石价格预测的ML全流程!从模型构建调优道部署应用!
PG中的Index-Only Scans解密
pip3升级到22.2.2
【知识分享】在音视频开发领域中SEI到底是个啥?
罗克韦尔Rockwell Automation EDI 项目
「POJ 3666」Making the Grade 题解(两种做法)
几行深度学习代码设计包含功能位点的候选免疫原、酶活性位点、蛋白结合蛋白、金属配位蛋白
第15章_锁
JVM内存和垃圾回收-11.执行引擎
让mixin为项目开发助力【及递归优化新尝试】
弘玑Cyclone与风变科技达成战略合作:优势互补聚焦数字化人才培养
FPGA:基础入门按键控制蜂鸣器
Today's bug, click on the bug that the Windows dynamic wallpaper disappears in the win10 taskbar, and no solution has been found yet.
GBASE 8s 高可用RSS集群搭建
redis.exceptions.DataError: Invalid input of type: ‘dict‘. Convert to a byte, string or number first
flask装饰器版登录、session
VoLTE基础自学系列 | 3GPP规范解读之Rx接口(上集)
websocket校验token:使用threadlocal存放和获取当前登录用户