ACM_数据结构
文章平均质量分 86
zhj5chengfeng
这个作者很懒,什么都没留下…
展开
-
C++中class和struct的区别
从语法上,在C++中(只讨论C++中)。class和struct做类型定义时只有两点区别: (一)默认继承权限。如果不明确指定,来自class的继承按照private继承处理,来自struct的继承按照public继承处理; (二)成员的默认访问权限。class的成员默认是private权限,struct默认是public权限。 除了这两点,class和struct基本就是一个东转载 2012-04-28 20:01:37 · 485 阅读 · 0 评论 -
UESTC Training for Data Structures——L
Problem L Problem DescriptionNow and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for原创 2012-05-02 21:29:57 · 459 阅读 · 0 评论 -
UESTC Training for Data Structures——M
Problem M Problem DescriptionYou have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to each number in a given inte原创 2012-05-02 21:30:53 · 587 阅读 · 0 评论 -
UESTC Training for Data Structures(总结)
UESTC Training for Data Structures 第一次的专题讲座总算是AK了。数据结构,多么熟悉的字眼,最怕的就是线段树了,但偏偏这套题中 13 道就有 5 道线段树!恼火。 题目分布: 线段树:D (扫描线求矩形面积并) G (并查集+线段树) H、I、M (线段树的基本操作) 树状原创 2012-05-02 21:05:26 · 819 阅读 · 0 评论 -
划分树(我的体会)
关于划分树,我没有百度,只是听说有这么个东西,可以在 log(n) 的时间内,查找出来区间 [st , en] 的第 k 大的值 , 再看了一下人家的代码,自己 YY 的,一下的内容全部是原创,绝对的原滋原味,要是和标准的定义有什么出入,欢迎指正,我懒得去百度了,能用来解决问题就行了一、什么是划分树? 就是给一串数,用类似线段树的结构来存储它,怎么存储?假设我们把父亲表示的区间中原创 2012-07-19 00:51:17 · 1256 阅读 · 0 评论 -
K-D tree 数据结构
首先来一个问题: 给定平面上一个点集 E ,还有一个定点 V ,怎么在一群点中找出一个点 U,使得 V 与 U 的距离最近(欧几里得距离)?当然,我们能够想到一种做法:枚举 E 中所有的点,找出它们中距离V 最近的点 U。但是,假设现在有两个点集 E1 与 E2 ,对于 E2 中每一个点 Vi ,找出一个在E1 中的一个点 Ui,使得 Vi 到 Ui 的距离最短,这怎么做?还是枚原创 2012-08-11 20:13:11 · 20021 阅读 · 10 评论 -
树形结构转线形结构——树链剖分——子树问题
昨天遇到了这样一道题目: 一个公司有 n 个员工,编号从 0 到 n-1 ,每个员工都有一个直系上司,编号为 0 的是整个公司的董事长(包工头),现在,给出每个员工每月的初始工资,为了鼓励最佳员工和最佳部门,现在,董事会会有以下两种询问: 1、employee x y z :询问员工 x 的工资,如果员工的 x 的工资小于 y原创 2012-08-17 21:38:46 · 2153 阅读 · 0 评论 -
Jewel——2010 天津赛区 J 题
一大清早起来 A 掉一道划分树+树状数组+离散化的题+近200行代码的题,勉强算是弥补了今晚不能做 CF 的遗憾了吧,该死的,怎么会这个时候交我回家呢?!! 题很裸,一看就知道是划分树求区间第 k 值 + 树状数组 给出题目连接,懒得写 html 了:http://livearchive.onlinejudge.org/index.php?option=co原创 2012-08-27 10:52:22 · 1439 阅读 · 0 评论 -
Codeforces Round #149 (Div. 2) E. XOR on Segment
题意 给你 n(1 1、 1 L R :询问区间 [L, R] 中所有数的和,并输出 2、 2 L R XOR :把区间 [L, R] 中的每个数换成原数与 XOR 异或得到的新数做法分析 典型的线段树,这里需要运用异或运算的一个性质: a^b 得到原创 2012-11-12 23:19:13 · 12733 阅读 · 0 评论 -
SPOJ GSS 1. Can you answer these queries I
题意 给一个含有 n(1做法分析 用线段树维护一段区间 [L, R] 内的: Lmax:包括左边 a[L] 在内的最大连续和 Rmax:包括右边 a[R} 在内的最大连续和 sum: 整段区间所有元素的和 Max: 整段区间内的最大连续子段和 在向上传递的时候:原创 2012-11-22 14:14:53 · 12645 阅读 · 0 评论 -
UESTC Training for Data Structures——K
Problem K Problem DescriptionA math instructor is too lazy to grade a question in the exam papers in which students are supposed to produce a complicated formula for the question asked. Students原创 2012-05-02 21:29:10 · 748 阅读 · 0 评论 -
UESTC Training for Data Structures——J
Problem J Problem DescriptionAn array of size n ≤ 10^6 is given to you. There is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the原创 2012-05-02 21:28:13 · 481 阅读 · 0 评论 -
UESTC Training for Data Structures——I
Problem I Problem Description 最近,吴神被谷峰神抓去埋地雷去了,谷峰神答应吴神只要他在规定时间内完成以下任务就放他走: 谷峰神给吴神N个数,然后有M次操作,13类操作:1.update i j k,把i到j这段内的每个数字加上k(-100002.query x,回答一个数i,i=max{j|aj>=x},如果不存在,输出-13.cha原创 2012-05-02 21:27:03 · 504 阅读 · 0 评论 -
UESTC Training for Data Structures——A
Problem A Problem Description The Romans have attacked again,This time they are much more than the Persians but Shapue is ready to defeat them.He says:"A lion is never afraid of a hundred shee原创 2012-05-02 21:11:05 · 630 阅读 · 0 评论 -
UESTC Training for Data Structures——B
Problem B Problem Description Polycarp thinks about the meaning of life very often. He does this constantly, even when typing in the editor. Every time he starts brooding he can no longer fully原创 2012-05-02 21:17:36 · 633 阅读 · 0 评论 -
UESTC Training for Data Structures——C
Problem C Problem Description Recently,our God Wu invented a little game named "God Wu's Puzzle" . If you dont know it, what a pity !In the game, God Wu will give you a rectangular grid of let原创 2012-05-02 21:19:02 · 596 阅读 · 0 评论 -
UESTC Training for Data Structures——D
Problem DProblem Description God KuFeng has a new house,in this big summer he is so boring.One day he noticed that there is a huge window in the house,, God KuFeng decides to decorate the window原创 2012-05-02 21:20:55 · 906 阅读 · 0 评论 -
UESTC Training for Data Structures——E
Problem E Time Limit : 3000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other)Total Submission(s) : 237 Accepted Submission(s) : 79Font: Times New Roman | Verdana | GeorgiaFont原创 2012-05-02 21:21:59 · 486 阅读 · 0 评论 -
UESTC Training for Data Structures——F
Problem F Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem Description Some of Farmer John\'s N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self-consciou原创 2012-05-02 21:23:20 · 476 阅读 · 0 评论 -
UESTC Training for Data Structures——G
Problem G Problem Description There were n cities in an ancient kingdom. In the beginning of the kingdom, all cities were isolated. Kings ordered their subjects to construct roads connecting cit原创 2012-05-02 21:24:38 · 473 阅读 · 0 评论 -
SPOJ GSS 5. Can you answer these queries V
题意 和 GSS1 一样,还是一个长度为 n 的序列和 m 个 querry,只不过这次 querry 的格式是 x1 y1 x2 y2,求 max{ a[i]+a[i+1]+...+a[j] }, x1做法分析 同 GSS1 一样,只不过查询的时候需分类讨论: 1、y1 2、y1>=x2:把整个 i 和 j 的取值分为三类讨论:原创 2012-11-22 14:26:27 · 11238 阅读 · 0 评论