2014多校1(1006)hdu4866
来源:互联网 发布:小米摄像头app软件 编辑:程序博客网 时间:2024/05/21 10:25
Shooting
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 903 Accepted Submission(s): 180
Problem Description
In the shooting game, the player can choose to stand in the position of [1, X] to shoot, you can shoot all the nearest K targets. The value of K may be different on different shootings. There are N targets to shoot, each target occupy the position of [Li, Ri] , the distance from the starting line is Di(1<=i<=N). Shooting a target can get the bonus points equal to the distance to the starting line. After each shooting targets still exist. Additional, if the previous bonus points is more than P, then as a reward for the shooting present bonus points doubled(and then check the next one). Player wants to know the bonus points he got in each shot.
Input
The input consists several test cases.
The first line has two integers, N, M, X, P(1<=N, M ,X<=100000, P<=1000000000), N represents the total number of target shooting, M represents the number of shooting.
The next N lines of three integers L, R, D (1<=L<=R<=X, 1<=D<=10000000), occupy the position of [L, R] and the distance from the starting line is D.
The next M lines, each line contains four integers x, a, b, c (1<=x<=X, 0<=a,b<=N, 1<=c<=10000000), and K = ( a * Pre + b ) % c. Pre is the bonus point of previous shooting , and for the first shooting Pre=1. It denotes standing in the position x and the player can shoot the nearest K targets.
The first line has two integers, N, M, X, P(1<=N, M ,X<=100000, P<=1000000000), N represents the total number of target shooting, M represents the number of shooting.
The next N lines of three integers L, R, D (1<=L<=R<=X, 1<=D<=10000000), occupy the position of [L, R] and the distance from the starting line is D.
The next M lines, each line contains four integers x, a, b, c (1<=x<=X, 0<=a,b<=N, 1<=c<=10000000), and K = ( a * Pre + b ) % c. Pre is the bonus point of previous shooting , and for the first shooting Pre=1. It denotes standing in the position x and the player can shoot the nearest K targets.
Output
Output M lines each corresponds to one integer.
Sample Input
4 3 5 81 2 62 3 32 4 71 5 22 2 1 53 1 1 104 2 3 7
Sample Output
111018
最开始不知道函数式线段树这东西,一直想用普通线段树搞,真是方法不对劳命伤财啊~
思路:讲所有目标距X轴的距离离散化为函数式线段树的值,然后按区间端点顺序将目标距离插入函数式线段树,左端点+1,右端点-1,分别表示在或不在,注意这里是有多少个区间端点就有多少颗树,每棵树形态大小一样,只是部分节点存的值有差别
树建好之后就是查找了,对于任意一个位置X,可以用二分查找出在X左边离它最近的区间端点,然后在该端点对应的线段树上查找前K个目标的和即可。
这里线段树每个节点只需维护两个值,一个是值的数量,一个是区间总和
0 0
- 2014多校1(1006)hdu4866
- hdu4866(函数式线段树)
- 主席树(多校联合)好题hdu4866
- HDU4866-Shooting
- HDU4866 Shooting (可持久化线段树)
- 可持久化线段树 HDU4866 Shooting
- 可持久化线段树(poj2104/hdu4866)
- 2014多校5(1006)hdu4916(树形DP)
- 2014多校1(1003)hdu4863
- 2014多校1(1002)hdu4862
- 2017多校1 1006Function
- 2014多校7(1006)hdu4940(有上下界的最大流)
- 2014多校(1011)hdu4871
- HDU 4864 Task(2014多校--贪心)
- 2014 (多校)1011 ZCC Loves Codefires
- 2014多校2(1002)hdu4872
- 2014多校9(1007)hdu4966(最小树形图)
- 2014多校5(1008)HDU4918(点分治)
- 收藏别人的推荐
- [LeetCode] Unique Binary Search Trees
- 关于关键字ref和out
- cin问题
- 题目1196:成绩排序
- 2014多校1(1006)hdu4866
- The history of Graph Store(matrix, adjacency list, and orthogonal list)
- hdu 4419
- 开源爬虫软件汇总
- git-cola的安装(SIP + QT4 + PyQt)
- java实现局域网内多人群聊
- BOJ 469. 暑假作业题
- 设计一个Cache系统 【双向链表+哈希表】
- Codeforces Round #259 (Div. 2) D. Little Pony and Harmony Chest