文章分类 - 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
阅读全文
摘要:1. stringstream 1.1 stringstream 基本用法 #include <bits/stdc++.h> using namespace std; signed main(){ stringstream stream; int first, second; stream << "
阅读全文
摘要:二分图的最大匹配 #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
阅读全文
摘要:染色法判定二分图 #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[
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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
阅读全文
摘要: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;
阅读全文
摘要:最大异或对 #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
阅读全文
摘要: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
阅读全文
摘要:字符串哈希板子 #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]
阅读全文
摘要: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;
阅读全文
摘要:滑动窗口 #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 =
阅读全文
摘要: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",
阅读全文
摘要: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 /
阅读全文
摘要:离散化板子 #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
阅读全文
摘要:区间合并板子 #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()
阅读全文
摘要:高精度加法板子 #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
阅读全文
摘要:归并排序求逆序对的数量 #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 >=
阅读全文

浙公网安备 33010602011771号