摘要: 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 阅读(25) 评论(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 阅读(27) 评论(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 阅读(18) 评论(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 阅读(29) 评论(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 阅读(17) 评论(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 阅读(17) 评论(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 阅读(21) 评论(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 阅读(13) 评论(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 阅读(16) 评论(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 阅读(20) 评论(0) 推荐(0) 编辑