随笔分类 - 暑假集训
2022
摘要:K - Subarrays OR 类似DP,前缀和 #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int>pii; const int N=1e5+10; int n; set
阅读全文
摘要:CF补题:A题:忘记memset,浪费时间B题:只想到相隔偶数就算,但是没想好用什么方法计算可以和滚动优化一样,只记录上一次的位置#include <bits/stdc++.h> using namespace std; const int N=1e5+10; int a[N],pre[N],ans
阅读全文
摘要:E - Dist Max 2 找最小值的最大值,这种题目一般都是二分 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=2e5+10,inf=0x3f3f3f3f; struct node
阅读全文
摘要:补题 H #include <bits/stdc++.h> using namespace std; const int N=1e5+10; int a[N]; int pos[55]; int b[N]; signed main() { int n; cin>>n; for (int i=1;i<
阅读全文
摘要:高手去散步 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=55; int g[N][N]; int dist[N]; bool st[N]; int n,m,ma; void dfs(i
阅读全文
摘要:二分图染色(最近是被DFS折磨的一段颇有遗憾的时光) #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e5+10,M=2e5+10; int h[N],e[M],ne[M],idx; i
阅读全文
摘要:线段树 并查集 dijkstra:每次找到未确定最短距离的一个点,把它放在S集合中,并用它带来更新它的出边的距离,n次。 bellman:外循环第一次找经过一条边的最短距离,备份当前最短距离;外循环第二次找经过两条边的最短距离,备份当前最短距离......外循环第k次找经过k条边的最短距离,备份当前
阅读全文
摘要:CF D #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e5+10; int cnt[30]; signed main() { // ios::sync_with_stdio(0);
阅读全文
摘要:基础数论: 质数(一般用线性筛) 约数 快速幂 组合数 容斥 补题: C - Bacteria 救命,取栈顶元素没开long long,太可惜了 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int
阅读全文
摘要:基础算法: 二分 #include <bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 10; int n, m; int a[N], b[N]; bool check(int x) { int
阅读全文
摘要:dfs(尽可能往深搜)栈O(n) 顺序+剪枝 全排列 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N=10; int path[N]; bool st[N]; int n; void df
阅读全文
摘要:单调栈 GInger的神罚洛谷U220471 #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int>pii; const int N=2e5+10; ll a[N],dp[N]
阅读全文