Gsss丶
Gsss丶
全部文章
分类
板子(4)
每日一题(3)
牛客入门班(26)
题解(2)
归档
标签
去牛客网
登录
/
注册
Gsss丶的博客
全部文章
(共35篇)
并查集板子
const int Max=1e5; int fa[Max]; //父亲集合 int find(int a) { return fa[a]==a ? a:fa[a]=find(fa[a]); } //寻找 void merge(int a,int b) { int x=find(...
2021-01-27
0
351
二分板子
#include<bits/stdc++.h> using namespace std; #define ll long long bool check() { } int main() { ll l=0,r=1e9;//l 和 r是实际范围 while(l<r)...
2021-01-27
0
426
欧拉筛板子
const int Max=1e5; int vis[Max],prime[Max]; void Prime() { memset(vis,0,sizeof(vis)); memset(prime,0,sizoef(prime)); for(int i=2;i<Max;...
2021-01-27
1
495
5.1 小木棍(搜索剪枝)
题目链接 小木棍 题目思路 dfs的思想需要学习,努力剪枝减小时间复杂度当第一个木棍尝试dfs无法拼成后,直接break当最后一个尝试dfs无法拼成后,直接breaka[i]不行的话,等于a[i]的也不行 代码实现 #include<bits/stdc++.h> using namesp...
2021-01-25
0
561
4.4 建筑抢修(利用堆维护的贪心)
题目链接 建筑抢修 题目思路 和会议问题相似,先把结束时间从小到大排序,再用最大堆维护,比较前面维修所需时间与后面所需维修时间,从而实现贪心最大化 代码实现 #include<bits/stdc++.h> using namespace std; const int Max=1e6; s...
2021-01-23
0
504
4.3 任意点
题目链接 任意点 加边的无向图 题目思路 都是通过用并查集来寻找是否各点是否关联,通过merge处理之后寻找是否fa[i]==i,从而确定有几个未关联的点集 代码实现 //任意点 #include<bits/stdc++.h> using namespace std; const i...
2021-01-22
0
349
4.2 经商(并查集的灵活运用)
题目链接 经商 题目思路 并查集构图,再用01背包解决 代码实现 #include<bits/stdc++.h> using namespace std; const int Max=1e6; int n,m,c; int fa[Max],dp[Max],cost[Max],value[...
2021-01-22
0
367
4.1 食物链(带权并查集)
题目链接 食物链 题目思路:带权并查集 设0为a,b同级 a1b为a吃b a2b为b吃a第一次写带权并查集,希望在最近的刷题中能有所提高 代码实现 #include<bits/stdc++.h> using namespace std; #define ll long long co...
2021-01-20
0
408
3.4 扑克牌
题目链接 扑克牌 题目思路 二分,数据比较大的时候r设的大一些,不然易wa 代码实现 #include<bits/stdc++.h> using namespace std; #define ll long long const int Max=1e5; ll n,m,c[Max]; b...
2021-01-19
0
378
3.3 聪明的质检员
题目链接 聪明的质检员 题目思路 二分+前缀和优化#代码实现 #include<bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); #d...
2021-01-18
0
499
首页
上一页
1
2
3
4
下一页
末页