随笔分类 -  数据结构

cf1321E
摘要:很像二维偏序,我们把武器和怪物放在一起排序按照攻击力递增的顺序,顺序扫描,这样攻击力满足了要求,然后防御力可以用一个线段树来处理,具体看代码 #include<iostream> #include<cstdio> #include<cstring> #include<vector> #include 阅读全文

posted @ 2020-03-03 21:01 欣崽 阅读(274) 评论(0) 推荐(0)

cf1131D
摘要:题意:总共有n+m个点,每一个点都有一个val,给出一个n*m的矩阵,矩阵中第i行第j列的为=,表示 i 点 和 j+n个点的值相等,<表示i 点比j+n个点的值小,> 刚好相反 要求用最少的值给每一个点确定一个val,满足如上那个矩阵,如果不存在输出Yes 存在输出每一个点的val 题解:大小关系 阅读全文

posted @ 2020-02-21 19:18 欣崽 阅读(244) 评论(0) 推荐(0)

楼房重建 HYSBZ - 2957
摘要:线段树更新,合并左右节点时利用递归函数 阅读全文

posted @ 2019-05-09 22:10 欣崽 阅读(227) 评论(0) 推荐(1)

Vasya and a Tree CodeForces - 1076E
摘要:很好的思维 转化为对树上的深度差分 回朔的思想 对查询离线 阅读全文

posted @ 2019-04-08 21:58 欣崽 阅读(189) 评论(0) 推荐(0)

codeforceCodeForces - 1107G
摘要:单调栈 RMQ 阅读全文

posted @ 2019-04-08 21:24 欣崽 阅读(223) 评论(0) 推荐(0)

线段树模板
摘要:int a[maxn]; struct Segment_Tree { #define maxn 100005 #define ls o>1; sum[ls]+=(mid-l+1)*add[o]; sum[rs]+=(r-mid)*add[o]; add[ls]+=add[o]; add[rs]+=add[o]; ... 阅读全文

posted @ 2019-04-03 22:35 欣崽 阅读(205) 评论(0) 推荐(0)

网格中的极大子矩形的另类解法
摘要:http://www.doc88.com/p-9042008501060.html 论文说的很清楚 Cricket FieldUVALive - 2689 附送代码 阅读全文

posted @ 2019-04-01 23:36 欣崽 阅读(218) 评论(0) 推荐(0)

斜率优化
摘要:Average UVALive - 4726 http://www.docin.com/p-881778722.html 这个论文说的很清楚 阅读全文

posted @ 2019-04-01 21:22 欣崽 阅读(193) 评论(0) 推荐(0)

Largest Rectangle in a Histogram POJ - 2559
摘要:很显然是单调栈 这里记录一种新的写法,这种写法基于递推,但是相比之下比单调栈更好写 阅读全文

posted @ 2019-03-03 17:29 欣崽 阅读(198) 评论(0) 推荐(0)

Game with string CodeForces - 1104B
摘要:虽然只是B题,还是div2的 但感觉挺有意思,所以写一篇博客记录一下 最初的想法是利用DP去做,f[s]=true表示字符串s对应先手赢,否则对应后手赢,大致想了下发现是指数级别的算法,看了下范围直接pass掉 然后就接着想,发现如果两个相等的字符被消掉之后,相等字符的周边靠过来,如果还能消除的话他 阅读全文

posted @ 2019-03-03 01:31 欣崽 阅读(325) 评论(0) 推荐(0)

差分数组
摘要:思想不错,但感觉很鸡肋 https://www.cnblogs.com/aininot260/p/9304521.html 这道题运用了差分数组 http://codeforces.com/blog/entry/65079 阅读全文

posted @ 2019-02-26 21:55 欣崽 阅读(152) 评论(0) 推荐(0)

Petya and Array CodeForces - 1042D
摘要:很不错的一道题 给你一个长度为n的数组,问共有多少个区间满足区间之和小于给定的数t 这种题一般做法肯定是枚举,固定左端点枚举右端点,枚举的过程需要优化,否则就是n方 这道题我先求一个前缀和,然后逆着枚举,显然问题转化为了对于一个数,如果寻找他右边的数哪些小于它+t,这就转化为了区间求和,可以树状数组 阅读全文

posted @ 2019-02-14 12:02 欣崽 阅读(177) 评论(0) 推荐(0)

AC自动机模板
摘要:const int SIGMA_SIZE = 26; const int MAXNODE = 11000; struct AhoCorasickAutomata { int ch[MAXNODE][SIGMA_SIZE]; int f[MAXNODE]; // fail函数 int val[MAXNODE]; // 每个字符串的结尾结点都有一个非0的val ... 阅读全文

posted @ 2019-02-11 21:50 欣崽 阅读(183) 评论(0) 推荐(0)

KMP模板
摘要:struct KMP { void print() { } void GetFail(char *P,int *f) { int m=strlen(P); f[0]=f[1]=0; for(int i=1; i<m; i++) { int j=f[i]; while(j&&P... 阅读全文

posted @ 2019-02-11 21:49 欣崽 阅读(177) 评论(0) 推荐(0)

bitset常用用法
摘要:b.any() b中是否存在置为1的二进制位?b.none() b中不存在置为1的二进制位吗?b.count() b中置为1的二进制位的个数b.size() b中二进制位数的个数b[pos] 访问b中在pos处二进制位b.test(pos) b中在pos处的二进制位置为1么?b.set() 把b中所 阅读全文

posted @ 2019-02-07 14:47 欣崽 阅读(246) 评论(0) 推荐(0)

字典树
摘要:#include using namespace std; #define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) const int maxnode=700000+5; const int sigma_size=26; const int mod=20071027; char tmp[200+5]; char st[... 阅读全文

posted @ 2019-01-24 23:35 欣崽 阅读(179) 评论(0) 推荐(0)

ST表
摘要://ST表#include #define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) //#define int long long using namespace std; const int maxn=100000+5; int d[maxn][32]; void RMQ_init(int *A,int n) { f... 阅读全文

posted @ 2019-01-24 12:11 欣崽 阅读(204) 评论(0) 推荐(0)

树状数组
摘要:uvalive4329 阅读全文

posted @ 2019-01-24 11:31 欣崽 阅读(180) 评论(0) 推荐(0)

自定义结构体 Map
摘要:struct Hashmap{ static const int Ha=999917,maxe=46340; int E,lnk[Ha],son[maxe+5],nxt[maxe+5],w[maxe+5]; int top,stk[maxe+5]; void clear() {E=0;while(top) lnk[stk[top--]]=0;} void ... 阅读全文

posted @ 2018-12-08 12:43 欣崽 阅读(396) 评论(0) 推荐(0)

导航