05 2022 档案
摘要:不使用 vector 的写法 点击查看代码 #include<iostream> #include<cmath> using namespace std; // 计算 n 有多少位 int dgt(int n) { int res = 0; while (n) { res ++; n /= 10;
阅读全文
摘要:类比完全背包 复杂度 总体复杂度 点击查看代码 #include<iostream> using namespace std; const int N = 1010, mod = 1e9 + 7; int n;
阅读全文
摘要:复杂度 总体复杂度 点击查看代码 #include<iostream> using namespace std; const int N = 300 + 10; int n; int s[N]; int f[N
阅读全文
摘要:复杂度 总体复杂度 点击查看代码 #include<iostream> using namespace std; const int N = 1010; int n, m; char a[N], b[N]; in
阅读全文
摘要:复杂度 总体复杂度 点击查看代码 #include<iostream> using namespace std; const int N = 1010; int n, m; char a[N]
阅读全文
摘要:线性 dp 复杂度 点击查看代码 #include<iostream> using namespace std; const int N = 1010; int n; int a[N], f[N]; int main() { cin >> n; for (int i = 0
阅读全文
摘要:使用一维数组优化 复杂度 总体复杂度 点击查看代码 #include<iostream> using namespace std; const int N = 510, INF = 1e9; int n; int a
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 110; int n, m; int v[N][N], w[N][N], s[N]; int f[N]; int main() { cin >> n >> m; for (int
阅读全文
摘要:1. 朴素做法(会超时) 点击查看代码 #include<iostream> using namespace std; const int N = 1010; int n, m; int v[N], w[N]; int f[N][N]; int main() { cin >> n >> m; for
阅读全文
摘要:1. 朴素做法(二维数组) 点击查看代码 #include<iostream> using namespace std; const int N = 1010; int n, m; int v[N], w[N]; int f[N][N]; int main() { cin >> n >> m; fo
阅读全文
摘要:点击查看代码 #include<iostream> #include<cstring> #include<unordered_set> using namespace std; const int N = 110; int n; int f[N]; int sg(int x) { if (f[x]
阅读全文
摘要:点击查看代码 #include<iostream> #include<cstring> #include<unordered_set> using namespace std; const int N = 110, M = 1e4 + 10; int k, n; int s[N], f[M]; //
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; int main() { int n; cin >> n; int res = 0; for (int i = 1; i <= n; i ++) { int x; scanf("%d", &x); if (
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; int main() { int n; cin >> n; int res = 0; while (n --) { int x; scanf("%d", &x); res ^= x; } if (res)
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; typedef long long LL; const int N = 20; int n, m; int p[N]; int main() { cin >> n >> m; for (int i = 0;
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; typedef long long LL; const int mod = 1e9 + 7; int qmi(int a, int k) { int res = 1; while (k) { if (k &
阅读全文
摘要:点击查看代码 #include<iostream> #include<vector> using namespace std; const int N = 5e3 + 10; int primes[N], cnt, sum[N]; bool st[N]; void get_primes(int n)
阅读全文
摘要:递推 复杂度 总体复杂度 点击查看代码 #include<iostream> using namespace std; const int N = 2e3 + 10, mod = 1e9 + 7; int c[N
阅读全文
摘要:复杂度 总体复杂度 点击查看代码 #include<iostream> using namespace std; const int N = 110; int n, a[N][N]; int gauss() { i
阅读全文
摘要:复杂度 总体复杂度 点击查看代码 #include<iostream> #include<cmath> using namespace std; const int N = 110; const double ep
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; typedef long long LL; LL exgcd(LL a, LL b, LL & x, LL & y) { if (!b) { x = 1, y = 0; return a; } LL d =
阅读全文
摘要:复杂度 总体复杂度 点击查看代码 #include<iostream> using namespace std; const int N = 1e6 + 10; typedef long long LL; int primes[N], cnt; int eul
阅读全文
摘要:点击查看代码 #include<iostream> #include<cstring> 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
阅读全文
摘要:点击查看代码 #include<iostream> #include<cstring> using namespace std; const int N = 1e5 + 10, M = 2 * N; int n, m; int h[N], e[M], ne[M], idx; int color[N]
阅读全文
摘要:复杂度 点击查看代码 #include<iostream> #include<algorithm> using namespace std; const int N = 1e5 + 10, M = 2 * N, INF = 0x3f3f3f3f; int n, m;
阅读全文
摘要:点击查看代码 #include<iostream> #include<cstring> using namespace std; const int N = 510, INF = 0x3f3f3f3f; int n, m; int g[N][N]; int dist[N]; bool st[N];
阅读全文
摘要:复杂度 点击查看代码 #include<iostream> using namespace std; const int N = 210, INF = 1e9; int n, m, k; int d[N][N]; void floyd() { for (int k = 1;
阅读全文
摘要:点击查看代码 #include<iostream> #include<cstring> #include<queue> using namespace std; const int N = 1e5 + 10; int n, m; int h[N], e[N], ne[N], w[N], idx; i
阅读全文
摘要:点击查看代码 #include<iostream> #include<cstring> #include<queue> using namespace std; const int N = 1e5 + 10; int n, m; int h[N], e[N], ne[N], w[N], idx; i
阅读全文
摘要:点击查看代码 #include<iostream> #include<cstring> using namespace std; const int N = 510, M = 1e5 + 10; int n, m, k; int dist[N], last[N]; struct Edge { int
阅读全文
摘要:复杂度 点击查看代码 #include<iostream> #include<cstring> #include<queue> using namespace std; typedef pair<int, int> PII; const int N = 1e6 + 1
阅读全文
摘要:复杂度 点击查看代码 #include<iostream> #include<cstring> using namespace std; const int N = 510; int n, m; int g[N][N], dist[N]; bool st[N]; int d
阅读全文
摘要:点击查看代码 #include<iostream> #include<cstring> #include<queue> using namespace std; const int N = 1e5 + 10; int n, m; int h[N], e[N], ne[N], idx; int d[N
阅读全文
摘要:点击查看代码 #include<iostream> #include<cstring> #include<queue> using namespace std; const int N = 1e5 + 10; int n, m; int h[N], e[N], ne[N], idx; int d[N
阅读全文
摘要:点击查看代码 #include<iostream> #include<cstring> using namespace std; const int N = 1e5 + 10, M = 2 * N; int n, ans = N; int h[N], e[M], ne[M], idx; bool s
阅读全文
摘要:点击查看代码 #include<iostream> #include<queue> #include<unordered_map> using namespace std; int bfs(string start) { string end = "12345678x"; queue<string>
阅读全文
摘要:BFS 使用STL中的queue 点击查看代码 #include<iostream> #include<cstring> #include<queue> using namespace std; typedef pair<int, int> PII; const int N = 100 + 10;
阅读全文
摘要:DFS 按行枚举 时间复杂度 点击查看代码 #include<iostream> using namespace std; const int N = 20; int n; char g[N][N]; bool col[N], dg[N], udg[N]; void dfs(in
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 10; int n, path[N]; bool st[N]; void dfs(int u) { if (u > n) { for (int i = 1; i <= n; i
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; typedef unsigned long long ULL; const int N = 1e5 + 10; const int P = 131; int h[N], p[N]; char str[N];
阅读全文
摘要:拉链法 点击查看代码 #include<iostream> #include<cstring> using namespace std; const int N = 1e5 + 3; int h[N], e[N], ne[N], idx; void insert(int x) { int k = (
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int h[N], sz, m; int ph[N], hp[N]; void heap_swap(int a, int b) { swap(ph[hp[a]
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int h[N], sz; void down(int u) { int t = u; if (2 * u <= sz && h[2 * u] < h[t])
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int p[N], sz[N]; int find(int x) { if (p[x] != x) p[x] = find(p[x]); return p[x
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int p[N]; int find(int x) { if (p[x] != x) p[x] = find(p[x]); return p[x]; } in
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; const int M = 5e6 + 10; int son[M][2], idx; int a[N]; void insert(int x) { int
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 6e5 + 10; int son[N][26], cnt[N], idx; char str[N]; void insert(char str[]) { int p = 0;
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; const int M = 1e6 + 10; int ne[N]; int main() { int n, m; char p[N], s[M]; cin
阅读全文