摘要:bitset可将01字符串转换为01数组,快速进行位运算等操作 bitset<int>(string) //将01字符串转换为01数组 例题 https://ac.nowcoder.com/acm/contest/92972/D #include<bits/stdc++.h> #define end
阅读全文
摘要:模板题在此 https://ac.nowcoder.com/acm/contest/86639/B /* tarjan:求强联通分量,本题中运用该算法实现重新构图并toposort */ #include<bits/stdc++.h> #define IOS ios::sync_with_stdio
阅读全文
摘要:set.erase(int x)可以将x删除,利用这个特性,可以做到一次性删除 https://atcoder.jp/contests/abc370/tasks/abc370_d #include<bits/stdc++.h> #define endl '\n' #define int long l
阅读全文
摘要:妙啊妙啊 https://ac.nowcoder.com/acm/contest/92687/K #include<bits/stdc++.h> #define endl '\n' #define lowbit(x) (x&-x) using namespace std; const double
阅读全文
摘要:https://ac.nowcoder.com/acm/contest/92687/G #include<bits/stdc++.h> #define endl '\n' #define int long long #define lowbit(x) (x&-x) using namespace s
阅读全文
摘要:关于启发式合并https://oi-wiki.org/graph/dsu-on-tree/ 在这里,对于两个大小不一样的集合,我们将小的集合合并到大的集合中,而不是将大的集合合并到小的集合中。 为什么呢?这个集合的大小可以认为是集合的高度(在正常情况下),而我们将集合高度小的并到高度大的显然有助于我
阅读全文
摘要:二维前缀和模板: 预处理:dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+map[i][j]; 查询:dp[x2][y2]+dp[x1-1][y1-1]-dp[x1-1][y2]-dp[x2][y1-1] 三维前缀和模板: 预处理: pre[i][j][k]=
阅读全文
摘要:思路很妙 https://atcoder.jp/contests/abc375/tasks/abc375_d #include<bits/stdc++.h> #define endl '\n' #define int long long #define lowbit(x) (x&-x) using
阅读全文
摘要:实现的暴力枚举 核心代码: int n; for(int i=0;i<(1<<n);i++){ for(int j=0;j<i;j++){ if(i&(1<<j)) //可以枚举2^n的所有情况 else //如果有两种枚举(比如起点到终点 、终点到起点) } } 例题:htt
阅读全文
摘要:using i64 = long long; template<class T> constexpr T power(T a, i64 b) { T res = 1; for (; b; b /= 2, a *= a) { if (b % 2) { res *= a; } } return res;
阅读全文