![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构基础
文章平均质量分 82
紫书第六章
来老铁干了这碗代码
算法爱好者 终生学习践行者 雨雪刀霜阻不住 不成大神誓不休
展开
-
【刘汝佳可运行代码】Ordering Tasks UVA - 10305【两种解法】
立志用最少的代码做最高效的表达John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task is only possible if other tasks have already been executed.InputThe input will consist of several instances of the problem. Each instan原创 2021-02-04 21:43:38 · 1573 阅读 · 2 评论 -
【两种解法】Quadtrees UVA - 297(隐式建树+显式建树)
立志用最少的代码做最高效的表达A quadtree is a representation format used to encode images. The fundamental idea behind the quadtree is that any image can be split into four quadrants. Each quadrant may again be split in four sub quadrants, etc. In the quadtree, the im原创 2021-02-02 18:56:58 · 981 阅读 · 0 评论 -
【两种解法】he Falling Leaves UVA - 699
立志用最少的代码做最高效的表达Each year, fall in the North Central region is accompanied by the brilliant colors of the leaves on the trees, followed quickly by the falling leaves accumulating under the trees. If the same thing happened to binary trees, how large woul原创 2021-02-02 19:01:00 · 1328 阅读 · 0 评论 -
【三种解法】Not so Mobile UVA - 839_19行代码AC
立志用最少的代码做最高效的表达Before being an ubiquous communications gadget, a mobile was just a structure made of strings and wires suspending colourfull things. This kind of mobile is usually found hanging over cradles of small babies.The figure illustrates a simp原创 2021-02-01 15:59:28 · 763 阅读 · 0 评论 -
43行代码AC——例题6-8 树(Tree,UVa 548)——解题报告
励志用尽量少的代码做高效的表达。题目大意给定二叉树的中序和后序遍历序列,求该二叉树中根到叶子的路径和最小者,若存在多个解,则选择叶子权值最小者(叶子权值不重复)。思路分析此题本质是中后序建树+求路径最小权。(PS:书上的数组建树用不习惯,于是自己写了一个指针建树。)关键在于中序和后序建树,后序遍历序列的最后一个元素来确定根(前序的话是第一个元素确定根),中序序列来划分左右子树,如此递...原创 2020-03-15 16:15:02 · 683 阅读 · 0 评论 -
33行代码AC——例题6-5 移动盒子(Boxes in a Line, UVa 12657)——解题报告
题目大意对升序排列的n个数字(1开始编号)进行一系列操作,输出最终序列的奇位数之和。操作如下:1 X Y:把X移到Y左侧2 X Y:把X移到Y右侧3 X Y:交换X和Y4:反转序列(逆置)思路分析若是直接用链表模拟,在查找和反转时会消耗大量时间,导致超时,因此,如何解决这两个问题是关键。查找:为了简化,可用STL的list模拟链表,同时定义pos存储每个数对应的链表指针,在查...转载 2020-03-13 17:19:54 · 660 阅读 · 0 评论 -
19行代码AC——例题 6-2 铁轨(Rails, UVa 514)——解题报告
励志用尽量少的代码做高效的表达。提交(题目)链接→UVa-514此题的本质是:给出“入栈顺序”,判断给定序列是否可以出栈。 有点像这种题:因此思路也类似:思路:数组存储列车调度顺序, 栈存储正常入栈顺序, 若数组头=栈顶,数组移到下一位,栈顶元素弹出遍历完毕后, 若栈空,则说明全部调度完毕, 输出Yes注意点:1、输出的是Yes不是YES!(最开始看错,哭晕在厕所)2、每...原创 2020-03-12 23:56:31 · 939 阅读 · 1 评论 -
30行代码AC——例题6-3 矩阵链乘(Maxtrix Chain Multiplication, UVa 442)——解题报告
励志用尽量少的代码做高效的表达。题目(提交)链接→UVa-442储备知识:矩阵相乘次数:如图:A矩阵*B矩阵得到C矩阵。 C矩阵中元素个数=A矩阵行数*B矩阵列数。得到C矩阵中任意元素都需要运算A矩阵的列数次。因此,总运算次数为:A矩阵行数*B矩阵列数*A矩阵列数(B矩阵行数)=2*2*3=12次。同理:求A(BC)的运算次数:设BC矩阵相乘后得D矩阵。则总次数=BC相乘后的...原创 2020-03-13 11:11:45 · 758 阅读 · 0 评论 -
【可运行,刘汝佳代码】Trees on the level UVA - 122
立志用最少的代码做最高效的表达Trees are fundamental in many branches of computer science (Pun definitely intended). Current stateof-the art parallel computers such as Thinking Machines’ CM-5 are based on fat trees. Quad- and octal-trees are fundamental to many algorit原创 2021-01-30 20:30:02 · 715 阅读 · 2 评论 -
【刘汝佳代码详解】例题6-4破损的键盘(Broken Keyboard,UVa 11988)
立志用最少的代码做最高效的表达You’re typing a long text with a broken keyboard. Well it’s not so badly broken. The only problemwith the keyboard is that sometimes the “home” key or the “end” key gets automatically pressed(internally).You’re not aware of this issue原创 2021-01-30 11:28:27 · 768 阅读 · 0 评论