文章分类 -  ACM

摘要:P1017 [NOIP 2000 提高组] 进制转换 #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back typedef pair<int, int> PII; const i 阅读全文
posted @ 2025-05-30 11:06 awei040519 阅读(12) 评论(0) 推荐(0)
摘要:1. stringstream 1.1 stringstream 基本用法 #include <bits/stdc++.h> using namespace std; signed main(){ stringstream stream; int first, second; stream << " 阅读全文
posted @ 2025-04-15 17:12 awei040519 阅读(7) 评论(0) 推荐(0)
摘要:二分图的最大匹配 #include <bits/stdc++.h> using namespace std; const int N = 510, M = 1e5 + 10; int n1, n2, m; int h[N], e[M], ne[M], idx; bool st[N]; int mat 阅读全文
posted @ 2025-04-07 20:46 awei040519 阅读(15) 评论(0) 推荐(0)
摘要:染色法判定二分图 #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, M = N * 2; int n, m; int h[N], e[M], ne[M], idx; bool st[N]; int color[ 阅读全文
posted @ 2025-04-07 20:36 awei040519 阅读(13) 评论(0) 推荐(0)
摘要:Kruskal算法求最小生成树 #include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int n, m; int p[N]; struct Edge{ int u, v, w; bool operator < (c 阅读全文
posted @ 2025-04-07 20:25 awei040519 阅读(14) 评论(0) 推荐(0)
摘要:Prim算法求最小生成树 #include <bits/stdc++.h> using namespace std; const int N = 510, INF = 0x3f3f3f3f; int n, m; int g[N][N], dis[N]; bool st[N]; int res; vo 阅读全文
posted @ 2025-04-07 20:20 awei040519 阅读(95) 评论(0) 推荐(0)
摘要:spfa判断负环 #include <bits/stdc++.h> using namespace std; typedef pair<int, int> PII; const int N = 150010; int n, m; int h[N], e[N], ne[N], w[N], idx; i 阅读全文
posted @ 2025-04-07 20:14 awei040519 阅读(8) 评论(0) 推荐(0)
摘要:spfa求最短路 #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int h[N], e[N], ne[N], w[N], idx; int n, m; int dis[N]; bool st[N]; voi 阅读全文
posted @ 2025-04-07 20:07 awei040519 阅读(19) 评论(0) 推荐(0)
摘要:Floyd求最短路 #include <bits/stdc++.h> using namespace std; const int N = 210; const int INF = 1e9; int n, m, k; int g[N][N]; void floyd(){ for(int k = 1; 阅读全文
posted @ 2025-04-07 19:58 awei040519 阅读(15) 评论(0) 推荐(0)
摘要:最大异或对 #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, M = 31 * N; int n; int a[N]; int son[M][2], idx; void insert(int x){ int p 阅读全文
posted @ 2025-04-07 15:17 awei040519 阅读(18) 评论(0) 推荐(0)
摘要:Trie字符串统计 #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int son[N][26], cnt[N], idx; char str[N]; void insert(){ int p = 0; fo 阅读全文
posted @ 2025-04-07 15:06 awei040519 阅读(10) 评论(0) 推荐(0)
摘要:字符串哈希板子 #include <bits/stdc++.h> using namespace std; typedef unsigned long long ULL; const int N = 1e5 + 10, P = 131; int n, m; char str[N]; ULL p[N] 阅读全文
posted @ 2025-04-07 15:00 awei040519 阅读(13) 评论(0) 推荐(0)
摘要:KMP板子 #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; string s, p; int ne[N]; signed main(){ int n, m; cin >> n >> p >> m >> s; 阅读全文
posted @ 2025-04-05 21:53 awei040519 阅读(11) 评论(0) 推荐(0)
摘要:滑动窗口 #include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10; int n, k; int a[N], q[N]; signed main(){ scanf("%d%d", &n, &k); for(int i = 阅读全文
posted @ 2025-04-05 21:43 awei040519 阅读(10) 评论(0) 推荐(0)
摘要:1.试除法求约数 #include <bits/stdc++.h> using namespace std; int n, a; vector<int> res; signed main(){ scanf("%d", &n); while(n--){ res.clear(); scanf("%d", 阅读全文
posted @ 2025-04-05 20:37 awei040519 阅读(11) 评论(0) 推荐(0)
摘要:1. 分解质因数 #include <bits/stdc++.h> using namespace std; int n, a; signed main(){ scanf("%d", &n); while(n--){ scanf("%d", &a); for(int i = 2; i <= a / 阅读全文
posted @ 2025-04-05 20:23 awei040519 阅读(8) 评论(0) 推荐(0)
摘要:离散化板子 #include <bits/stdc++.h> using namespace std; typedef pair<int, int> PII; const int N = 3e5 + 10; int a[N], sum[N]; vector<int> alls; vector<PII 阅读全文
posted @ 2025-04-05 19:10 awei040519 阅读(26) 评论(0) 推荐(0)
摘要:区间合并板子 #include <bits/stdc++.h> using namespace std; const int N = 100010; typedef pair<int, int> PII; PII a[N]; int n; vector<PII> ans; signed main() 阅读全文
posted @ 2025-04-05 19:09 awei040519 阅读(11) 评论(0) 推荐(0)
摘要:高精度加法板子 #include <bits/stdc++.h> using namespace std; vector<int> A, B, C; string a, b; signed main(){ cin >> a >> b; for(int i = a.size() - 1; i >= 0 阅读全文
posted @ 2025-04-05 17:05 awei040519 阅读(26) 评论(0) 推荐(0)
摘要:归并排序求逆序对的数量 #include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int n; int a[N], tmp[N]; long long merge_sort(int l, int r){ if(l >= 阅读全文
posted @ 2025-04-05 16:07 awei040519 阅读(15) 评论(0) 推荐(0)