摘要: 莫队模板题 相当于优化的暴力,每一次调整左右节点的位置 #include <bits/stdc++.h> using namespace std; int n,m,k; const int N=5e4+5; int a[N]; int cnt[N];//用于计算当前区间i出现了几次 int ans[ 阅读全文
posted @ 2025-11-22 16:54 wtnbl 阅读(0) 评论(0) 推荐(0)
摘要: #include <bits/stdc++.h> using namespace std; const int N=2e5+5; int n,cnt=0,didx=0,idx[N],ans[N]; string s[N]; struct Node { int son[26],idx,fail,ans 阅读全文
posted @ 2025-11-13 21:33 wtnbl 阅读(4) 评论(0) 推荐(0)
摘要: Dijkstra #include <bits/stdc++.h> #define pii pair<int,int> using namespace std; const int N=1e5+5; vector<vector<pair<int,int>>> G; int n,m,s; priori 阅读全文
posted @ 2025-11-01 10:53 wtnbl 阅读(4) 评论(0) 推荐(0)
摘要: 见pdf https://wwak.lanzouo.com/ipQq6398irbc 阅读全文
posted @ 2025-10-24 21:22 wtnbl 阅读(3) 评论(0) 推荐(0)
摘要: int findMinValid(int left, int right) { int ans = -1; while (left <= right) { int mid = (left+right)/2; if (check(mid)) { // 满足条件,尝试找更小的解 ans = mid; / 阅读全文
posted @ 2025-10-03 20:58 wtnbl 阅读(4) 评论(0) 推荐(0)
摘要: 少使用rbegin,用prev(end()) 尽量使用容器自带的函数,比如set的lower_bound() 阅读全文
posted @ 2025-09-24 15:01 wtnbl 阅读(6) 评论(0) 推荐(0)
摘要: 可以用一个map数组记录边存了没有 最简单好写的 数据范围\(m<=5e4\) map<pair<int,int>,bool> uni; for(int u,v,i=1;i<=m;i++) { cin>>u>>v; if(uni[{u,v}]) continue; uni[{u,v}]=uni[{v 阅读全文
posted @ 2025-08-28 10:10 wtnbl 阅读(8) 评论(0) 推荐(0)
摘要: 求强联通分量 解释见代码 #include <bits/stdc++.h> using namespace std; const int N = 100005; // 根据题目最大点数修改 int n, m; vector<int> G[N]; int dfn[N]/*时间戳,代表u的访问顺序*/, 阅读全文
posted @ 2025-08-27 16:33 wtnbl 阅读(6) 评论(0) 推荐(0)
摘要: 卢卡斯定理 对于素数 p,有 \(\binom{n}{k}\equiv \binom{\lfloor n/p\rfloor}{\lfloor k/p\rfloor}\binom{n\bmod p}{k\bmod p}\pmod p.\) 其中,当 n<k 时,二项式系数 \(\dbinom{n}{k 阅读全文
posted @ 2025-08-26 22:37 wtnbl 阅读(6) 评论(0) 推荐(0)
摘要: #include <bits/stdc++.h> #define lson l,m,k*2 #define rson m+1,r,k*2+1 //左右儿子在函数里面用 #define int long long using namespace std; const int N=5000005; in 阅读全文
posted @ 2025-08-26 22:33 wtnbl 阅读(9) 评论(0) 推荐(0)