Live2d Test Env

随笔分类 -  分治

摘要:题意:给定数组a[],求区间个数,满足区间的数各不同,而且满足maxval-len<=K; 思路:一看就可以分治做,对于当前的区间,从max位置分治。 对于这一层,需要高效的统计答案,那么对短的一边开始统计。 (这个过程很像启发式的逆过程,所以叫做启发式分治 1,对于数不同,这个可以预处理前缀和后缀 阅读全文
posted @ 2019-08-21 17:21 nimphy 阅读(977) 评论(0) 推荐(0) 编辑
摘要:A思路:排个序建立最短路树即可,可以双指针实现。 考察:贪心,构造。 B:显然最大值取决于a[],出现的最高位不同的那一位,假设有最高位的分到A组,不然分到B组,分组后,各取一个x,y,那么ans=min(x^y),这个可以字典树实现。 比较常规。 但是比赛的时候我以为字典树空间不够只能得80分。所 阅读全文
posted @ 2019-08-19 13:29 nimphy 阅读(292) 评论(0) 推荐(0) 编辑
摘要:题意:给定N,表示N堆石子,每堆石子数为a[],问多少个区间,可以满足“石子总和若为偶数,那么可以两两取来自不同堆的石子,直到取完; 如果为奇数,那么排除其中一个,然后可以两两取来自不同堆的石子,直到取完”。 思路:结论是,如果一个区间的区间和大于等于区间最大值的两倍,则这个区间合法。 考虑分治,我 阅读全文
posted @ 2019-07-26 17:32 nimphy 阅读(663) 评论(0) 推荐(0) 编辑
摘要:题意:给定一棵树,有点权a[],有边权。 现在有M次修改点权的操作,输出每次修改后,Σ(a[i]^a[j])*dis(i,j); 思路:因为待修改,我们需要快速得到以及修改一个点到其他所有点的信息。 肯定就是动态点分治了啊。 而异或这个操作没有什么累加的性质,所以每一位拆开单独计算。 根据二进制位置 阅读全文
posted @ 2019-07-19 17:33 nimphy 阅读(280) 评论(0) 推荐(0) 编辑
摘要:题目连接:https://www.luogu.org/problemnew/show/U60884 题意:有N个点,标号为1∼N,用N−1条双向带权通道连接,保证任意两个点能互相到达。 Q次询问,问从编号为x的点到达标号L∼R的点其中一个点的最小距离是多少。 说明 :N,Q<1e5,边权<1e4; 阅读全文
posted @ 2019-07-16 15:21 nimphy 阅读(348) 评论(0) 推荐(0) 编辑
摘要:题目:在一片土地上有N个城市,通过N-1条无向边互相连接,形成一棵树的结构,相邻两个城市的距离为1,其中第i个城市的价值为value[i]。 不幸的是,这片土地常常发生地震,并且随着时代的发展,城市的价值也往往会发生变动。 接下来你需要在线处理M次操作: 0 x k 表示发生了一次地震,震中城市为x 阅读全文
posted @ 2019-07-12 11:31 nimphy 阅读(248) 评论(0) 推荐(0) 编辑
摘要:题意:一个序列被称作是不无聊的,当且仅当,任意一个连续子区间,存在一个数字只出现了一次,问给定序列是否是不无聊的。 思路:每次找到一个只出现了一次的点,其位置的pos,那么继续分治[L,pos-1],[pos1+1,R];为了保证分治的复杂度,每次的复杂度应该是拆开后较小的哪个。 可以类比启发式合并 阅读全文
posted @ 2019-07-11 17:06 nimphy 阅读(677) 评论(0) 推荐(0) 编辑
摘要:题意:有一个厨师,他买菜-做菜-买菜-做菜....-做菜,一共有N天,他的冰箱里只能有一个菜,在他做菜的第二天才会买菜,如果菜不做,放在冰箱里,每天新鲜程度会下降1。 第一天也会买菜,第i天的菜新鲜程度的Fi,厨艺是Ci,(厨艺会增长),要求这一天做的菜的新鲜长度大于等于Li。 思路:即dpi=ma 阅读全文
posted @ 2019-02-06 11:28 nimphy 阅读(308) 评论(0) 推荐(0) 编辑
摘要:You are given a tree consisting of n vertices. A number is written on each vertex; the number on vertex i is equal to ai . Let's denote the function g 阅读全文
posted @ 2019-01-12 10:01 nimphy 阅读(864) 评论(0) 推荐(0) 编辑
摘要:题意:给定N个组合,每个组合有a和b,现在求最长序列,满足a不升,b不降。 思路:三位偏序,CDQ分治。 但是没想到怎么输出最小字典序,我好菜啊。 最小字典序: 我们倒序CDQ分治,ans[i]表示倒序的以i为结尾的最长序列,如果当前的ans[i]==目前最大,而且满足序列要求,就输出。 阅读全文
posted @ 2018-11-05 23:07 nimphy 阅读(272) 评论(0) 推荐(0) 编辑
摘要:JRY wants to drag racing along a long road. There are nn sections on the road, the ii-th section has a non-negative integer length sisi. JRY will choo 阅读全文
posted @ 2018-09-18 10:25 nimphy 阅读(445) 评论(0) 推荐(0) 编辑
摘要:lyk拥有一个区间。 它规定一个区间的价值为这个区间中所有数and起来的值与这个区间所有数or起来的值的乘积。 例如3个数2,3,6。它们and起来的值为2,or起来的值为7,这个区间对答案的贡献为2*7=14。 现在lyk有一个n个数的序列,它想知道所有n*(n+1)/2个区间的贡献的和对1000 阅读全文
posted @ 2018-06-14 22:49 nimphy 阅读(219) 评论(0) 推荐(0) 编辑
摘要:对于一个 11 到 nn 的排列 p1,p2,⋯,pnp1,p2,⋯,pn ,我们可以轻松地对于任意的 1≤i≤n1≤i≤n 计算出 (li,ri)(li,ri) ,使得对于任意的 1≤L≤R≤n1≤L≤R≤n 来说 min(pL,pL+1,⋯,pR)=pimin(pL,pL+1,⋯,pR)=pi  阅读全文
posted @ 2018-06-14 21:03 nimphy 阅读(385) 评论(0) 推荐(0) 编辑
摘要:You are given a tree consisting of nn vertices. A number is written on each vertex; the number on vertex ii is equal to aiai. Let's denote the functio 阅读全文
posted @ 2018-06-14 18:07 nimphy 阅读(849) 评论(0) 推荐(0) 编辑
摘要:#include<bits/stdc++.h> using namespace std; const int maxn=100010; int num[26],used[26]; char c[maxn],ans[maxn]; int main() { int L,i; scanf("%s",c+1 阅读全文
posted @ 2018-06-11 09:26 nimphy 阅读(258) 评论(0) 推荐(0) 编辑
摘要:In the lattice points of the coordinate line there are n radio stations, the i-th of which is described by three integers: xi — the coordinate of the  阅读全文
posted @ 2018-05-31 16:54 nimphy 阅读(291) 评论(0) 推荐(0) 编辑
摘要:https://www.cnblogs.com/OYzx/p/5506468.html BZOJ2863:(允许离线) 题目大意:给定一个n*n的矩形,以及若干个操作,操作有如下两种: 1.给矩形的(x,y)加上一个v; 2.询问某个子矩阵的权值和。 数据范围:n<=5*10^5,操作数<=2*10 阅读全文
posted @ 2018-05-31 11:45 nimphy 阅读(163) 评论(0) 推荐(0) 编辑
摘要:Jon fought bravely to rescue the wildlings who were attacked by the white-walkers at Hardhome. On his arrival, Sam tells him that he wants to go to Ol 阅读全文
posted @ 2018-05-29 12:44 nimphy 阅读(272) 评论(0) 推荐(0) 编辑
摘要:Given a sequence of N pairs of integers, find the length of the longest increasing subsequence of it. An increasing sequence A1..An is a sequence such 阅读全文
posted @ 2018-05-28 22:16 nimphy 阅读(269) 评论(0) 推荐(0) 编辑
摘要:Little Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply th 阅读全文
posted @ 2018-05-28 18:34 nimphy 阅读(360) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示