• 2024-07-09数据结构第17节 最小堆
    最小堆(MinHeap)是一种特殊的完全二叉树数据结构,在这种结构中,对于任意节点,其值都小于或等于它的子节点的值。根节点是堆中的最小元素。最小堆常用于实现优先队列,以及堆排序算法。在Java中,我们可以使用数组或ArrayList来实现最小堆,因为完全二叉树的特性允许我们通过简单的数
  • 2024-04-13数据结构-堆
    数据结构-堆1.定义:堆是一种特殊的完全二叉树。在堆中,所有的父节点都满足特定的顺序关系(大于或小于)与它们的子节点。这种属性使得堆在处理优先级队列和排序操作时非常有效。2.类型:常见的两种类型的堆是最大堆和最小堆。在最大堆中,每个父节点的值都大于或等于其子节点的值;而在
  • 2024-02-22发着试试【doge】
    `#include//牢大includeusingnamespacestd;templateclasssmallest_heap{private:itemheap[10001];intlen;public:smallest_heap();voidpush(itemconst&);voidpop();itemtop();intsize();boolempty();};templatesmallest_heap::smallest_heap()
  • 2024-02-05[ARC162D] Smallest Vertices 题解
    题目链接点击打开链接题目解法这种树的形态计数题首先可以想到\(prufer\)序列计数,如果没有任何限制,那么方案数为\(\prod\frac{(n-2)!}{deg_i}\),其中\(deg_1=d_1-1,deg_i=d_i(2\lei\len)\)对于每个点分开求贡献考虑这个式子只和点的个数和子树内的\(\sumdeg\)有关
  • 2023-10-19PAT_A 1038 Recover the Smallest Number
    Givenacollectionofnumbersegments,youaresupposedtorecoverthesmallestnumberfromthem.Forexample,given{32,321,3214,0229,87},wecanrecovermanynumberssuchlike32-321-3214-0229-87or0229-32-87-321-3214withrespecttodifferentor
  • 2023-07-26SROP-smallest
    第一次打srop,题目来源是https://github.com/ctf-wiki/ctf-challenges/blob/master/pwn/stackoverflow/srop/2016-360%E6%98%A5%E7%A7%8B%E6%9D%AF-srop/smallest这个原理是从hollk师傅的博客中搬来的https://hollk.blog.csdn.net/article/details/107512670?spm=1001.2014.3001.5
  • 2023-07-181851. Minimum Interval to Include Each Query (Hard)
    Description1851.MinimumIntervaltoIncludeEachQuery(Hard)Youaregivena2Dintegerarrayintervals,whereintervals[i]=[lefti,righti]describestheithintervalstartingatleftiandendingatrighti(inclusive).Thesizeofanintervalisdefi
  • 2023-07-16[ARC162D] Smallest Vertices
    [ARC162D]SmallestVerticesAtcoder:[ARC162D]SmallestVertices洛谷:[ARC162D]SmallestVerticesProblem在本问题中,当我们提到有根有向树时,我们指的是所有边都指向从根到叶子的有根树。给定一个使得其总和为\(N-1\)的非负整数序列\(d=(d_1,d_2,\ldots,d_N)\)。对于带编
  • 2023-07-10Largest-Smallest-Cyclic-Shift题解
    题目链接本题码量不大,但是事实上是一道极其难想的思维题。题目描述你有\(a\)个a,\(b\)个b,\(c\)个c。要求用这\(a+b+c\)个字母拼接成一个字符串,使得这个字符串的最小表示法在所有能拼成的字符串中最大。补充:最小表示法,将一个字符串的最后一个字符放到首位,重复这个操作,
  • 2023-06-28文心一言 VS 讯飞星火 VS chatgpt (50)-- 算法导论6.2 2题
    二、参考过程MAX-HEAPIFY,写出能够维护相应最小堆的MIN-HEAPIFY(A,i)的伪代码,并比较MIN-HEAPIFY与MAX-HEAPIFY的运行时间。文心一言:MIN-HEAPIFY(A,i)的伪代码如下:1.将节点i及其子树中的最小元素交换到根节点i;2.对于左子树,递归调用MIN-HEAPIFY(A,2i);3.对于右子树,递归调
  • 2023-06-28文心一言 VS 讯飞星火 VS chatgpt (50)-- 算法导论6.2 2题
    二、参考过程MAX-HEAPIFY,写出能够维护相应最小堆的MIN-HEAPIFY(A,i)的伪代码,并比较MIN-HEAPIFY与MAX-HEAPIFY的运行时间。文心一言:MIN-HEAPIFY(A,i)的伪代码如下:1.将节点i及其子树中的最小元素交换到根节点i;2.对于左子树,递归调用MIN-HEAPIFY(A,2i);3.对于右子树,递归调用MIN-H
  • 2023-03-14Find the smallest integer in the array
    InstructionsGivenanarrayofintegersyoursolutionshouldfindthesmallestinteger.Forexample:Given[34,15,88,2]yoursolutionwillreturn2Given
  • 2023-02-08230. Kth Smallest Element in a BST[Medium]
    230.KthSmallestElementinaBSTGiventherootofabinarysearchtree,andanintegerk,returnthekthsmallestvalue(1-indexed)ofallthevaluesofthe
  • 2023-02-06union find 查并集题库
    StatusTitleSolutionAcceptanceDifficultyFrequency438.FindAllAnagramsinaString50.0%Medium200.NumberofIslands56.7%Medium2421.NumberofGoodPaths58.0%Ha
  • 2023-01-29Kth Smallest Element in a Sorted Matrix
    classSolution{//14ms,fasterthan55.67%publicintkthSmallest(int[][]matrix,intk){intm=matrix.le
  • 2022-10-09Using a Robot to Print the Lexicographically Smallest String
    UsingaRobottoPrinttheLexicographicallySmallestStringYouaregivenastring s andarobotthatcurrentlyholdsanemptystring t .Applyoneofthe
  • 2022-09-22类欧几里得,以及ARC111E和ARC123E
    例题https://atcoder.jp/contests/practice2/tasks/practice2_c在\(O(\log(n+m+k+b))\)的时间复杂度求:\[\sum_{i=0}^{n-1}\lfloor{\frac{ki+b}{m}}\rfloor\]其中\(n,
  • 2022-09-21Smallest Subsets
    传送门题意:\(n\le1e5\)个整数,范围\(-1e9\lea\le1e9\),求第\(k\)小的子集和思路先考虑只有正数怎么做这就是经典的类最短路:先将序列排序,然后从最小的子集和\({
  • 2022-09-18Smallest Subarrays With Maximum Bitwise OR
    SmallestSubarraysWithMaximumBitwiseORYouaregivena0-indexedarray nums oflength$n$,consistingofnon-negativeintegers.Foreachindex$i$from$