- 博客(37)
- 资源 (1)
- 收藏
- 关注
原创 splay(伸展树)的实现
数据结构之伸展树 http://dongxicheng.org/structure/splay-tree/ 伸展树 http://www.cnblogs.com/kernel_hcy/archive/2010/03/17/1688360.html BZOJ 1500: [NOI2005]维修数列 (splay tree) http://www.cnblogs.com/k
2017-02-27 23:42:44 392
原创 POJ1201-Intervals-线段树+贪心
原题链接 题意:给定一些区间,每个区间里必须取ci个数,这些数组成一个集合z,求z的最少的元素数 思路:由于如果两个区间如果有重复取的元素,那么这个元素一定是在左边的这个区间的最右边的那些元素。所以我们按照区间的右边界排序后,总是如果当前区间还需要取数,那么就从右往左取还没有被取的数即可。然后就可以用线段树来维护一段区间内已经被取走的数的总数。这样问题的复杂度就降到了O(NlogN)的程度了#i
2017-02-22 16:34:40 660
原创 POJ3368-Frequent values-离散化+线段树
原题链接 题意:给定一个非严格单调增数列,请快速求解一个区间内出现最频繁的数的频次。 思路:其实就是把相同的值合并成三个信息,即相同的值的数量,左端点,右端点。这样我们就可以把问题分为三种情况 1、属于同一个区间:答案就是它们之间的大小 2、属于相邻区间:找到它们的分隔点,取两个区间大小的较大者 3、属于两个不相邻的区间:取出头尾两个区间,计算它们的大小。对于中间的一个或多个区间,它们都是
2017-02-21 22:44:39 294
原创 离散化思想
离散化,把无限空间中有限的个体映射到有限的空间中去,以此提高算法的时空效率。 通俗的说,离散化是在不改变数据相对大小的条件下,对数据进行相应的缩小。例如: 原数据:1,999,100000,15;处理后:1,3,4,2; 原数据:{100,200},{20,50000},{1,400}; 处理后:{3,4},{2,6},{1,5};#include <iostream>#include <
2017-02-21 16:04:37 332
原创 POJ2886-Who Gets the Most Candies?-树状数组
原题链接 题意:N个熊孩子围成一个圈,从第K个开始淘汰,每淘汰一个,出示手中的数字(数字非0且绝对值可能有10^8这么大),决定下一个淘汰者,正数表示从这个孩子开始顺时针的第n个,负数反之。每个人可以拿到的存活回数的因数个数的糖果,求拿到最多糖果数的孩子的名字以及糖果数。 思路:首先根据不同的出局的数可以得出其因子数,为了快速处理我们可以使用类似于素数筛的方式得到。然后其实就是用树状数组实现约瑟
2017-02-21 12:58:45 310
原创 POJ2155-Matrix-二维树状数组
原题链接 题意:给定一个初始为0的矩阵,每次可以使一个方块内的数由0变成1或者由1变成0,询问某一点是1还是0 思路:普通修改肯定过不了,但是有一点,某一个点如果被改变k次那么这个点就是k&1或者说k%2。基于这个思路,我们可以用树状数组方便地得出某一个点被修改过多少次。假设sum[i][j]可以求得i,j这个点被改变的次数,那么如果我们给出12 2C 1 1 2 2Q 2 2这组数据,那
2017-02-20 21:37:32 255
原创 POJ3109-Inner Vertices-离散化+扫描线
Inner Vertices Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 2422 Accepted: 666 Case Time Limit: 2000MS DescriptionThere is an infinite square grid. Some vertices of the grid
2017-02-20 18:12:31 615
原创 线段树的实现
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int tree_maxsize = (1<<18) + 1;//代表最多的二叉树的节点const int maxn = 100...
2017-02-19 20:41:13 356
原创 POJ1990-MppFest-树状数组
原题链接 MooFest Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 7357 Accepted: 3299 DescriptionEvery year, Farmer John’s N (1 <= N <= 20,000) cows attend “MooFest”,a social gatheri
2017-02-18 17:49:41 285
原创 POJ2991-Crane-线段树+计算几何
原题链接 Crane Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 6253 Accepted: 1673 Special Judge DescriptionACM has bought a new crane (crane – jeřáb) . The crane consists o...
2017-02-17 22:21:04 452
原创 POJ2392-Space Elevator-多重背包
原题链接 Space Elevator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11392 Accepted: 5433 DescriptionThe cows are going to space! They plan to achieve orbit by building a sort
2017-02-17 09:29:18 245
原创 POJ3666-Making the Grade-dp
原题链接 Making the Grade Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6861 Accepted: 3176 DescriptionA straight dirt road connects two fields on FJ’s farm, but it changes elevat
2017-02-17 09:26:50 231
原创 POJ1631-Bridging signals-最长上升子序列
原题链接 Bridging signals Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 13755 Accepted: 7474 Description‘Oh no, they’ve done it again’, cries the chief designer at the Waferlan
2017-02-17 09:23:39 280
原创 POJ1065-Wooden Sticks-最长下降子序列
原题链接 Wooden Sticks Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 22711 Accepted: 9731 DescriptionThere is a pile of n wooden sticks. The length and weight of each stick are
2017-02-17 09:21:47 423
原创 POJ3181-Dollar Dayz-完全背包+高精度
原题链接 Dollar Dayz Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6768 Accepted: 2538 DescriptionFarmer John goes to Dollar Days at The Cow Store and discovers an unlimited nu...
2017-02-17 09:17:09 554
原创 POJ1742-Coins-多重背包
原题链接 Coins Time Limit: 3000MS Memory Limit: 30000K Total Submissions: 36108 Accepted: 12247 DescriptionPeople in Silverland use coins.They have coins of value A1,A2,A3…An Silverland dol
2017-02-16 21:48:49 294
原创 POJ3280-Cheapest Palindrome-区间dp
原题链接 Cheapest Palindrome Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9310 Accepted: 4494 DescriptionKeeping track of all the cows can be a tricky task so Farmer John has ins
2017-02-16 21:46:36 205
原创 POJ3616-Milking Time-区间动态规划
原题链接 Milking Time Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8764 Accepted: 3647 DescriptionBessie is such a hard-working cow. In fact, she is so focused on maximizing her
2017-02-16 21:45:03 360
原创 POJ2385-Apple Catching-简单dp
原题链接 Apple Catching Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11850 Accepted: 5738 DescriptionIt is a little known fact that cows love apples. Farmer John has two apple
2017-02-16 21:41:20 422
原创 POJ2229-Sumsets-完全背包
原题链接 Sumsets Time Limit: 2000MS Memory Limit: 200000K Total Submissions: 17986 Accepted: 7052 DescriptionFarmer John commanded his cows to search for different sets of numbers that sum
2017-02-16 21:39:44 298
原创 POJ3176-Cow Bowling-简单dp
原题链接 Cow Bowling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 18427 Accepted: 12264 DescriptionThe cows don’t use actual bowling balls when they go bowling. They each take
2017-02-16 21:35:29 389
原创 POJ2236-Wireless Network-并查集
原题链接 Wireless Network Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 25542 Accepted: 10621 DescriptionAn earthquake takes place in Southeast Asia. The ACM (Asia Cooperated M
2017-02-16 21:25:47 225
原创 POJ2010-Moo University - Financial Aid-优先队列
原题链接 Moo University - Financial Aid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8703 Accepted: 2537 DescriptionBessie noted that although humans have many universities they
2017-02-16 21:23:12 304
原创 POJ3614-Sunscreen-优先队列
原题链接 Sunscreen Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8079 Accepted: 2861 DescriptionTo avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cove
2017-02-16 21:21:15 357
原创 POJ2376-Cleaning Shifts-区间贪心
原题链接 Cleaning Shifts Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 19831 Accepted: 5047 DescriptionFarmer John is assigning some of his N (1 <= N <= 25,000) cows to do some
2017-02-16 21:19:41 317
原创 POJ3050-Hopscotch-穷竭搜索
原题链接 Hopscotch Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3968 Accepted: 2634 DescriptionThe cows play the child’s game of hopscotch in a non-traditional way. Instead of a
2017-02-16 21:17:37 338
原创 POJ3187-Backward Digit Sums-穷竭搜索
原题链接 Backward Digit Sums Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6887 Accepted: 3998 DescriptionFJ and his cows enjoy playing a mental game. They write down the numbers
2017-02-16 21:16:10 278
原创 POJ2718-Smallest Difference-穷竭搜索
原题链接 Smallest Difference Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10032 Accepted: 2752 DescriptionGiven a number of distinct decimal digits, you can form one integer b
2017-02-16 21:11:55 206
原创 POJ3669-Meteor Shower-BFS
原题链接 Meteor Shower Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 18098 Accepted: 4704 DescriptionBessie hears that an extraordinary meteor shower is coming; reports say tha
2017-02-16 21:06:43 289
原创 POJ3009-Curling 2.0-DFS
原题链接 Curling 2.0 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 19909 Accepted: 8136 DescriptionOn Planet MM-21, after their Olympic games this year, curling is getting popu
2017-02-16 21:02:19 193
原创 POJ1979-Red and Black-DFS染色
原题链接 Red and Black Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 33776 Accepted: 18319 DescriptionThere is a rectangular room, covered with square tiles. Each tile is color
2017-02-16 20:59:14 313
原创 POJ1222-EXTENDED LIGHTS OUT-反转
原题链接 EXTENDED LIGHTS OUT Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 9955 Accepted: 6434 DescriptionIn an extended version of the game Lights Out, is a puzzle with 5 rows of
2017-02-16 20:50:57 224
原创 POJ3185-The Water Bowls-反转问题
原题链接 The Water Bowls Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6210 Accepted: 2443 DescriptionThe cows have a line of 20 water bowls from which they drink. The bowls can b
2017-02-16 20:45:35 339
原创 POJ3111-K Best-最大化平均值
原题链接 K Best Time Limit: 8000MS Memory Limit: 65536K Total Submissions: 9788 Accepted: 2510 Case Time Limit: 2000MS Special Judge DescriptionDemy has n jewels. Each of her jewels has s
2017-02-16 20:34:28 357
原创 POJ2976-Dropping tests-最大化平均值
原题链接 Dropping tests Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11056 Accepted: 3857 DescriptionIn a certain course, you take n tests. If you get ai out of bi questions c
2017-02-16 20:31:04 260
原创 排列组合与集合的实现
本文借鉴于《挑战程序设计竞赛》第二版P156到P157页的内容自己实现,首先我们应该知道的是常用集合运算的位运算: (1) 空集:0; (2) 只含有第i个元素的集合:1<#include <cstdio>#include <iostream>using namespace std;int used[10000];int main(){ int n; cin >>
2017-02-02 21:37:20 982
vega56刷64所需工具及文件修正版
2019-01-08
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人