摘要: 在计算机科学中,并查集是一种树型的数据结构,其保持着用于处理一些不相交集合(Disjoint Sets)的合并及查询问题。有一个联合-查找算法(union-find algorithm)定义了两个操作用于此数据结构: Find:确定元素属于哪一个子集。它可以被用来确定两个元素是否属于同一子集。 Un 阅读全文
posted @ 2017-01-19 19:52 _Koreyoshi 阅读(382) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h>using namespace std;int a[101],b[101],n;int main(){ cin>>n; for (int i=1;i<=n;i++) cin>>a[i]; for (int i=1;i<=n;i++) for (int j 阅读全文
posted @ 2017-01-19 19:39 _Koreyoshi 阅读(235) 评论(0) 推荐(0) 编辑
摘要: #include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#define N 100010#define INF 0xfffffusing namespace std;int n, m, q, x, y, cn 阅读全文
posted @ 2017-01-19 19:38 _Koreyoshi 阅读(96) 评论(0) 推荐(0) 编辑
摘要: #include <cstdio>#include <cstring>#include <iostream>#include <algorithm>typedef long long ll;using namespace std; ll n,m,i,j,k; struct Matrix { ll a 阅读全文
posted @ 2017-01-19 19:35 _Koreyoshi 阅读(112) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h>using namespace std; int exGcd(int a,int b,int &x,int &y) { if(b==0) { x=1; y=0; return a; } int r=exGcd(b,a%b,x,y); int t=x; x 阅读全文
posted @ 2017-01-19 19:33 _Koreyoshi 阅读(157) 评论(0) 推荐(0) 编辑
摘要: #include<cstdio>typedef long long ll;const int maxn=100005;ll d[maxn],id[maxn],s[maxn],k;int n,m,c,x,y;void add(ll*b,int p,ll v){for(;p<=n;p+=p&-p)b[p 阅读全文
posted @ 2017-01-19 19:31 _Koreyoshi 阅读(113) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h>using namespace std;const int maxx = 100000 + 10;int Heap[maxx];int main() { int n,num = 0,x; scanf("%d",&n); for(int i=1; i<=n 阅读全文
posted @ 2017-01-19 19:30 _Koreyoshi 阅读(162) 评论(0) 推荐(0) 编辑