题目大意:给定一个序列,以最小代价将其变成单调不增或单调不减序列,求最小的变动价值;需要用到离散化dp状态转移方程:dp[i][j]=abs(j-w[i])+min(dp[i-1][k]);(k 2 #include 3 #include 4 #include 5 #include 6 using ...
分类:
其他好文 时间:
2015-04-14 16:35:05
阅读次数:
164
题意:给你n个可以重复的无序数列,问经过k次相邻交换后最少还有多少对逆序数
求逆序对可以用树状数组来做,对于重复的元素,可能在sort的时候交换编号
求和的时候要注意去重,还有一种方法就是稳定排序stable_sort
#include
#include
#include
using namespace std;
#define ll __int64
#define N 100000+10
...
分类:
编程语言 时间:
2015-04-14 10:01:37
阅读次数:
132
Splay 离散化+Splay维护序列…… 好吧主要说一下我做这道题遇到的几个错误点: 1.离散化 2.由于找到的这个数的位置一定是大于等于 i 的,所以其实在把它splay到根以后,i 结点只能splay到它的左儿子,而不是右儿子……而且相应的,代表这个区间的应该是c[c[root][0]...
分类:
编程语言 时间:
2015-04-14 00:19:07
阅读次数:
218
之前我的离散化方法一直用set和map做,感觉使用stl不够优越。刚刚发现线段树PPT给了一种离散化的新姿势。。。
分类:
其他好文 时间:
2015-04-12 20:59:59
阅读次数:
115
题意:给你一串序列,不断的将一个数 取出来放在最前面,不断的询问 rank位 和 数的rank,解题思路:1)线段树 + 树状数组(需要离散化)2)Splay ,我把抽出来的建树,所以不是那么方便,可以离散化直接建树,这样会方便一点。解题代码: 1 // File Name: hdu3436.pb....
分类:
其他好文 时间:
2015-04-09 10:26:15
阅读次数:
213
【标签】离散化,数据结构,分治,图论
【题意】
You are given a tree with N nodes.
The tree nodes are numbered from 1 to N.
Each node has an integer weight.
We will ask you to perfrom the following operation:
u v :...
分类:
其他好文 时间:
2015-04-08 18:06:15
阅读次数:
184
Mayor's posters
Time Limit: 1000MS
Memory Limit: 65536K
Total Submissions: 46857
Accepted: 13601
Description
The citizens of Bytetown, AB, could not stand that the ca...
分类:
其他好文 时间:
2015-04-08 13:17:40
阅读次数:
135
Boring Counting
Time Limit: 3000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
In this problem you are given a number sequence P consisting of N integer and Pi is the ith element in the sequence. No...
分类:
编程语言 时间:
2015-04-07 09:58:52
阅读次数:
146
【转】主席树:对于序列的每一个前缀建一棵以序列里的值为下标的线段树(所以要先离散化),记录该前缀序列里出现的值的次数;记离散后的标记为1~n; (下面值直接用1~n代替;)对于区间[x,y]的第k大的值,那么从root[x-1],root[y]开始,t=root[y].[1,mid]-root[x-...
分类:
其他好文 时间:
2015-04-05 21:49:20
阅读次数:
122
题目地址:SDUT 2159
这题的数据很水。。几乎所有人都是水过去的。。网上也没找到正解,全是水过去的。于是我来第一发正解23333。
首先,可以想到的是先离线下来,然后对行离散化,然后对于每行的所有列用set去存,那么怎么去找最小的行有大于给出列的列数呢?这时候线段树就可以登场了,用线段树来维护每一行的出现的最大列,这样就可以用线段树去搜了。然后删除添加操作同...
分类:
其他好文 时间:
2015-04-05 12:02:22
阅读次数:
156