11 2022 档案

摘要:https://www.acwing.com/problem/content/106/ 这一眼看过去是个数学题,解方程即可设个x为仓库地址,然后x-a[i]进行求和,枚举每个位置求最小总距离,复杂度有点高,过不了,但是可以试试 #include<iostream> #include<algorith 阅读全文
posted @ 2022-11-26 13:49 风乐 阅读(24) 评论(0) 推荐(0)
摘要:贪心模板题思考这题之前,首先需要明确一点:对于任何买卖操作,即便跨了n天也是一样,都可以拆分成如图的形式{(at,at+1),(at2,at2+1)....,(atk,atk+1)},这样的集合,即可以拆分成跨度都为1天的小买卖这样的集合中每项元素可正可负,值即为a(i+1)-a(i)的数值,后一天 阅读全文
posted @ 2022-11-24 21:23 风乐 阅读(25) 评论(0) 推荐(0)
摘要:https://www.acwing.com/problem/content/1209/ #include<iostream> #include<cstring> #include<algorithm> #include<cstdio> using namespace std; const int 阅读全文
posted @ 2022-11-09 22:34 风乐 阅读(20) 评论(0) 推荐(0)
摘要:图论好难啊,什么树啊图啊,树的直径,最短路径啊,怎么求啊,这算法怎么是对的啊???好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好南啊好 阅读全文
posted @ 2022-11-09 22:27 风乐 阅读(73) 评论(0) 推荐(0)
摘要:https://www.acwing.com/problem/content/3420/ 一眼dp,但是还是先走个暴搜看看,开始的时候我这样想,由于天平两边都可以称,需要减的操作,数组无法存储负数下标,于是我这里加了个偏移量100000,于是只过了一半的数据233(但是实际上小于0的下标不需要计算, 阅读全文
posted @ 2022-11-07 23:30 风乐 阅读(69) 评论(0) 推荐(0)
摘要:https://www.acwing.com/problem/content/1115/首先要考虑有多少个连通块,可以直接枚举每个点,对每个点进行一次搜索,与这个点连通的点共同构成一个连通块,数量用cnt表示,在搜索中,检查判断是否会被完全淹没(Flood Fill) #include<bits/s 阅读全文
posted @ 2022-11-05 14:30 风乐 阅读(34) 评论(0) 推荐(0)
摘要:2067. 走方格 - AcWing题库 第一眼就是暴搜2333结果显而易见,卡数据了,9/10,最后一个过不了DFS: #include<iostream> #include<cstring> #include<algorithm> using namespace std; const int N 阅读全文
posted @ 2022-11-02 09:11 风乐 阅读(33) 评论(0) 推荐(0)
摘要:https://www.acwing.com/problem/content/1098/ 简单练手bfs题需要注意的是此题是三维的数据,偏移量需要改一下 #include<iostream> #include<queue> #include<cstdio> #include<cstring> #in 阅读全文
posted @ 2022-11-01 16:12 风乐 阅读(32) 评论(0) 推荐(0)