HDU4866-Shooting
来源:互联网 发布:linux如何安装win7 编辑:程序博客网 时间:2024/06/10 07:53
Shooting
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2534 Accepted Submission(s): 582
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
Author
FZU
Source
2014 Multi-University Training Contest 1
题意:在一个射击游戏里面,游戏者可以选择地面上[1,X]的一个点射击,并且可以在这个点垂直向上射击最近的K个目标,每个目标有一个价值,价值等于它到地面的距离。游戏中有N个目标,每个目标从L到R,距离地面高度D。每次射击一个目标可以得到目标价值大小的分数,每次射击以后目标不会消失。如果在该点上方的目标个数小于可以射击的次数,那么就当多出来的次数全部射在该点上方最高的目标身上。并且如果你前一次游戏得到的分数如果大于P,那么这次你得到的分数就翻倍
解题思路:主席树,也可以对坐标进行离散化然后再建主席树
#include <iostream>#include <cstdio>#include <cstring>#include <string>#include <algorithm>#include <map>#include <cmath>#include <set>#include <stack>#include <queue>#include <vector>#include <bitset>#include <functional>using namespace std;#define LL long longconst int INF = 0x3f3f3f3f;int n,m,P,X,x,y,z,c,ma;int res,s[100009],nt[200009],v[200009];int ss[100009],L[30*200009],R[30*200009],cnt[30*200009],tot;LL sum[30*200009];void update(int pre,int &now,int l,int r,int val){ now=++tot,L[now]=L[pre],R[now]=R[pre]; cnt[now]=cnt[pre]+val/abs(val),sum[now]=sum[pre]+val; if(l==r) return ; int mid=(l+r)>>1; if(mid>=abs(val)) update(L[pre],L[now],l,mid,val); else update(R[pre],R[now],mid+1,r,val);}LL query(int k,int l,int r,int p){ if(l==r) return 1LL*min(p,cnt[k])*l; int mid=(l+r)>>1; if(cnt[L[k]]<p) return sum[L[k]]+query(R[k],mid+1,r,p-cnt[L[k]]); return query(L[k],l,mid,p);}int main(){ while(~scanf("%d%d%d%d",&n,&m,&X,&P)) { tot=ss[0]=L[0]=R[0]=res=ma=0; memset(s,-1,sizeof s); for(int i=1;i<=n;i++) { scanf("%d%d%d",&x,&y,&z); nt[res]=s[x],s[x]=res,v[res++]=z; nt[res]=s[y+1],s[y+1]=res,v[res++]=-z; ma=max(ma,z); } for(int i=1;i<=X;i++) { int k=ss[i-1]; for(int j=s[i];~j;j=nt[j]) update(k,ss[i],1,ma,v[j]),k=ss[i]; ss[i]=k; } LL pre=1; while(m--) { scanf("%d%d%d%d",&x,&y,&z,&c); pre=(pre>P?2:1)*query(ss[x],1,ma,1LL*(pre*y+z)%c); printf("%lld\n",pre); } } return 0;}
阅读全文
0 0
- HDU4866-Shooting
- HDU4866 Shooting (可持久化线段树)
- 可持久化线段树 HDU4866 Shooting
- Trouble Shooting
- trouble shooting
- Shooting Game
- TYVJ1360Imperishable Shooting
- 2014多校1(1006)hdu4866
- hdu4866(函数式线段树)
- 可持久化线段树(poj2104/hdu4866)
- Shooting an Elephant
- XL Trouble Shooting
- WASCE trouble shooting
- POJ 1719 Shooting Contest
- POJ 1719 Shooting Contests
- Eclipse trouble shooting
- Android trouble shooting 整理
- FreeNX trouble shooting
- codeforces 852I Dating(DFS序,LCA,莫队)
- HDU 5533(计算几何+暴力)
- 第十二章 与Spring集成(三) Shiro权限注解
- C++学习札记
- Unity_设计模式_状态模式_05
- HDU4866-Shooting
- RabbitMQ原理
- 顺序表应用7:最大子段和之分治递归法
- Windows平台异常处理 开发中何时利用异常处理模块
- maven项目环境搭建
- centos7安装jdk环境
- c++(1) 类模板/构造函数/捕获异常 实例
- OSS阿里云存储——整合Spring文件上传,实现动静网站资源分离
- 浅谈单链表和顺序表