Live2d Test Env

随笔分类 -  RMQ---树状数组

摘要:题意:现在给定空空的三维平面,有加点操作和询问立方体点数。 思路:考虑CDQ套CDQ。复杂度是O(NlogN*logN*logN),可以过此题。 具体的,这是一个四维偏序问题,4维分别是(times,x,y,z);我们知道cdq可以求出t<=T,x=X,y<=Y,在套一层就可以z<=Z了。那么一个立 阅读全文
posted @ 2019-09-13 09:05 nimphy 阅读(299) 评论(0) 推荐(0) 编辑
摘要:题意:询问区间有多少个连续的段,而且这段的颜色在[L,R]才算贡献,每段贡献是1。 有单点修改和区间查询。 思路:46min交了第一发树套树,T了。 稍加优化多交几次就过了。 不难想到,除了L这个点,其他的点都可以只统计这一段的段首。把位置看成x,颜色看成y,就成了二维平面就矩形内点的个数,这就是裸 阅读全文
posted @ 2019-09-12 10:58 nimphy 阅读(338) 评论(3) 推荐(0) 编辑
摘要:链接:https://ac.nowcoder.com/acm/contest/926/D来源:牛客网 在一维坐标系中,给定 n条有颜色的线段,第 i条线段的左右端点分别为 li​和 ri​,此外它的颜色为 ci​。 给定m个查询,每个查询给定一个区间 [a,b],需要求出这个区间完全包含的线段中有多 阅读全文
posted @ 2019-08-20 21:51 nimphy 阅读(208) 评论(0) 推荐(0) 编辑
摘要:pro:给定N+1个点的树,有M对关键点,现在让你破坏最少的点,使得M对关键点不连通。 sol:贪心,我们把M对点按照LCA深度排序,每次破坏LCA。 如果一对点(u,v,lca),u-lca-v有点被破坏,则可以不用破坏新的点。 我们可以用dfs序+树状数组来处理。 如果破坏了一个点,则给它的子树 阅读全文
posted @ 2019-04-23 10:16 nimphy 阅读(280) 评论(0) 推荐(0) 编辑
摘要:Sample Input Sample Output Prof.Q is a sophisticated professor who has insights into quadrillions of sorting algorithms, especially into bubble sort. 阅读全文
posted @ 2019-01-04 18:38 nimphy 阅读(714) 评论(0) 推荐(0) 编辑
摘要:A permutation of size n is an array of size n such that each integer from 1 to n occurs exactly once in this array. An inversion in a permutation p is 阅读全文
posted @ 2018-12-31 15:54 nimphy 阅读(361) 评论(0) 推荐(0) 编辑
摘要:n players are going to play a rock-paper-scissors tournament. As you probably know, in a one-on-one match of rock-paper-scissors, two players choose t 阅读全文
posted @ 2018-12-25 20:37 nimphy 阅读(405) 评论(0) 推荐(0) 编辑
摘要:Vasya has decided to build a zip-line on trees of a nearby forest. He wants the line to be as long as possible but he doesn't remember exactly the hei 阅读全文
posted @ 2018-08-31 21:49 nimphy 阅读(342) 评论(0) 推荐(0) 编辑
摘要:题意:给定字符串char[],以及Q个操作,操作有三种: 1:pos,chr:把pos位置的字符改为chr 2:pos:问以pos为中心的回文串长度为多长。 3:pos:问以pos,pos+1为中心的回文串长度为多长。 思路:用hash表示一段字符串或者连续子串。我们用BIT记录hash前缀和,那么 阅读全文
posted @ 2018-08-20 21:20 nimphy 阅读(210) 评论(0) 推荐(0) 编辑
摘要:The best programmers of Embezzland compete to develop a part of the project called "e-Government" — the system of automated statistic collecting and p 阅读全文
posted @ 2018-06-30 22:40 nimphy 阅读(472) 评论(0) 推荐(0) 编辑
摘要:墨墨购买了一套N支彩色画笔(其中有些颜色可能相同),摆成一排,你需要回答墨墨的提问。墨墨会像你发布如下指令: 1、 Q L R代表询问你从第L支画笔到第R支画笔中共有几种不同颜色的画笔。 2、 R P Col 把第P支画笔替换为颜色Col。为了满足墨墨的要求,你知道你需要干什么了吗? Input 第 阅读全文
posted @ 2018-06-24 14:16 nimphy 阅读(398) 评论(0) 推荐(0) 编辑
摘要:DCE Coders admins are way much geekier than they actually seem! Kartik has been following that tradition lately. How? Well, he took the inversion coun 阅读全文
posted @ 2018-05-19 09:30 nimphy 阅读(674) 评论(4) 推荐(0) 编辑
摘要:You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number 阅读全文
posted @ 2018-03-22 19:12 nimphy 阅读(259) 评论(0) 推荐(0) 编辑
摘要:You are given n segments on a line. There are no ends of some segments that coincide. For each segment find the number of segments it contains. Input 阅读全文
posted @ 2018-03-15 21:09 nimphy 阅读(396) 评论(2) 推荐(0) 编辑
摘要:Given an N*N matrix A, whose elements are either 0 or 1. A[i, j] means the number in the i-th row and j-th column. Initially we have A[i, j] = 0 (1 <= 阅读全文
posted @ 2018-01-05 15:15 nimphy 阅读(820) 评论(0) 推荐(0) 编辑
摘要:You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number 阅读全文
posted @ 2018-01-05 14:07 nimphy 阅读(278) 评论(0) 推荐(0) 编辑
摘要:Suppose that the fourth generation mobile phone base stations in the Tampere area operate as follows. The area is divided into squares. The squares fo 阅读全文
posted @ 2018-01-03 21:30 nimphy 阅读(437) 评论(0) 推荐(1) 编辑
摘要:You may have wondered why most extraterrestrial life forms resemble humans, differing by superficial traits such as height, colour, wrinkles, ears, ey 阅读全文
posted @ 2017-12-11 17:42 nimphy 阅读(585) 评论(0) 推荐(0) 编辑
摘要:Time limit per test: 1.0 seconds Memory limit: 256 megabytes Time limit per test: 1.0 seconds Memory limit: 256 megabytes Time limit per test: 1.0 sec 阅读全文
posted @ 2017-12-09 12:54 nimphy 阅读(358) 评论(0) 推荐(0) 编辑
摘要:题意: 给出一个矩阵,初始每个位置上的值都为0,然后有两种操作 一种是更改某个位置上的值 另一种是求某个位置附近曼哈顿距离不大于K的所有位置的值的总和 技巧: 坐标旋转,使得操作之后菱形变成方方正正的矩形,(即“曼哈顿距离”转化为“切比雪夫距离”)方便使用树状数组进行计算。 利用哈希进行离散,节约空 阅读全文
posted @ 2017-12-04 13:57 nimphy 阅读(357) 评论(0) 推荐(0) 编辑

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