HDU 5592 ZYB's Premutation
来源:互联网 发布:天刀天香御姐捏脸数据 编辑:程序博客网 时间:2024/06/07 03:39
题目链接
传送门
题意
对于一个一到
分析
我们倒着来考虑,
Code
#include <cstdio>#include <cstring>#include <algorithm>#include <vector>#define lson num<<1#define rson num<<1|1#define gl l,m,lson#define gr m+1,r,rson#define PARA int l,int r,int numusing namespace std;const int MAXN = 5e4+100;struct SegTree { int st[MAXN<<2]; void init() { memset(st,0,sizeof(st)); } void update(int pos,int v,PARA) { int m = l+r>>1; if(l==r) st[num]+=v; else { if(m>=pos) update(pos,v,gl); else update(pos,v,gr); st[num]=st[lson]+st[rson]; } } int find(int k,PARA) { if(l==r) return l; int m = l + r >> 1; if(st[rson]>=k) return find(k,gr); else return find(k-st[rson],gl); }} S;int a[MAXN];int main() { int t,n; scanf("%d",&t); while(t--) { scanf("%d",&n); S.init(); a[0]=0; for(int i=1; i<=n; i++) { scanf("%d",a+i); S.update(i,1,1,n,1); } vector<int >ans; for(int i=n; i>=1; i--) { int k=a[i]-a[i-1]+1; int val=S.find(k,1,n,1); ans.push_back(val); S.update(val,-1,1,n,1); } for(int i=n-1; i>0; i--) printf("%d ",ans[i]); printf("%d\n",ans[0]); } return 0;}
1 0
- HDU 5592 ZYB's Premutation
- HDU 5592 ZYB's Premutation
- HDU 5592 ZYB's Premutation
- HDU 5592 ZYB's Premutation
- hdu 5592 ZYB's Premutation
- HDU 5592 ZYB's Premutation 线段树
- hdu 5592 ZYB's Premutation (线段树)
- HDU 5592(ZYB's Premutation-线段树)
- 续hdu 5592 ZYB's Premutation
- hdu 5592 ZYB's Premutation 线段树
- hdu-5592 ZYB's Premutation(线段树)
- hdu 5529 ZYB's Premutation
- HDU 5592:ZYB's Premutation 树状数组+二分
- HDU 5592 ZYB's Premutation(二分+树状数组)
- hdu 5592 ZYB's Premutation(线段树求逆序数)
- HDU 5592 ZYB's Premutation(树状数组 + 二分)
- hdu 5592 ZYB's Premutation(线段树)
- HDU.5592 ZYB's Premutation(线段树求第k大)
- LINQ
- 机器学习中的相似性度量
- 零基础入门学习Python(3):数据类型
- jQuery实现的虚拟键盘
- ,工程项目创建流程,目录结构的一半格式,工程中pod进来的用<>,bundle命名的作用,用处怎么用兼容读个版本,pch文件创建
- HDU 5592 ZYB's Premutation
- Android监听键盘状态变化
- SHELL编程
- jsp Request获取url信息的各种方法比较
- C#类型转换总结(三)各类型转化实例
- JSP内置对象
- 列表中的导航菜单的制作
- ECSHOP后台SQL查询提示错误 this sq May contain
- 反向迭代器