- 博客(23)
- 收藏
- 关注
原创 stl priority_queue 运算符重载
struct PII1{ int l, r; friend bool operator < (PII1 a, PII1 b){ return a.l>b.l; }};struct PII2{ int l, r; friend bool operator < (PII2 a, PII2 b){ return a.r<b.r; }};struct ...
2018-08-31 17:36:26 221
原创 POJ1459 Power Network Dinic最大流当前弧优化
参考:https://blog.csdn.net/Floatiy/article/details/80961870Power NetworkTime Limit: 2000MS Memory Limit: 32768K Total Submissions:30761 Accepted: 15835 DescriptionA power netwo...
2018-08-31 09:07:27 158
原创 CodeForces 906C Party(状压dp)
参考:https://blog.csdn.net/u013534123/article/details/78887346C. Partytime limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputoutput:standard outputArseny likes to...
2018-08-31 04:37:15 259
原创 dinic复习 poj1273
Drainage DitchesTime Limit: 1000MS Memory Limit: 10000K Total Submissions:85327 Accepted: 33196 DescriptionEvery time it rains on Farmer John's fields, a pond forms over Bessie...
2018-08-30 20:07:12 96
转载 莫队 cf617e
#include<bits/stdc++.h>#define rep(i, j, k) for(int i=j; i<k; i++)#define ll long longusing namespace std;const int maxn =1<<20;struct node{int l, r, id;}Q[maxn];int ...
2018-08-30 00:25:33 176
原创 线性基模板
//小心全局变量a数组会被改变void cal(int n) { cnt = 0; memset(b, 0, sizeof(b)); for (int i = 0; i < n; ++i) for (int j = MAX_BASE; j >= 0; --j) if (a[i] >> j & 1) ...
2018-08-30 00:24:22 217
转载 线段树getid 无敌 嘿嘿
https://www.cnblogs.com/ihopenot/p/9229766.html二话不多说,直接上公式:pos(l,r) = ( l + r ) | ( l != r )这个样子适用于不用动态开点的线段树分配编号,相比直接son[x][L or R] = x<<1|(L or R),不用多开4倍空间;所有叶子节点编号为2,4,6,8,...,2r全为偶数...
2018-08-22 15:17:10 87
原创 1023D. Array Restoration
#include<bits/stdc++.h>using namespace std;#define ll long long#define dprintf if (debug) printf#define rep(i, j, k) for (int i=j; i<k; i++)const int debug = 0;const int maxn = 2e5+50;...
2018-08-18 12:39:08 154
原创 CF916D Jamie and To-do List 主席树 留坑
https://www.luogu.org/problemnew/solution/CF916DD. Jamie and To-do Listtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard outputWhy I ...
2018-08-17 22:04:29 461 2
原创 POJ2104 K-th number主席树
也就这样吧主席树的本质是很多棵形态完全相同的线段树;既然形态完全相同,那么每个节点就可以做减法;权值线段树如何求第k大这个默认你已经会了;n个数求区间第k大,相当于有n个权值线段树,举个例子,比如[1,2,3]这个序列,插入过程中会形成三棵树,三棵树里面存储的权值分别是酱紫的,[1],[1,2],[1,2,3],求[2,3]区间第k大就是第3棵树-第1棵树;按照上面的方式建树肯定会爆...
2018-08-17 21:49:23 125
转载 负下标数组 Codeforces-916B:Jamie and Binary Sequence (changed after round)(思维)
转的 链接忘了 题意:给出n和k,求把n分为k个数的2的幂的和的分法,而且要求最大字典序,且最大的数尽可能多;不行的话输出No;可以的话先输出Yes,在输出序列;#include<bits/stdc++.h>using namespace std;long long n,k;int a[100200],*cnt=a+100000;int main(){ cnt[-...
2018-08-17 01:15:55 157
原创 爆int n次了 今天记一下 怎么找undefined behavior 留坑
safe and easy怎么找 不会啊 怎么用sanitizers??? 留坑
2018-08-17 00:18:50 200
原创 倍增LCA和细节
void makelca(){ rep(j, 1, 23){ rep(i, 1, n+1){ fa[i][j] = fa[fa[i][j-1]][j-1]; ///循环顺序 细节1 } }}int lca(int x, int y){ if (depth[x] < depth[y]) swap(x, y);...
2018-08-16 23:52:12 163
原创 Jamie and Tree( Codeforces 916E) lca + dfs序建线段树
改编自:https://blog.csdn.net/sdut16szq/article/details/79148096 http://www.cnblogs.com/KingSann/articles/9441763.html 算法:LCA,DFS序,线段树区间维护解题思路:首先考虑不对根进行修改,通过对根与询问节点的相对位置关系分析,通过求LCA实现各个操作...
2018-08-16 18:17:12 178
原创 CodeForces 805F Expected diameter of a tree 期望
改编自: CodeForces 805F Expected diameter of a tree 期望证明计算fi方法的正确性 (反证) 注意 tarjan求强连通分量只对有向图使用 无向图使用并查集即可 #include <cstdio>#include <cstring>#include <algorithm>#i...
2018-08-14 21:03:23 167
原创 并查集改进
int findfather(int x){ return par[x]=par[x]==x?x:findfather(par[x]);}bool unite(int a, int b){ int fa=findfather(a), fb=findfather(b); if(fa==fb) return false; if(high[fa...
2018-08-14 17:05:55 188
原创 凸多边形重心与判断点是否在凸多边形内
求凸多边形重心:https://wenku.baidu.com/view/6c113283ec3a87c24028c426.html (有错)一句话概括:固定一点 枚举另两点(连续的)构成三角形 求出这个三角形重心 求平均(加权面积)代码:Point Zhongxin(Point *a,int n){ Point ans=Point(0,0);double ss=0; ...
2018-08-13 21:55:42 1227
原创 Codeforces 989E A Trance of Nightfall 矩阵快速幂+DP
改编自Codeforces 989E A Trance of Nightfall 矩阵快速幂+DP题意:二维平面上右一点集SS,共nn个元素,开始位于平面上任意点PP,PP不一定属于SS,每次操作为选一条至少包含SS中两个元素和当前位置PP的直线,每条直线选取概率相同,同一直线上每个点Q \in SQ∈S 选取概率相同,QQ次询问 包含两个元素t,mt,m 即点PP到tt共操作mm次的最大概...
2018-08-12 22:55:41 313
原创 Codeforces 1020C. Elections 枚举
C. Electionstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputAs you know, majority of students and teachers of Summer Informatics...
2018-08-12 04:48:27 1124 4
转载 Codeforces edu#46 E.We Need More Bosses (无向图tarjan缩点+树的直径)
转载请注明出处:http://tokitsukaze.live/题目链接:http://codeforces.com/problemset/problem/1000/E题意:一条路径上必经的边为关键边,现在让你找一条路径,使得其关键边最多,输出最多的数量。(无向图注意判断返祖)题解:如果一条路径上面有环,那么这个环的任意一条边都不是关键边。所以先缩点,缩点完变成一棵树,那么在一棵树上...
2018-08-07 15:36:47 134
转载 Codeforces Round#489 div2E Nastya and King-Shamans (线段树+暴力剪枝)
转载请注明出处:http://tokitsukaze.live/题目链接:http://codeforces.com/problemset/problem/992/E题意:给一个序列a,q次操作。每次操作单点修改。每次操作后,询问序列a中有没有一个位置满足a[i]=bit[i-1],如果有,随便输出一个位置,如果没有输出-1。其中bit为前缀和数组。题解:容易想到建立线段树维护a[i...
2018-08-06 23:18:04 189
转载 codeforces 992D. Nastya and a Game【思维】
https://blog.csdn.net/Haipai1998/article/details/80740649Nastya and a Game题意:给定一个Arr[n],求满足multipul[L,R]/sum[L,R]==k的区间个数思路:对于a[i]==1的情况,因为对multipul是没有影响的,只影响L,R。那么对于连续的区间1我们就可以跳,只要sum[L,R]∈[sum...
2018-08-06 17:53:04 295
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人