希胤
希胤
全部文章
分类
dp模板(4)
dp狂练(1)
图论模板(4)
小知识(3)
数论模板(1)
未归档(3)
杂模板(5)
题解(36)
归档
标签
去牛客网
登录
/
注册
希胤的博客
TA的专栏
23篇文章
0人订阅
蓝桥真题
12篇文章
800人学习
线段树和数状数组经典例题
11篇文章
281人学习
全部文章
(共60篇)
//01背包 + 并查集
//01背包 + 并查集#include<bits/stdc++.h>using namespace std;int const N=1e4+7;//int const M=1e5+7;int t;//int a[i];int f[N];int v[N],w[N];int dp[505]...
2020-09-07
0
523
并查集可以处理传递关系,并查集中的f[x]是用来压缩路径的 ,主函数找祖先用find(x)
//题目分析:并查集,节点祖先为连续的没有使用的节点,每次使用后的下一个点合并//每个点的祖先是自己,如果自己被使用了,则祖先指向下一个点(即+1)(即合并)#include<bits/stdc++.h>using namespace std;#define _for(n,m,i) fo...
2020-09-06
0
504
桶排序——map比数组更节省空间
//题目:k倍区间(AcWing) include<bits/stdc++.h> using namespace std;int n,k;int a[100005];map<int,int>b; //int映射成int可以用数组,但 用map比用数组更节省空间 ,因为数组多开...
2020-09-06
0
613
连通块用广搜
//题目:全球变暖(AcWing)#include<bits/stdc++.h>using namespace std;int n,ans;int vis[1005][1005][3];string str[1005];int xx[]={0,1,0,-1};int yy[]={1,0,...
2020-09-05
0
551
01背包的变形/拓展(这道题其实是二维背包)
//头文件int n,k;string str;//f[i][j] //在前i天已经工作了j天//f[i][j][p] //多了一维p(现在已经连续工作了多少天)//f[j][p] //采用就地滚动去掉第一维int f[405][405];int main...
2020-08-21
0
592
dp貌似可以直接用贪心做,实则不能,因为直接对原问题分部贪心结果不一定最优,dp是在子问题中贪心
include<bits/stdc++.h> using namespace std;int n;int a[15][15];int f[15][15][15][15];int main(){ cin >> n; int x=0,y=0,b=0; while...
2020-08-17
0
657
最长上升子序列和下降子序列(朴素版)
include<bits/stdc++.h> using namespace std;int n;int a[105];int f[105];int main(){ cin >> n; for(int i=1;i<=n;++i){ cin &g...
2020-08-17
0
708
找集合的个数即找统领的个数
struct L{ int x,y;}a[103];int f[103],b[103];int find(int x){ return f[x]==x?x:f[x]=find(f[x]);}void merge(int x,int y){ f[find(x)]=find(y);}i...
2020-07-28
0
487
可以后悔的贪心
int const N=150007;struct L{ ll t1,t2; friend bool operator<(L a,L b){ return a.t1 < b.t1 ; }}a[N];bool cmp(L a,L b){ return ...
2020-07-27
0
566
差分+离散化
//先差分,再前缀和 #include<bits/stdc++.h> using namespace std; namespace{ template<typename T> inline void read(T &s){ T f=1;...
2020-07-13
0
865
首页
上一页
1
2
3
4
5
6
下一页
末页