Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/EndlessCheng/codeforces-go
/ functions
Functions
8,098 in github.com/EndlessCheng/codeforces-go
⨍
Functions
8,098
◇
Types & classes
911
Function
maxWeight
(edges [][]int, values []int)
leetcode/season/2020spring2/f/f.go:7
Method
maxWeightedBipartiteMatchingKuhnMunkres
O(n^3) 下标需要从 1 开始
copypasta/graph.go:2451
Method
maxWeightedBipartiteMatchingKuhnMunkresSlow
带权二分图最大完美匹配 - 任务分配问题/婚姻匹配问题 - KM (Kuhn–Munkres) 算法 注意:下面的代码是 O(n^4) 的, O(n^3) 的在后面 https://en.wikipedia.org/wiki/Assignment_problem https://en.wikiped
copypasta/graph.go:2373
Function
maxWidthOfVerticalArea
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/38/b/b.go:6
Method
maxXor
v 与 trie 上所有数的最大异或值,trie 不能是空的 模板题 LC421 https://leetcode-cn.com/problems/maximum-xor-of-two-numbers-in-an-array/ 离线 LC1707/周赛211D https://leetcode-cn
copypasta/trie01.go:74
Method
maxXorWithLimitVal
v 与 trie 上所有不超过 limit 的数的最大异或值 不存在时返回 -1 https://codeforces.com/problemset/problem/979/D LC1707/周赛211D https://leetcode-cn.com/problems/maximum-xor-wi
copypasta/trie01.go:110
Method
maxXorWithLimitXor
v 与 trie 上所有数异或不超过 limit 的最大异或值 不存在时返回 -1 原理同 countLimitXOR
copypasta/trie01.go:173
Method
maximalCliques
团 clique 图 G 中的团和图 G 的补图中的独立集是一一对应的 图 G 中的独立集和图 G 的补图中的团是一一对应的(等价说法) https://en.wikipedia.org/wiki/Clique_(graph_theory) 最大独立集 maximal independent set
copypasta/graph.go:3838
Function
maximalNetworkRank
github.com/EndlessCheng/codeforces-go
leetcode/weekly/210/b/b.go:4
Function
maximalPathQuality
* 暴搜+剪枝 根据题目的数据范围,至多只能走 $10$ 条边,这意味着爆搜的层数至多为 $10$;同时,题目保证每个节点至多有四条边与之相连,因此每次搜索时至多会递归 $4$ 次。因此计算量至多为 $4^{10}$,可以在时限内跑完。 本题的一个剪枝技巧是,先预处理起点 $0$ 到其余节点的最
leetcode/weekly/266/d/d.go:14
Function
maximalRectangleArea
最大全 1 矩形 LC85 https://leetcode-cn.com/problems/maximal-rectangle/
copypasta/monotone_stack.go:129
Function
maximizeSweetness
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/11/d/d.go:6
Function
maximizeXor
(a []int, qs [][]int)
leetcode/weekly/221/d/d.go:42
Function
maximum69Number
(num int)
leetcode/weekly/172/a/a.go:5
Function
maximumAverageSubtree
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/4/c/c.go:6
Function
maximumBeauty
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/65/c/c.go:6
Function
maximumDetonation
建图 + 暴力枚举所有起点 github.com/EndlessCheng/codeforces-go
leetcode/biweekly/67/c/c.go:6
Function
maximumDifference
github.com/EndlessCheng/codeforces-go
leetcode/weekly/260/a/a.go:4
Function
maximumElementAfterDecrementingAndRearranging
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/51/c/c.go:6
Function
maximumMinimumPath
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/3/d/d.go:6
Function
maximumNumber
Go 贪心 github.com/EndlessCheng/codeforces-go
leetcode/weekly/251/b/b.go:6
Function
maximumNumberOfOnes
注:题解区有 O(1) 做法 github.com/EndlessCheng/codeforces-go
leetcode/biweekly/8/d/d.go:8
Function
maximumPopulation
github.com/EndlessCheng/codeforces-go
leetcode/weekly/240/a/a.go:4
Function
maximumProduct
(a []int)
leetcode/weekly/38/a/a.go:5
Function
maximumRemovals
github.com/EndlessCheng/codeforces-go
leetcode/weekly/245/b/b.go:6
Function
maximumRequests
github.com/EndlessCheng/codeforces-go
leetcode/weekly/208/d/d.go:4
Function
maximumScore
github.com/EndlessCheng/codeforces-go
leetcode/weekly/229/c/c.go:4
Function
maximumScore
github.com/EndlessCheng/codeforces-go
leetcode/weekly/232/d/d.go:4
Function
maximumScore
github.com/EndlessCheng/codeforces-go
leetcode/weekly/227/b/b.go:6
Function
maximumTime
github.com/EndlessCheng/codeforces-go
leetcode/weekly/225/a/a.go:6
Function
maximumUniqueSubarray
github.com/EndlessCheng/codeforces-go
leetcode/weekly/220/b/b.go:4
Function
maximumUnits
github.com/EndlessCheng/codeforces-go
leetcode/weekly/222/a/a.go:6
Function
maximumWealth
github.com/EndlessCheng/codeforces-go
leetcode/weekly/217/a/a.go:4
Function
maxmiumScore
* 排序+贪心 将 $\textit{cards}$ 从大到小排序,并累加前 $\textit{cnt}$ 个元素之和,记作 $\textit{sum}$,若 $\textit{sum}$ 是偶数则直接返回,若不是偶数,则我们需要从前 $\textit{cnt}$ 个元素中选一个元素 $x$,并从
leetcode/season/2021fall/b/b.go:18
Function
memLeak
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/52/b/b.go:4
Method
merge
(from, to int)
copypasta/union_find.go:270
Method
merge
启发式合并:把深度小的合并到深度大的。若二者深度一样,则合并后的深度加一
copypasta/union_find.go:360
Method
merge
注:push 一个节点就相当于 merge 这个节点
copypasta/leftist_tree.go:58
Method
merge
(l, r int, value tpValueType)
copypasta/odt_bst.go:40
Method
merge
EXTRA: 线段树合并 https://www.luogu.com.cn/problem/P5494 todo 一些题目 https://www.luogu.com.cn/blog/styx-ferryman/xian-duan-shu-ge-bing-zong-ru-men-dao-fang-q
copypasta/segment_tree.go:481
Method
merge
把子树 ro 合并进子树 o,返回合并前 o 的最大节点 子树 o 的所有元素比子树 ro 中的小 o != nil
copypasta/splay.go:110
Function
mergeAlternately
github.com/EndlessCheng/codeforces-go
leetcode/weekly/229/a/a.go:4
Function
mergeCount
归并排序与逆序对 LC 面试题 51 https://leetcode-cn.com/problems/shu-zu-zhong-de-ni-xu-dui-lcof/ EXTRA: LC315 https://leetcode-cn.com/problems/count-of-smaller-num
copypasta/misc.go:425
Function
mergeInBetween
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/40/b/b.go:6
Function
mergeTriplets
若 $(a_i,b_i,c_i)$ 各部分均不超过 $(x,y,z)$,则可以执行更新操作 因此对所有满足要求的 $(a_i,b_i,c_i)$,只要各部分都出现了 $x,y,z$,最终各部分就能更新成 $x,y,z$ github.com/EndlessCheng/codeforces-go
leetcode/weekly/245/c/c.go:7
Function
middleNode
github.com/EndlessCheng/codeforces-go
leetcode/weekly/95/a/a.go:6
Method
min
()
copypasta/bst.go:273
Function
minAbsDifference
github.com/EndlessCheng/codeforces-go
leetcode/weekly/227/d/d.go:6
Function
minAbsoluteSumDiff
github.com/EndlessCheng/codeforces-go
leetcode/weekly/235/c/c.go:6
Function
minAvailableDuration
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/11/b/b.go:6
Function
minBuildTime
(a []int, split int)
leetcode/biweekly/9/d/d.go:14
Function
minCameraCover
LC 968
leetcode/main.go:1651
Function
minChanges
github.com/EndlessCheng/codeforces-go
leetcode/weekly/231/d/d.go:4
Function
minCharacters
github.com/EndlessCheng/codeforces-go
leetcode/weekly/225/b/b.go:4
Function
minCost
github.com/EndlessCheng/codeforces-go
misc/nowcoder/6218/c/c.go:4
Function
minCost
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/66/c/c.go:4
Function
minCost
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/56/d/d.go:4
Function
minCost
github.com/EndlessCheng/codeforces-go
leetcode/weekly/201/d/d.go:6
Function
minCost
(houses []int, cost [][]int, n int, m int, target int)
leetcode/weekly/192/d/d.go:3
Function
minCost
(grid [][]int)
leetcode/weekly/178/d/d.go:3
Function
minCost
github.com/EndlessCheng/codeforces-go
leetcode/weekly/205/c/c.go:4
Function
minCostConnectPoints
(points [][]int)
leetcode/weekly/206/c/c.go:129
Function
minCostConnectPoints_N2
github.com/EndlessCheng/codeforces-go
leetcode/weekly/206/c/c.go:9
Method
minCostFlowDijkstra
基于原始对偶方法 (primal-dual method) https://blog.xehoth.cc/DurationPlan-Primal-Dual/
copypasta/graph.go:3672
Method
minCostFlowSPFA
最小费用流 MCFP 最小费用最大流 MCMF(即满流时的费用) 将 Edmonds-Karp 中的 BFS 改成 SPFA O(fnm) 或 Dijkstra O(fmlogn) 要求初始网络中无负权圈 性能对比(洛谷 P3381,由于数据不强所以 SPFA 很快):SPFA 1.05s(max
copypasta/graph.go:3592
Function
minCostToSupplyWater
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/7/d/d.go:6
Function
minCount
(a []int)
leetcode/season/2020spring/a/a.go:3
Function
minDays
O(nm) 求割点
leetcode/weekly/204/c/c.go:8
Function
minDays
(bloomDay []int, m int, k int)
leetcode/weekly/193/c/c.go:5
Function
minDays
github.com/EndlessCheng/codeforces-go
leetcode/weekly/202/d/d.go:4
Function
minDeletionSize
github.com/EndlessCheng/codeforces-go
leetcode/weekly/115/d/d.go:4
Function
minDeletions
github.com/EndlessCheng/codeforces-go
leetcode/weekly/214/b/b.go:6
Method
minDiffMST
Kruskal 重构树 https://oi-wiki.org/graph/mst/#kruskal_1 最小生成树计数 Kirchhoff's theorem https://www.luogu.com.cn/problem/P4208 todo 最小差值生成树 edges 中的节点编号从 0 开
copypasta/graph.go:1965
Function
minDifference
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/30/c/c.go:6
Function
minDifference
github.com/EndlessCheng/codeforces-go
leetcode/weekly/246/d/d.go:4
Function
minDifficulty
(jobDifficulty []int, d int)
leetcode/weekly/173/d/d.go:3
Function
minDist
(n, _, s, t int, es [][]int)
misc/nowcoder/9887/c/c.go:36
Function
minDistance
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/28/d/d.go:6
Function
minElements
github.com/EndlessCheng/codeforces-go
leetcode/weekly/231/b/b.go:4
Function
minFallingPathSum
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/15/d/d.go:4
Function
minFlips
(a int, b int, c int)
leetcode/weekly/171/b/b.go:3
Function
minFlips
(s string)
leetcode/weekly/199/b/b.go:3
Function
minFlips
(mat [][]int)
leetcode/weekly/166/d/d.go:3
Function
minFlips
* 从前往后匹配+从后往前匹配 如果去掉第一种操作,由于交替字符串只有 $\texttt{1}$ 开头与 $\texttt{0}$ 开头两种,我们只需要检查 $s$ 与 $\texttt{1010}\cdots$ 和 $\texttt{0101}\cdots$ 中哪个不同字母最少,这样第二种操作次
leetcode/weekly/244/c/c.go:30
Function
minHeightShelves
github.com/EndlessCheng/codeforces-go
leetcode/weekly/143/c/c.go:4
Function
minInsertions
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/32/c/c.go:4
Function
minInsertions
(ss string)
leetcode/weekly/170/d/d.go:3
Function
minInteger
(s string, k int)
leetcode/weekly/196/d/d.go:111
Function
minInterval
github.com/EndlessCheng/codeforces-go
leetcode/weekly/239/d/d.go:6
Function
minJump
(a []int)
leetcode/season/2020spring/d/d.go:3
Function
minJumps
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/19/d/d.go:4
Function
minKnightMoves
马走日从 (0,0) 到 (x,y) 所需最小步数 无边界 LC1197/双周赛9B https://leetcode-cn.com/contest/biweekly-contest-9/problems/minimum-knight-moves/ 有边界+打印方案 https://www.acwi
copypasta/misc.go:729
Function
minKnightMoves
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/9/b/b.go:4
Function
minMoveToAllSameInCircle
均分纸牌 https://www.luogu.com.cn/problem/P1031 环形 https://www.luogu.com.cn/problem/P2512 https://www.luogu.com.cn/problem/P3051 https://www.luogu.com.cn/
copypasta/misc.go:787
Function
minMoves
github.com/EndlessCheng/codeforces-go
leetcode/weekly/217/c/c.go:4
Function
minMovesToSeat
* 排序+贪心 由于座位和学生数相同,一个萝卜一个坑,将座位和学生位置排序后,第 $i$ 个学生可以对应第 $i$ 个座位。 由于交换任意两个学生对应的座位不会产生更少的移动次数(可以画一画,证明略),所以上述对应关系可以产生最少移动次数,累加位置之差即为答案。 */ github.com/E
leetcode/biweekly/63/a/a.go:14
Function
minMustPassSum
倒序思想 来源自被删除的 C 题 https://ac.nowcoder.com/acm/contest/view-submission?submissionId=45798625 有一个大小为 n*m 的网格图,和一个长为 n*m 的目标位置列表,每个位置表示网格图中的一个格点且互不相同 网格图初
copypasta/misc.go:676
Function
minNonZeroProduct
(p int)
leetcode/weekly/254/c/c.go:44
Function
minNumberOfFrogs
(s string)
leetcode/weekly/185/c/c.go:5
Function
minNumberOfSemesters
(n int, dependencies [][]int, k int)
leetcode/biweekly/29/d/d.go:7
← previous
next →
7,401–7,500 of 8,098, ranked by callers