随笔分类 -  Segment Tree

摘要:link Given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the integ 阅读全文
posted @ 2020-07-06 04:16 feibilun 阅读(249) 评论(0) 推荐(0)
摘要:link 题解: 按高度升序排序,若高度相同,按宽度降序排序。到i后,用线段树找w,d 在[0,0]-[wi-1,di-1]的最大值,更新此节点。 class Solution { public: unordered_map<int,int> seg[3010<<2]; int qx1,qy1,qx 阅读全文
posted @ 2020-05-27 09:58 feibilun 阅读(187) 评论(0) 推荐(0)
摘要:link Fenwick Tree: class Solution { public: int n; int reversePairs(vector<int>& nums) { n=nums.size(); vector<int> copy=nums; sort(copy.begin(),copy. 阅读全文
posted @ 2020-05-09 17:58 feibilun 阅读(146) 评论(0) 推荐(0)
摘要:link 1. Fenwick Tree: #include <iostream> #include <vector> #include <algorithm> #include <unordered_set> #include <cstring> #include <queue> #include 阅读全文
posted @ 2020-04-27 11:32 feibilun 阅读(103) 评论(0) 推荐(0)
摘要:link 解法: 先DFS给每个节点一个id,然后可以获得每个节点这颗子树的区间(一定是连续的),这样就可以进行线段树的操作(单点修改,区间修改,和区间查询), #define LL long long const int maxn=50005; const int mod=1000000007; 阅读全文
posted @ 2020-04-13 11:18 feibilun 阅读(187) 评论(0) 推荐(0)
摘要:题目链接 题解: copy from: https://www.luogu.com.cn/blog/ryoku/ryoku-di-xin-nian-huan-le-sai-ti-xie segment tree, seg[i]为区间元素个数,每次从剩下的数中找第(b[i]+1)小的数,然后去掉次数( 阅读全文
posted @ 2020-02-01 10:09 feibilun 阅读(228) 评论(0) 推荐(0)