10 2022 档案
摘要:简简单单的并查集,再加上模拟合并找值 #include<bits/stdc++.h>using namespace std;const int N = 2e5 + 7;int f1[N], f2[N];int u1[N], u2[N], v1[N], v2[N];int ans1[N], ans2[
阅读全文
摘要:感觉可以用tarjan,但奈何弱小的我并没有学过QAQ; 这题的坑就在排序上面 #include<bits/stdc++.h>using namespace std;const int N = 1e6 + 7;struct Edge{ int u, v;}a[N];int f[N];bool cmp
阅读全文
摘要:简简单单的一个并查集 #include<bits/stdc++.h>using namespace std;const int N = 1e6 + 7;int u[N], v[N], f[1010];int find (int x) { return f[x] == x ? x : f[x] = f
阅读全文
摘要:哎呦喂!!看错题目啦!!还以为要用最短路, 就写了个dijkstra,呜呜呜,我就说怎么不对, 呜呜呜QAQ!!! #include<bits/stdc++.h>using namespace std; const int N = 1e4 + 7; int f[N];struct Edge{ int
阅读全文
摘要:最小生成树的板子; 使得连通块的数量减小到k即可! 数据有点水(printf("No Answer");根本没用到QAQ)。 #include<bits/stdc++.h>using namespace std;const int N = 1e3 + 7;const int M = 1e4 + 7;
阅读全文
摘要:#include<bits/stdc++.h>using namespace std;const int N = 1e5 + 7;struct Node{ int bn, ed, t;}a[N];int f[N];int find(int x){ return x == f[x] ? x : f[x
阅读全文
摘要:区间查询加单点修改 这个题目写了很久,然后写了一遍后是错的,但是我感觉我的逻辑是没有问题的; 后来又写了一遍,发现还是错了;就放在那儿了; 今天写的时候,终于把错误找出来了: change_tree中的return条件有问题(l == p); 是错的,应改为:(l == r)!!! #include
阅读全文
摘要:搞不懂为啥这样写有问题 不就是线段树的板子吗!!! 为啥会有问题啊QAQ!!! #include<bits/stdc++.h>using namespace std; typedef long long ll; const int N = 2e5 + 7; ll a[N]; struct Tree{
阅读全文
摘要:水题,线段树板子(单点修改和区间和) #include<bits/stdc++.h>using namespace std; typedef unsigned long long ull; const int N = 1e5 + 7; ull a[N], tree[N * 4]; void chan
阅读全文
摘要:我靠,居然忘记怎么写单调队列了,废了废了QAQ #include<bits/stdc++.h>using namespace std; const int N = 1e6 + 7; int a[N], q[N]; int main(){ int n, k; scanf("%d%d", &n, &k)
阅读全文
摘要:线段树板子题(水题) #include<bits/stdc++.h>using namespace std; const int N = 1e5 + 7; int a[N], tree[N * 4]; void build_tree(int l, int r, int i){ if(l == r){
阅读全文
摘要:利用大根堆和小根堆的性质,进行维护, 大根堆的元素要一直小于GET的次数(也就是i),每一次操作后都要进行大根堆的元素增加 也就是p.push(q.top()), q.pop();这一步操作!!!!! #include <bits/stdc++.h>using namespace std; cons
阅读全文
摘要:1.归并排序方法求逆对 (方法相同于P1908 逆序对) #include<bits/stdc++.h>using namespace std; const int N = 5e5 + 7; int a[N], st[N];long long ans = 0;void merge_sort(int
阅读全文