AcWing-摸鱼
yxc牛逼
fwxljwawawawawa
QQ:1320305093
展开
-
C++队列
原题链接#include <iostream>#include <cstring>using namespace std;const int maxn = 100000 + 5;int q[maxn];int m, x, hh, tt = -1;string s;int main(){ cin >> m; while (m --) { cin >> s; if (s == "push") { cin >&g原创 2021-02-28 23:58:56 · 101 阅读 · 0 评论 -
C++栈
原题链接#include <iostream>#include <cstring>using namespace std;const int maxn = 100000 + 5;int stk[maxn];int m, x, tt;string s;int main(){ cin >> m; while (m --) { cin >> s; if (s == "push") { cin >> x;原创 2021-02-28 21:53:54 · 49 阅读 · 0 评论 -
C++01背包
原题链接#include <iostream>#define int long longusing namespace std;const int maxn = 1000 + 5;int volume[maxn], worth[maxn], dp[maxn];signed main(){ int n, v; cin >> n >> v; for (int i = 1; i <= n; i ++) { scanf("%lld %lld原创 2021-02-25 00:00:02 · 88 阅读 · 0 评论 -
C++并查集
原题链接#include <iostream>using namespace std;const int N = 1e5 + 5;int p[N];int find(int x){ if (p[x] != x) { p[x] = find(p[x]); } return p[x];}int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n原创 2021-02-18 23:03:40 · 69 阅读 · 0 评论 -
C++单链表
#include<bits/stdc++.h>using namespace std;const int maxn = 100000 + 5;int head, idx, e[maxn], ne[maxn];void init(){ head = -1; idx = 0;}void add_to_head(int x){ e[idx] = x; ne[idx] = head; head = idx ++;}void add(int k, int x){原创 2021-02-18 22:45:51 · 156 阅读 · 3 评论 -
C++BFS
原题链接#include <bits/stdc++.h>using namespace std;typedef pair<int, int> PII;int n, m;const int maxn = 100 + 5;int g[maxn][maxn], d[maxn][maxn];int bfs(){ queue <PII> q; memset(d, -1, sizeof d); d[0][0] = 0; q.push({0, 0});原创 2021-02-15 20:21:56 · 157 阅读 · 1 评论 -
C++DFS
原题链接#include <bits/stdc++.h>using namespace std;int n;const int maxn = 10;int path[maxn];bool vis[maxn];void dfs(int u){ if (n == u) { for (int i = 0; i < n; i ++) { cout << path[i] << ' '; } cout << endl;原创 2021-02-15 18:42:20 · 214 阅读 · 1 评论 -
C++区间合并
原题链接#include <bits/stdc++.h>#define PII pair<int, int>using namespace std;const int maxn = 100000 + 5;PII a[maxn];int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 0; i < n原创 2021-02-15 17:04:12 · 335 阅读 · 0 评论 -
C++离散化
原题链接#include <bits/stdc++.h>using namespace std;typedef pair<int, int> PII;const int maxn = 3e5 + 15;int a[maxn], s[maxn];vector<int> alls;vector<PII> add, query;int find (int x){ int l = 0, r = alls.size() - 1; whil原创 2021-02-15 15:03:25 · 109 阅读 · 0 评论 -
C++位运算
原题链接#include <bits/stdc++.h>using namespace std;int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; while (n --) { int x; cin >> x; int ans = 0; for (int i = x; i; i -= i & -i)原创 2021-02-09 16:11:50 · 51 阅读 · 0 评论 -
C++双指针算法
原题链接#include <bits/stdc++.h>using namespace std;const int maxn = 100000 + 5;int q[maxn], s[maxn];int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 0; i < n; i ++) { cin >>原创 2021-02-08 23:35:24 · 196 阅读 · 0 评论 -
C++差分
原题链接#include <bits/stdc++.h>using namespace std;const int maxn = 100000 + 5;int a[maxn], b[maxn];void insert(int l, int r, int c){ b[l] += c; b[r + 1] -= c;}int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m ;原创 2021-02-08 22:29:37 · 1133 阅读 · 0 评论 -
C++前缀和
原题链接#include <bits/stdc++.h>#define int long longusing namespace std;const int maxn = 100000 + 5;int a[maxn], s[maxn];signed main(){ int n, m; cin >> n >> m; for (int i = 1; i <= n; i ++) { cin >> a[i]; s[i] =原创 2021-02-08 22:14:07 · 782 阅读 · 0 评论 -
C++二分
原题链接#include <bits/stdc++.h>using namespace std;const int maxn = 100000 + 5;int a[maxn];int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, q; cin >> n >> q; for (int i = 0; i < n; i ++) { cin >原创 2021-02-08 18:08:36 · 82 阅读 · 0 评论 -
C++归并排序
原题链接#include <bits/stdc++.h>using namespace std;const int maxn = 100000 + 5;int q[maxn], temp[maxn];void merge_sort(int q[], int l, int r){ if (l >= r) return; int mid = l + r >> 1; merge_sort(q, l, mid); merge_sort(q, mid +原创 2021-02-08 17:45:15 · 37 阅读 · 0 评论 -
C++快速排序
原题链接摸鱼壬从头开始#include <bits/stdc++.h>using namespace std;const int maxn = 100000 + 5;int q[maxn];void quick_sort (int q[], int l, int r){ if (l >= r) return; int i = l - 1, j = r + 1, x = q[(l + r) >> 1]; while (i < j) {原创 2021-02-07 13:00:27 · 66 阅读 · 4 评论