上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 55 下一页
摘要: 原题链接 题解 看数据范围,故想到做法,即遍历每个子集,看看每个子集是否具有合法的播放列表 code #include<bits/stdc++.h> #define lowbit(x) ((x)&(-x)) using namespace std; struct node { int a,b; }r 阅读全文
posted @ 2024-06-28 13:59 纯粹的 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 原题链接 题解 1.假设有k类球,当这k类球中数量最多的那一类的数量为m,若m不超过总数的一半,那么答案就是总数的一半+总数的奇偶性,否则答案是m 2.由于数据很小,所以可以 \(O(n^2)\) 3.我们可以对所有的球类组合用数量最多的那一类球定义 code // LUOGU_RID: 16321 阅读全文
posted @ 2024-06-28 13:49 纯粹的 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 原题链接 题解 先想想能不能暴力? 可以,先预处理异或前缀和,然后遍历所有区间 能不能优化? 对于 \(i\) 来说,以其为右端点的左端点有几个? 即对于 \(pre[i]\) 来说,有几个 \(pre[j],j<i\) 能使得异或和不小于k? 再抽象点,对于 \(a,b,k\) ,其中 \(a,k 阅读全文
posted @ 2024-06-27 19:01 纯粹的 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 原题链接 题解 深搜和广搜的结合,一次性往四个方向打标记 code #include<bits/stdc++.h> using namespace std; string s[105]; int vis[105][105]={0}; int main() { int n,m; cin>>m>>n; 阅读全文
posted @ 2024-06-27 13:26 纯粹的 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 原题链接 题解 1.把天数抽象为数组,下标代表天数,值代表每天能借的教室数 2.订单抽象成区间,每个点覆盖的区间数不超过其值,问第一个无法覆盖的区间是? 3.具有单调性,考虑二分 4.区间覆盖可以用差分线性复杂度求出来 code #include<bits/stdc++.h> using names 阅读全文
posted @ 2024-06-26 16:15 纯粹的 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 原题链接 题解 我一开始想遍历每一个点,然后求出能和它配对的点的权值,但是参考菊花图,这样的速度太慢,所以考虑用一个点表示多个配对,于是发现每个点都可以作为配对的中间点 code #include<bits/stdc++.h> using namespace std; const int mod=1 阅读全文
posted @ 2024-06-26 14:56 纯粹的 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 原题链接 题解 贪心,遇到大坑就建立一条到小坑自动减少的区间 code #include<bits/stdc++.h> using namespace std; int a[100005]; int main() { int n; cin>>n; int sum=0; for(int i=1;i<= 阅读全文
posted @ 2024-06-26 13:08 纯粹的 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 原题链接 题解 随便找两个数字,删哪个更优? 发现了什么规律? code #include<bits/stdc++.h> using namespace std; struct node { int v,id,l,r; }c[300]; int main() { string s; cin>>s; 阅读全文
posted @ 2024-06-26 11:50 纯粹的 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 原题链接 题解 对于线段A,选与线段A有交叉,且结束时间比A晚的线段一定不比选线段A更优 code #include<bits/stdc++.h> using namespace std; struct node { int l,r; }seg[1000005]; bool cmp(node a,n 阅读全文
posted @ 2024-06-26 11:11 纯粹的 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 原题链接 题解 先考虑操作一,首先要数组总和不小于 \(s\) 其次,我们可以通过两边删数来得到子数组,如果两边任一边有二,我们删掉二之后, \(sum\) 减二,如果全是一,我们两边的一都删掉(数组长度大于1), \(sum\) 减二,所以如果 \(sum\) 是偶数,那么我一定能得到 \([2, 阅读全文
posted @ 2024-06-25 20:14 纯粹的 阅读(3) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 55 下一页