As you might remember from our previous rounds, Vova really likes computer games. Now he is playing a strategy game known as Rage of Empires. In the game Vova can hire n different warriors; ith warrior has the type ai. Vova wants to create a balanced…
https://www.lydsy.com/JudgeOnline/problem.php?id=2683 知识点:1.以操作的顺序进行分治 2.cdq分治维护矩阵 3.计算比mid小的给比mid大的的贡献 4.容斥原理 code: #include <bits/stdc++.h> #define inf 1000000002 #define ll long long using namespace std; int s,w,m; int ans[]; int t[]; struct que…
Mario is world-famous plumber. His “burly” figure and amazing jumping ability reminded in our memory. Now the poor princess is in trouble again and Mario needs to save his lover. We regard the road to the boss’s castle as a line (the length is n), on…
主席树就是对每个历史版本都建了一颗线段树,这样我们在统计一些问题的时候,对于一个区间[L,R]的询问,就可以利用前缀和的思想找到第L-1和第R颗历史版本的线段树来处理查找.由于这样空间需求就增大了,注意到如果每个版本之间只是多更新了一个点的话,那么这两颗树就只有一条链不相同,我们不妨在前一颗树的基础上建立第二颗树,用链表做链接,这样就达到了节省空间的目的. Kth number Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32…