摘要:
题目 前缀和+记忆化搜索的方法: 时间复杂度:\(O(10^{2} L^{2})\)(\(L\)为数字位数) #include<bits/stdc++.h> using namespace std; long long a,b,f[25][25],dig[20];//f[pos][k]:记忆化数组, 阅读全文
摘要:
题目 最小生成树模板 Kruskal: 时间复杂度:\(O(M\log M)\) #include<bits/stdc++.h> using namespace std; int N,M,f[5010],ans; struct node{ int X,Y,Z; }e[200010]; bool cm 阅读全文
摘要:
题目 差分约束模板 时间复杂度:\(O(nm)\) #include<bits/stdc++.h> using namespace std; const int N=5005; int n,m,hd[N],ver[2*N],nxt[2*N],w[2*N],tot,dis[N],cnt[N]; boo 阅读全文
摘要:
题目 负环模板 时间复杂度:\(O(Tnm)\) #include<bits/stdc++.h> using namespace std; const int N=3005; int T,n,m,hd[N],ver[2*N],nxt[2*N],w[2*N],tot,dis[N],cnt[N];//c 阅读全文
摘要:
一些简单的模板 快速幂模板 题目 时间复杂度:\(O(\log b)\) #include<bits/stdc++.h> using namespace std; long long a,b,p; long long qp(long long a,long long b,long long p){ 阅读全文
摘要:
题目 单源最短路径模板 Dijkstra: 时间复杂度:\(O((n+m)\log n)\) #include<bits/stdc++.h> using namespace std; using pii=pair<long long,int>; const int N=1e5+10; int n,m 阅读全文
摘要:
题目 笛卡尔树模板 时间复杂度:\(O(n)\) #include<bits/stdc++.h> using namespace std; const int N=1e7+10; int n,p[N],stk[N]; long long ql,qr,l[N],r[N]; void build(){/ 阅读全文
摘要:
题目 单调栈模板 时间复杂度:\(O(n)\) #include<bits/stdc++.h> using namespace std; const int N=3e6+5; int n,a[N],f[N]; stack<int> s; int main(){ ios::sync_with_stdi 阅读全文