随笔分类 - 基础算法
摘要:异或的性质 点击查看代码 #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
阅读全文
摘要:递推 点击查看代码 #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
阅读全文
摘要:二分 + 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
阅读全文
摘要:差分 + 贪心 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e5 + 10; int n; int a[N], b[N]; void solve() { cin >>
阅读全文
摘要:位运算 大数乘法 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 5e5 + 10; LL a, b, p; void solve() { cin >> a >> b >>
阅读全文
摘要:递推 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e5 + 10; char a[10][10]; char g[10][10]; int dx[] = {0, -1
阅读全文
摘要:点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 2e5 + 10; int n, m; int x[N], t[N]; vector<int> a, b, c; int f
阅读全文
摘要:等价变形 + 前缀和 + 单调栈 + 二分 点击查看代码 #include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e6 + 10; int n, res; int a[N]; LL s[N];
阅读全文
摘要:点击查看代码 #include<iostream> #include<vector> #include<algorithm> using namespace std; typedef pair<int, int> PII; vector<PII> segs; void merge(vector<PI
阅读全文
摘要:点击查看代码 #include<iostream> #include<vector> #include<algorithm> using namespace std; typedef pair<int, int> PII; const int N = 3e5 + 10; vector<int> al
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; int lowbit(int x) { return x & -x; } int main() { int n; scanf("%d", &n); while (n --) { int x; scanf("
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N], b[N]; int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 0;
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N], b[N]; int main() { int n, m, x; scanf("%d %d %d", &n, &m, &x); for (i
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N], s[N]; int main() { int n, res = 0; scanf("%d", &n); for (int i = 0; i
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e3 + 10; int a[N][N], b[N][N]; void insert(int x1, int y1, int x2, int y2, int c) { b[x1
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N], b[N]; void insert(int l, int r, int c) { b[l] += c; b[r + 1] -= c; }
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e3 + 10; int a[N][N], s[N][N]; int main() { int n, m, q; scanf("%d %d %d", &n, &m, &q);
阅读全文
摘要:点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N], s[N]; int main() { int n, m; scanf("%d %d", &n, &m); for (int i = 1;
阅读全文
摘要:点击查看代码 #include<iostream> #include<vector> #include<algorithm> using namespace std; vector<int> div(vector<int>& A, int b, int &r) { vector<int> C; fo
阅读全文
摘要:点击查看代码 #include<iostream> #include<vector> using namespace std; vector<int> mul(vector<int>& A, int b) { vector<int> C; int t = 0; for (int i = 0; i <
阅读全文