上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 65 下一页
摘要: 原题链接 题解 1.字符串集合map?但是无法做到字典序排序,所以是字典树 2.n<=3000,所以 \(O(n^2)\) 而且本题的特殊性,即每个子串都要放进去,所以要在 \(n^2\) 一边遍历一边放 code #include<bits/stdc++.h> using namespace st 阅读全文
posted @ 2024-04-01 14:19 纯粹的 阅读(18) 评论(0) 推荐(0)
摘要: 原题链接 题解 1.二分+dp code #include<bits/stdc++.h> using namespace std; string name[1000005],dp[1000005],st[1000005]; int main() { string s; cin>>s; int cnt 阅读全文
posted @ 2024-03-30 22:02 纯粹的 阅读(61) 评论(0) 推荐(0)
摘要: 原题链接 题解 1.由于我刚刚才学字典树,所以我会告诉你这就类似字典树,对字符串终点节点加一,然后搜索统计最大前缀和 code #include<bits/stdc++.h> using namespace std; string s; int tree[2000005][65]={0}; int 阅读全文
posted @ 2024-03-30 20:37 纯粹的 阅读(24) 评论(0) 推荐(0)
摘要: 原题链接 题解 1.建议去B站上看看动画演示,你就明白怎么回事了 2.如何用代码实现呢?看完你就明白了 code #include<bits/stdc++.h> using namespace std; int num=0; int tree[3000006][75]={0}; int cnt[30 阅读全文
posted @ 2024-03-30 20:20 纯粹的 阅读(95) 评论(0) 推荐(0)
摘要: 原题链接 题解 1.如果数字为 \(100110101\) 那么答案为 \(000000000\) ~ \(011111111\) 中,k个1的组合数 + \(100000000\) ~ \(100011111\) 中k-1个1的组合数 +...+ \(1010101...\) (有k个1) 中0个 阅读全文
posted @ 2024-03-30 18:43 纯粹的 阅读(93) 评论(0) 推荐(0)
摘要: 原题链接 题解 1.该题等价于构建一颗k叉树,每个叶子节点都有一个权值 \(leaf_i\) ,树的权值为 \(\sum_{1}^{n}leaf_i\) ,在使树的权值尽可能小的情况下,使最深的叶子节点的深度也尽可能小,即使数的高度尽可能小 这个叫做哈夫曼树 2.构建过程如下:每次从队列中取出 \( 阅读全文
posted @ 2024-03-30 11:47 纯粹的 阅读(51) 评论(0) 推荐(0)
摘要: 原题链接 题解 用由于本题具有线性特征(总是不减?)所以可以用两个堆来维护第i小的元素, code #include<bits/stdc++.h> using namespace std; int a[200005]; int main() { ios::sync_with_stdio(false) 阅读全文
posted @ 2024-03-29 16:50 纯粹的 阅读(27) 评论(0) 推荐(0)
摘要: 原题链接 题解 1.最短路径一定可以表示成经过若干端点的线段,所以我们把端点单独提出来,这样就变成了计算几何形式的最短路 2.如果两个端点能相连,代表他们之间没有墙阻挡 code #include<bits/stdc++.h> using namespace std; int n; struct { 阅读全文
posted @ 2024-03-29 16:07 纯粹的 阅读(36) 评论(0) 推荐(0)
摘要: 原题链接 题解 1.模拟题,注意细节 2.时间复杂度 \(O(n·sqrt(n))\) code #include<bits/stdc++.h> using namespace std; int n; string s; int check(int len) { int flag=0; for(in 阅读全文
posted @ 2024-03-29 15:16 纯粹的 阅读(52) 评论(0) 推荐(0)
摘要: 原题链接 题解 1.模拟+贪心,我们一个一个点添加,一层一层遍历,每个节点对当前层的接口数的贡献是-1 如果是节点2,对下一层接口数贡献为2,节点1贡献为1 如果当前层接口数用完了就下一层,初始值层0设为1 在时间复杂度合理的情况下无所不用其极 code #include<bits/stdc++.h 阅读全文
posted @ 2024-03-29 14:02 纯粹的 阅读(100) 评论(0) 推荐(0)
上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 65 下一页