08 2022 档案

摘要:DFS 剪枝 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n; int w[N]; int sum, len; bool st[N]; bo 阅读全文
posted @ 2022-08-23 23:57 wKingYu 阅读(30) 评论(0) 推荐(0) 编辑
摘要:DFS + 剪枝 + 位运算优化 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 9, M = 1 << N; int ones[M]; // ones[i]表示i的二进制 阅读全文
posted @ 2022-08-18 00:17 wKingYu 阅读(33) 评论(0) 推荐(0) 编辑
摘要:DFS 剪枝 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 50 + 10; int n, m; int w[N]; int sum[N]; // 每组的重量之和 int 阅读全文
posted @ 2022-08-17 22:14 wKingYu 阅读(21) 评论(0) 推荐(0) 编辑
摘要:DFS 剪枝 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 50 + 10; int n; int a[N]; int ans = 1e9; vector<int> g[ 阅读全文
posted @ 2022-08-17 17:50 wKingYu 阅读(34) 评论(0) 推荐(0) 编辑
摘要:DFS 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 50 + 10; int n; string word[N]; int g[N][N]; // g[i][j]表示w 阅读全文
posted @ 2022-08-17 13:11 wKingYu 阅读(20) 评论(0) 推荐(0) 编辑
摘要:带扩展域的并查集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, m; int p[N]; struct Node { int a, b; 阅读全文
posted @ 2022-08-16 21:18 wKingYu 阅读(22) 评论(0) 推荐(0) 编辑
摘要:并查集 + 树的判定 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n; int p[N]; int find(int x) { if (p[ 阅读全文
posted @ 2022-08-16 17:22 wKingYu 阅读(26) 评论(0) 推荐(0) 编辑
摘要:带扩展域的并查集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, m; int p[N]; int find(int x) { if (p 阅读全文
posted @ 2022-08-16 16:47 wKingYu 阅读(15) 评论(0) 推荐(0) 编辑
摘要:并查集 + 树的判定 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e4 + 10; int n; int p[N]; int find(int x) { if (p[ 阅读全文
posted @ 2022-08-16 14:21 wKingYu 阅读(22) 评论(0) 推荐(0) 编辑
摘要:贪心 + 小根堆 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> PII; const int N = 1e6 + 10; int n; void solv 阅读全文
posted @ 2022-08-15 23:41 wKingYu 阅读(24) 评论(0) 推荐(0) 编辑
摘要:异或的性质 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n; int a[N]; void solve() { cin >> n; for 阅读全文
posted @ 2022-08-14 17:12 wKingYu 阅读(22) 评论(0) 推荐(0) 编辑
摘要:带权并查集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, m; int p[N], d[N]; int find(int x) { if 阅读全文
posted @ 2022-08-12 23:32 wKingYu 阅读(37) 评论(0) 推荐(0) 编辑
摘要:带权并查集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, m; int p[N], d[N]; int find(int x) { if 阅读全文
posted @ 2022-08-12 22:39 wKingYu 阅读(24) 评论(0) 推荐(0) 编辑
摘要:先合并集合,最后统计集合个数 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, m; int p[N]; int find(int x) { 阅读全文
posted @ 2022-08-11 23:55 wKingYu 阅读(23) 评论(0) 推荐(0) 编辑
摘要:先合并集合,最后统计多少学生和 0 号学生属于同一集合 并查集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, m; int a[N] 阅读全文
posted @ 2022-08-11 23:49 wKingYu 阅读(26) 评论(0) 推荐(0) 编辑
摘要:特定条件合并集合 并查集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, d; int p[N]; bool open[N]; struc 阅读全文
posted @ 2022-08-11 23:34 wKingYu 阅读(17) 评论(0) 推荐(0) 编辑
摘要:单点修改(更新),区间查询(最大值) 线段树 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 5e5 + 10; int n, m; int w[N]; struct No 阅读全文
posted @ 2022-08-11 23:07 wKingYu 阅读(15) 评论(0) 推荐(0) 编辑
摘要:单点修改(增加),区间查询(区间和) 线段树 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 5e5 + 10; int n; int w[N]; struct Node 阅读全文
posted @ 2022-08-11 22:56 wKingYu 阅读(19) 评论(0) 推荐(0) 编辑
摘要:二分 + 双端队列广搜 复杂度 mlog(rl)=1×104×log(109)=3×105 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long 阅读全文
posted @ 2022-08-10 23:44 wKingYu 阅读(21) 评论(0) 推荐(0) 编辑
摘要:最短路 + DFS 枚举顺序 最短路用堆优化 dijkstra 复杂度 O(mlog(n))=105log(5×104)1.56×106 DFS 枚举复杂度 O(n!)=5!=120 两个复杂度是相加 阅读全文
posted @ 2022-08-10 22:29 wKingYu 阅读(33) 评论(0) 推荐(0) 编辑
摘要:递推 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 100 + 10; int n, m; int a[N][N], g[N][N]; int dx[] = {0, -1 阅读全文
posted @ 2022-08-10 14:06 wKingYu 阅读(25) 评论(0) 推荐(0) 编辑
摘要:三维迷宫 BFS + 结构体存储 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 100 + 10; const int INF = 0x3f3f3f3f; int L, 阅读全文
posted @ 2022-08-10 13:35 wKingYu 阅读(30) 评论(0) 推荐(0) 编辑
摘要:八皇后问题的变形 DFS 按行枚举 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 10 + 10; int n, m; char g[N][N]; bool col[ 阅读全文
posted @ 2022-08-10 13:09 wKingYu 阅读(16) 评论(0) 推荐(0) 编辑
摘要:贪心 + 连通性 + 最短路 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 100 + 10; const int INF = 0x3f3f3f3f; const int 阅读全文
posted @ 2022-08-09 23:56 wKingYu 阅读(25) 评论(0) 推荐(0) 编辑
摘要:建图 + 有限制的最短路 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> PII; const int N = 1e6 + 10; const int M 阅读全文
posted @ 2022-08-09 19:35 wKingYu 阅读(18) 评论(0) 推荐(0) 编辑
摘要:按照换乘次数建图,求单源最短路 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> PII; const int N = 1e6 + 10; const int 阅读全文
posted @ 2022-08-09 17:50 wKingYu 阅读(24) 评论(0) 推荐(0) 编辑
摘要:乘积最大的路径 堆优化 dijkstra 复杂度 O(mlog(n))=1×105×log(2000)1.1×106 点击查看代码 #include<bits/stdc++.h> using namespace s 阅读全文
posted @ 2022-08-09 11:52 wKingYu 阅读(24) 评论(0) 推荐(0) 编辑
摘要:选一个起点,到其他点的最短距离之和最小 堆优化 dijkstra (2500 ms) 复杂度 O(mlog(n)p)=1450×log(500)×8001.04×107 点击查看代码 #incl 阅读全文
posted @ 2022-08-09 00:15 wKingYu 阅读(27) 评论(0) 推荐(0) 编辑
摘要:求起点到其他所有点的最短距离 堆优化 dijkstra20 ms) 复杂度 (mlog(n))=200×log(100)664 点击查看代码 #include<bits/stdc++.h> using namespace std; 阅读全文
posted @ 2022-08-08 23:18 wKingYu 阅读(25) 评论(0) 推荐(0) 编辑
摘要:起点到终点的最短距离 堆优化 dijkstra 复杂度 O(mlog(n))=6200×log(2500)7×104 点击查看代码 #include<bits/stdc++.h> using namespace std; type 阅读全文
posted @ 2022-08-08 22:44 wKingYu 阅读(30) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n; vector<int> primes; bool st[N]; void get_prim 阅读全文
posted @ 2022-08-07 23:38 wKingYu 阅读(52) 评论(0) 推荐(0) 编辑
摘要:DFS 求方案个数 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 100 + 10; int n, m, x, y; bool st[N][N]; int res; in 阅读全文
posted @ 2022-08-07 22:42 wKingYu 阅读(23) 评论(0) 推荐(0) 编辑
摘要:Flood Fill 的 DFS 写法 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 100 + 10; int n, m; char g[N][N]; bool st[ 阅读全文
posted @ 2022-08-07 22:31 wKingYu 阅读(22) 评论(0) 推荐(0) 编辑
摘要:DFS + 去重 复杂度 O(n2) 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 100 + 10; int n; char g[N][N]; int xa, 阅读全文
posted @ 2022-08-07 22:19 wKingYu 阅读(18) 评论(0) 推荐(0) 编辑
摘要:A* 算法 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,string> PIS; const int N = 1e6 + 10; string start; in 阅读全文
posted @ 2022-08-07 13:36 wKingYu 阅读(32) 评论(0) 推荐(0) 编辑
摘要:A* 算法 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int> PII; typedef pair<int,PII> PIPII; const int N = 阅读全文
posted @ 2022-08-06 18:24 wKingYu 阅读(9) 评论(0) 推荐(0) 编辑
摘要:双向广搜 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 10 + 10; int n; string A, B; string a[N], b[N]; queue<str 阅读全文
posted @ 2022-08-06 12:38 wKingYu 阅读(25) 评论(0) 推荐(0) 编辑
摘要:DFS + LCA 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; int n, m; int l[N], r[N], p[N]; int d[N]; 阅读全文
posted @ 2022-08-06 10:38 wKingYu 阅读(15) 评论(0) 推荐(0) 编辑
摘要:二分 + BFS 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 20000 + 10; int n, m; int h[N], e[N], ne[N], w[N], id 阅读全文
posted @ 2022-08-05 23:38 wKingYu 阅读(17) 评论(0) 推荐(0) 编辑
摘要:双端队列 BFS 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 500 + 10; const int INF = 0x3f3f3f3f; #define x first 阅读全文
posted @ 2022-08-05 22:41 wKingYu 阅读(25) 评论(0) 推荐(0) 编辑
摘要:BFS + 贪心 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; string start = "12345678"; map<string,int> 阅读全文
posted @ 2022-08-05 17:30 wKingYu 阅读(33) 评论(0) 推荐(0) 编辑
摘要:全集 - 集合的补集 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e5 + 10; const LL mod = 100003; LL n, m; LL qmi(LL 阅读全文
posted @ 2022-08-03 23:30 wKingYu 阅读(23) 评论(0) 推荐(0) 编辑
摘要:构造 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n; vector<int> primes; bool st[N]; void get_p 阅读全文
posted @ 2022-08-03 23:05 wKingYu 阅读(26) 评论(0) 推荐(0) 编辑
摘要:点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n; vector<int> primes; bool st[N]; void get_prim 阅读全文
posted @ 2022-08-03 22:44 wKingYu 阅读(18) 评论(0) 推荐(0) 编辑
摘要:多源 BFS 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; #define x first #define y second int n, m; c 阅读全文
posted @ 2022-08-03 22:17 wKingYu 阅读(16) 评论(0) 推荐(0) 编辑
摘要:带条件的 BFS 最短路 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; int n, m; int d[N]; int bfs(int x) { qu 阅读全文
posted @ 2022-08-02 19:24 wKingYu 阅读(5) 评论(0) 推荐(0) 编辑
摘要:BFS 最短路 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; #define x first #define y second int n, m; 阅读全文
posted @ 2022-08-02 18:38 wKingYu 阅读(27) 评论(0) 推荐(0) 编辑
摘要:BFS 最短路 + 记录方案 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; #define x first #define y second int 阅读全文
posted @ 2022-08-02 18:24 wKingYu 阅读(16) 评论(0) 推荐(0) 编辑
摘要:Flood Fill 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; #define x first #define y second int n; 阅读全文
posted @ 2022-08-02 17:48 wKingYu 阅读(74) 评论(0) 推荐(0) 编辑
摘要:需要处理输入的 Flood Fill 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; #define x first #define y second 阅读全文
posted @ 2022-08-02 17:22 wKingYu 阅读(22) 评论(0) 推荐(0) 编辑
摘要:Flood Fill 问题 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1000 + 10; #define x first #define y second int 阅读全文
posted @ 2022-08-02 16:55 wKingYu 阅读(67) 评论(0) 推荐(0) 编辑

欢迎阅读『2022 年 8月 随笔档案』
点击右上角即可分享
微信分享提示