随笔分类 - 数据结构
摘要:Given a integers x = 1, you have to apply Q (Q ≤ 100000) operations: Multiply, Divide. Input First line of the input file contains an integer T(0 incl
阅读全文
摘要:"题目链接" 所有元素初始值为0才能这么做: ①l r全加1 a[l]++; a[r+1] ; 求一遍前缀和为元素本身。 求两遍前缀和为元素前缀和。 include include include include include include include include include inc
阅读全文
摘要:给你一个n个初始元素都为1的序列和m个询问q。 询问格式为:l r x(x为2or3) 最后求1~n所有数的GCD GCD:把每个数分别分解质因数,再把各数中的全部 公有质因数 提取出来连乘,所得的积就是这几个数的最大公约数。 include include include include incl
阅读全文
摘要:【前后缀枚举】
阅读全文
摘要:LCA,最近公共祖先,实现有多种不同的方法,在树上的问题中有着广泛的应用,比如说树上的最短路之类。 LCA的实现方法有很多,比如RMQ、树链剖分等。 今天来讲其中实现较为简单的三种算法: RMQ+时间戳、树上倍增(类似二分步长)、Tarjan算法(DFS+并查集)。
阅读全文
摘要:【模板】洛谷P3865 include include include include include include include include include include include include include include include include include in
阅读全文
摘要:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=2151 Input 第一行三个数n,m,v0 表示有n名萌新和m次调整,初始时全部萌新的集训难度都为v0 第2~m+1行 每行三个数或四个数 0 x y v 表示把 [x,y]区间内的萌新的集训难
阅读全文
摘要:动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说
阅读全文
摘要:Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different genders and that
阅读全文
摘要:题目描述 Farmer John's N (1 include include include include include include include include include include include include include typedef long long ll;
阅读全文
摘要:``` include include include include include include include include include include include include include include include include define debug() put
阅读全文
摘要:B. The Festive Evening time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output It's the end of July –
阅读全文
摘要:C. Little Girl and Maximum Sum time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output The little gi
阅读全文
摘要:【题意】:给你n个可重叠区间和一个参考值k,然后进行q次询问,每次询问也是一个区间,问你该区间中有多少个整数在n个区间中出现次数 =k include include include include include include include include include include in
阅读全文
摘要:差分有:一维差分、多维差分、树上差分 差分标记一般求离线区间问题!(修改完后不再修改,然后修改结束后查询) 对于带有“将一段区间内的每个数全部加上某个值”这种操作的题目,通常考虑差分原数列以简化情况,将对一段区间的操作转化为对某两个特定数的操作。 我们可以用树状数组来维护一个差分序列。差分序列的本质
阅读全文
摘要:这里的关键就是区间加的时候是整个区间 同时 加某个数,所以这个 区间内的公差 还是不变的
阅读全文
摘要:You are given an array d1,d2,…,dn consisting of n integer numbers. Your task is to split this array into three parts (some of which may be empty) in s
阅读全文
摘要:Balanced Lineup Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 62103 Accepted: 29005 Case Time Limit: 2000MS Description For the daily mil
阅读全文