当前位置:网站首页>2019 Nanchang Internet Competition Question C, Hello 2019
2019 Nanchang Internet Competition Question C, Hello 2019
2022-08-09 07:40:00 【swust_fang】
The meaning of the question: Find the minimum number of deletions that includes 9012, but does not include 8012
Solution idea: first invert the string, and maintain the matrix for the line segment tree according to the problem solving idea
We represent each interval of the line segment tree as a matrix, and the matrix mat[5][5] maintains the situation of the 2019 sequence~
First clarify the meaning of the matrix mat: we need to form a sequence of length 4
mat[0][1] represents the minimum cost required for "2"
mat[0][2] represents the minimum cost of "20"
mat[0][3] represents the minimum cost required by "201"
mat[0][4] means "2019" and there is no minimum cost required for "2018"
Encounter a '2', then we use this '2', mat[0][1]=0, if not mat[0][1]=1
When a '0' is encountered, then we use this '0', mat[1][2]=0, if not mat[1][1]=1
Encounter a '1', then we use this '1', mat[2][3]=0, if not mat[2][2]=1
Encounter a '9', then we use this '9', mat[3][4]=0, if not mat[3][3]=1
In 2019, we can choose to transfer or not transfer our numbers, but in the case of 8, whether it is 3 or 4, it will cost 1 to delete him~
Encounter an '8', then we don't need this '8', mat[3][3]=1, mat[4][4]=1
From the case of i->j, it is obvious that the optimal can be found by shifting i->k,k->j
dp transfer equation: ans.mat[i][j]=min(ans.mat[i][j],a.mat[i][k]+b.mat[k][j]);
If you want to merge, you can directly use the line segment tree interval to merge.
This question is really difficult. After the game, I found that more than 200 teams beat the tourist~(wu
//#pragma comment (linker, "/STACK:102400000,102400000")#include#include#include#include#include#include#include#include#include#include#include
边栏推荐
- 【ROS2原理8】节点到参与者的重映射
- 数据一致性架构
- JSONObject遍历的时候顺序不一致,导致数据对应出错
- 工信部等四部门推动绿色智能家居产品下乡
- Difference Constraint - Graph Theory
- Codeforces Round #359 (Div. 2) C. Robbers' watch Violent Enumeration
- PyTorch中 torch.nn与torch.nn.functional的区别
- 金九银十即将到来,求职套路多,面试指南我来分享~
- 【机器学习】随机森林、GBDT、XGBoost、LightGBM等集成学习代码练习
- MYSQLWorkbench看数据库ER图
猜你喜欢
学习小笔记---机器学习
Learning Notes---Machine Learning
web自动化测试有哪些工具和框架?
Four departments including the Ministry of Industry and Information Technology promote green smart home products to the countryside
74HC595 chip pin description
CoCube传感器MPU6050笔记
毕业我选择了保家卫国,退伍我选择了华为外包
SiamFC:用于目标跟踪的全卷积孪生网络 fully-convolutional siamese networks for object tracking
Pytorch中 nn.BatchNorm2d() 归一化操作
Win10桌面图标排列混乱
随机推荐
重要消息丨.NET Core 3.1 将于今年12月13日结束支持
Lottie系列四:使用建议
Codeforces Round #359 (Div. 2) C. Robbers' watch 暴力枚举
(error) NOAUTH Authentication required.
SAP ALV 数据导出被截断的bug
A brief introduction to microservice architecture
Snake game, C language
软件测试的岗位会越来越少吗?
Colors that Tkinter can choose from
【烂笔头】各厂商手机手动抓log
搭载开源鸿蒙系统的嵌入式XM-RK3568工业互联方案
查看日志常用命令
神经网络优化器
2022 年全球十大最佳自动化测试工具
tianqf的解题思路
排序第二节——选择排序(选择排序+堆排序)(两个视频讲解)
【机器学习】中国大学慕课《机器学习》课后习题(二)(回归)
信息反馈平台的设计与实现(一、项目设计)
【sqlite3】sqlite3.OperationalError: table addresses has 7 columns but 6 values were supplied
Native JDBC operation database