2017年11月9日

POJ1741

摘要: #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int maxn=10010; int N,K; int ans,root,Max; struct node { int v,next,w... 阅读全文

posted @ 2017-11-09 19:56 very_czy 阅读(130) 评论(0) 推荐(0) 编辑

HDU5971

摘要: #include using namespace std; typedef long long ll; vector e[1010]; int color[1010]; int tst[1010]; int vis[1010]; int ans; int num[1010]; int fa[1010]; int Find(int x) { int r=x; while (fa... 阅读全文

posted @ 2017-11-09 13:57 very_czy 阅读(266) 评论(0) 推荐(0) 编辑

2017年9月10日

ZKW优化费用流

摘要: #include using namespace std; typedef long long ll; double pi=acos(-1.0); double eps=1e-8; const int mod=1e9+7; bool vis[200001]; int dist[200001]; int n,m,s,t,ans=0; int nedge=-1,p[200001],c[200001... 阅读全文

posted @ 2017-09-10 11:47 very_czy 阅读(391) 评论(0) 推荐(0) 编辑

2017年5月5日

codeforces 786B legacy 线段树建图

摘要: http://www.cnblogs.com/jianrenfang/p/6622404.html 会长的代码很朴实,很平易近人。就是区间最短路。 阅读全文

posted @ 2017-05-05 14:25 very_czy 阅读(210) 评论(0) 推荐(0) 编辑

2017年4月20日

树的重心

摘要: const int N = 50005; const int INF = 1<<30; int head[N]; int son[N]; bool vis[N]; int cnt,n; int num,size; int ans[N]; struct Edge { int to; int next; }; Ed... 阅读全文

posted @ 2017-04-20 17:18 very_czy 阅读(162) 评论(0) 推荐(0) 编辑

树的直径

摘要: 输出这个点能到的最大值,还有次大值。 阅读全文

posted @ 2017-04-20 16:44 very_czy 阅读(144) 评论(0) 推荐(0) 编辑

2017年4月14日

并查集+按秩合并

摘要: #include using namespace std; const int N = 5e5+50; int n,lst; struct UnionTable { int f[N],s[N],v[N],d[N]; void init(int n) { for(int i=1; is[f2]) f[f2]=f1,v[f2]=c,s[f1]+=s[f2... 阅读全文

posted @ 2017-04-14 20:38 very_czy 阅读(1081) 评论(0) 推荐(0) 编辑

2016年12月7日

线段树区间更新,区间求和,最大值,最小值模板

摘要: 转自http://blog.csdn.net/acmer_ak/article/details/52002537 vector<vector <int> > a(m ,vector<int>(n,0)); //m*n的二维vector,所有元素为0 vector<vector <int> >a; a 阅读全文

posted @ 2016-12-07 23:26 very_czy 阅读(2949) 评论(0) 推荐(0) 编辑

2016年11月16日

树链剖分 hdu3966 (kuangbin)

摘要: 最简单的点修改,也是树链剖分的第一题。 树链剖分是一种把树分成一条条链,一般是按照儿子的轻重划分以达到查询最优(因为儿子多,命中的概率也大,因此如果直接找到祖先就很完美了)。 以下是kuangbin神的代码 阅读全文

posted @ 2016-11-16 21:02 very_czy 阅读(155) 评论(0) 推荐(0) 编辑

2016年11月7日

扩展lucas定理

摘要: i64 POW(i64 a,i64 b,i64 mod) { i64 ans=1; while(b) { if(b&1) ans=ans*a%mod; a=a*a%mod; b>>=1; } return ans; } i64 POW(i64 a,i64 b) { i64 ans=1; wh... 阅读全文

posted @ 2016-11-07 22:23 very_czy 阅读(352) 评论(0) 推荐(0) 编辑

导航