[HDU5592] ZYB's Premutation】的更多相关文章

[HDU5592] ZYB's Premutation 题目大意:一个由\([1,n]\)组成的数列,但不知道具体排列,但给出每个前缀的逆序对数目,让你还原排列 Solution 创造一颗\([1,n]\)的权值线段树,初始权值都为\(1\),我们从后往前离线处理,每次拿到一个前缀的逆序对数\(p[i]\),说明在\(i\)上的这个数字\(a_i\)前面有\(sum=p[i]-p[i-1]\)个数字比它大,所以\(a_i\)是\(a_1,\cdots ,a_i\)中第\(i -sum\)大的数字…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5592 题目大意就是给了每个[1, i]区间逆序对的个数,要求复原原序列. 比赛的时候2B了一发. 首先既然给了[1, i-1]和[1, i]区间逆序对的个数,自然可以求出与i组成逆序对的个数,自然就是i前面比i大的个数,自然也就能求出i前面比i小的个数. 然后我考虑最后一个数,由于它在最后一个,所以所有数都在它前面,自然如果知道它前面有多少个比他小的,就知道它是几了.不妨设最后一个是p,然后考虑倒数…
ZYB's Premutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 758    Accepted Submission(s): 359 Problem Description ZYB has a premutation P,but he only remeber the reverse log of each pr…
ZYB's Premutation Accepts: 220 Submissions: 983 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) 问题描述 ZYBZYBZYB有一个排列PPP,但他只记得PPP中每个前缀区间的逆序对数,现在他要求你还原这个排列. (i,j)(i<j)(i,j)(i < j)(i,j)(i<j)被称为一对逆序对当且仅当Ai>AjA_i&g…
最近在线段树的世界里遨游,什么都能用线段树做,这不又一道权值线段树了么. ZYB's Premutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1029    Accepted Submission(s): 528 Problem Description ZYB has a premutation P ,but he o…
ZYB's Premutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 637    Accepted Submission(s): 301 Problem Description ZYB has a premutation P,but he only remeber the reverse log of each pre…
ZYB has a premutation P,but he only remeber the reverse log of each prefix of the premutation,now he ask you to restore the premutation. Pair (i, j)(i < j) is considered as a reverse log if Ai > Aj is matched.Input In the first line there is the num…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 175    Accepted Submission(s): 74 Problem Description ZYB has a premutation P,but he only remeber the reverse log of each prefix of the premutat…
Problem Description ZYBZYBZYB has a premutation PPP,but he only remeber the reverse log of each prefix of the premutation,now he ask you to restore the premutation. Pair (i,j)(i<j)(i,j)(i < j)(i,j)(i<j) is considered as a reverse log if Ai>AjA…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5592 题意: http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=654&pid=1003 题解: 对给的n个数做差分,即a[i]=a[i]-a[i-1],然后对做完差分之后的数组从后往前扫一遍(最后一个数就是代表整个序列中比它大的数有a[n-1]个,即,它是第a[n-1]+1大的数),每次求还未求出的数中的第(a…