Just a Hook In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic sticks which are of the same length. Now Pudge wants to do some operations on the hook.…
http://acm.uestc.edu.cn/#/problem/show/1057 题意:给你n个数,q次操作,每次在l,r上加上x并输出此区间的sum 题解:线段树模板, #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<stdio.h> using namespace std; ; int a[maxn], n, q, l, r, val; typedef long long ll; struct nod…
题目:https://www.luogu.org/problemnew/show/P3834 无法忍受了,我要写主席树! 解决区间第 k 大查询问题,可以用主席树,像前缀和一样建立 n 棵前缀区间的权值线段树: 然后 n 棵线段树可以共用一些节点: 线段树的 sum 可以相减,利用这个查询即可: 什么嘛,主席树也没我想得那么难(蛮简单的)! 代码如下: #include<iostream> #include<cstdio> #include<cstring> #incl…