MCPcopy Create free account

hub / github.com/EndlessCheng/codeforces-go / functions

Functions8,098 in github.com/EndlessCheng/codeforces-go

FunctioncountSwap
输入两个无重复元素的序列,返回通过交换相邻元素,从 a 到 b 所需的最小交换次数 保证 a b 包含相同的元素
copypasta/misc.go:483
FunctioncountTriples
(n int)
leetcode/biweekly/56/a/a.go:14
FunctioncountTriplets
(a []int, A, B int)
misc/nowcoder/10325/a/a.go:6
FunctioncountTriplets
(a []int)
leetcode/weekly/121/d/d.go:3
FunctioncountTriplets
(a []int)
leetcode/weekly/188/b/b.go:3
FunctioncountValidSubstring
输入一个仅包含 () 的括号串,返回右括号个数不少于左括号个数的非空子串个数
copypasta/misc.go:500
FunctioncountValidWords
Go 模拟,附详细注释 github.com/EndlessCheng/codeforces-go
leetcode/weekly/264/a/a.go:11
FunctioncountVowelStrings
github.com/EndlessCheng/codeforces-go
leetcode/weekly/213/b/b.go:6
FunctioncountVowelSubstrings
双指针 O(n) github.com/EndlessCheng/codeforces-go
leetcode/weekly/266/a/a.go:8
FunctioncountVowels
* 单独计算每个元音的出现次数 遍历 $\textit{word}$,若 $\textit{word}[i]$ 是元音,我们考察它能出现在多少个子字符串中。 设 $\textit{word}$ 的长度为 $n$。子字符串 $\textit{word}[l..r]$ 若要包含 $\textit{w
leetcode/weekly/266/b/b.go:22
FunctioncountWords
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/66/a/a.go:4
FunctioncowModCount
(N int64)
misc/nowcoder/9005/c/c.go:6
FunctioncreateSortedArray
(a []int)
leetcode/weekly/214/d/d.go:26
FunctioncreateTargetArray
(nums []int, index []int)
leetcode/weekly/181/a/a.go:3
FunctiondaysBetweenDates
(date1 string, date2 string)
leetcode/weekly/177/a/a.go:8
FunctiondecimalToFraction
小数转分数 decimal like "2.15(376)", which means "2.15376376376..." https://zh.wikipedia.org/wiki/%E5%BE%AA%E7%8E%AF%E5%B0%8F%E6%95%B0#%E5%8C%96%E7%82%BA%E
copypasta/misc.go:608
Functiondecode
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/44/c/c.go:4
Functiondecode
github.com/EndlessCheng/codeforces-go
leetcode/weekly/223/a/a.go:4
FunctiondecodeCiphertext
github.com/EndlessCheng/codeforces-go
leetcode/weekly/267/c/c.go:6
FunctiondecompressRLElist
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/17/a/a.go:4
Functiondecrypt
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/39/a/a.go:4
FunctiondeepestLeavesSum
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/16/c/c.go:6
Methoddel
LC1938/周赛250D https://leetcode-cn.com/problems/maximum-genetic-difference-query/
copypasta/trie01.go:59
Methoddelete
(key int)
main/500-599/555C.go:86
Methoddelete
(key int)
main/800-899/840D.go:74
Methoddelete
(key int)
main/gym/101628K.go:83
Methoddelete
(key int)
copypasta/scapegoat_tree.go:128
Methoddelete
(key rbKeyType)
copypasta/red_black_tree.go:204
Methoddelete
删除字符串 s,返回字符串末尾对应的节点 LC1804 https://leetcode-cn.com/problems/implement-trie-ii-prefix-tree/
copypasta/trie.go:84
Methoddelete
(key spKeyType)
copypasta/splay.go:169
Methoddelete
(key int)
leetcode/weekly/196/d/d.go:91
FunctiondeleteDuplicateFolder
(paths [][]string)
leetcode/weekly/251/d/d.go:29
FunctiondeleteMiddle
* 快慢指针 这题其实就是把 [876. 链表的中间结点](https://leetcode-cn.com/problems/middle-of-the-linked-list/) 和删除链表结点结合起来 我们只需要在 876 题的基础上,额外记录 $\textit{slow}$ 结点的上一个结
leetcode/weekly/270/b/b.go:14
FunctiondeleteTreeNodes
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/14/c/c.go:4
MethoddepthSize
两个基本信息:节点深度和子树大小 节点深度: - 深度与祖先:v 是 w 的祖先,当且仅当 dep[v]+dist(v,w)=dep[w] - 与 DFS 序结合,可以表达子树在某个深度上的一段信息(见 tree.inOutTimestamp) - 直径 中心(见 tree.diameter) 子树
copypasta/graph_tree.go:64
FunctiondestCity
(paths [][]string)
leetcode/weekly/187/a/a.go:3
Methoddet
(b vecF)
misc/atcoder/abc168/c/c.go:16
Methoddet
(vecF)
copypasta/geometry.go:1105
FunctiondetectCycle
LC 142
leetcode/main.go:757
Methoddeterminant
EXTRA: 求行列式(对结果模 mod) https://en.wikipedia.org/wiki/Determinant 参考 https://www.luogu.com.cn/blog/Stormy-Rey/calculate-det
copypasta/math_matrix.go:309
Methoddfs
EXTRA: 先染色,再递归 https://codeforces.com/problemset/problem/1470/D 无向图后向边定向 https://codeforces.com/problemset/problem/1519/E
copypasta/graph.go:149
FunctiondiagonalSort
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/18/c/c.go:6
FunctiondiagonalSum
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/34/a/a.go:4
Methoddiameter
树的直径/最长链(DP 求法另见 dp.go 中的 diameter) 返回树的某条直径的两端点以及直径长度(最长链长度) 树的中心:树的直径的中点。直径长度为偶数时有一个,为奇数时有两个 如果给每条边加一个中点,那么可以保证树的中心为一个 性质: 直径的中点到所有叶子的距离和最小 对于两棵树,记第
copypasta/graph_tree.go:249
FunctiondietPlanPerformance
github.com/EndlessCheng/codeforces-go
leetcode/weekly/152/b/b.go:4
MethoddifferenceInTree
LCA 应用:树上差分 操作为更新 v-w 路径上的点权或边权(初始为 0) 点权时 diff[lca] -= val 边权时 diff[lca] -= 2 * val(定义 diff 为点到父亲的差分值) https://www.luogu.com.cn/blog/RPdreamer/ci-fen
copypasta/graph_tree.go:973
FunctiondigSum
github.com/EndlessCheng/codeforces-go
misc/nowcoder/6384/c/c.go:6
FunctiondigitsCount
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/1/d/d.go:6
Methoddis
(vecF)
copypasta/geometry.go:1108
Methoddis2
(b vecF)
misc/atcoder/abc168/c/c.go:18
Methoddis2
(vecF)
copypasta/geometry.go:1109
MethoddisToLine
点 a 到直线 l 的距离 若不取绝对值得到的是有向距离
copypasta/geometry.go:335
MethoddisToSeg
点 a 到线段 l 的距离
copypasta/geometry.go:341
FunctiondisplayTable
(orders [][]string)
leetcode/weekly/185/b/b.go:8
FunctiondistanceLimitedPathsExist
(n int, es, qs [][]int)
leetcode/weekly/220/d/d.go:29
FunctiondistinctEchoSubstrings
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/17/d/d.go:4
FunctiondistributeCandies
github.com/EndlessCheng/codeforces-go
leetcode/weekly/143/a/a.go:4
Methoddiv
(b Int)
copypasta/big.go:23
Methoddiv
(b rat)
copypasta/big.go:43
Functiondiv2
(a int)
copypasta/math_fwt.go:99
Methoddivmod
(b poly)
copypasta/math_ntt.go:336
Methoddivs
(b Int)
copypasta/big.go:14
Methoddivs
(b rat)
copypasta/big.go:35
Methoddivs
(k float64)
copypasta/geometry.go:194
Functiondoll
github.com/EndlessCheng/codeforces-go
misc/nowcoder/9476/a/a.go:10
Functiondomino
(n int, m int, broken [][]int)
leetcode/season/2019fall/d/d.go:3
Methoddot
(b vecF)
misc/atcoder/abc168/c/c.go:15
Methoddot
(vecF)
copypasta/geometry.go:1104
FunctiondpCollections
* 动态规划 首先请透彻理解何为问题的「状态空间」,见 search.go 开头的注释 思考过程: 1.1 如何把问题形式化为状态空间?(可以从边界、子集的角度思考) 1.2 子问题是如何重叠的? 1.3 子问题是怎么逐层递进的?(题目描述、隐含的顺序) 2.1 如何定义状态?需要用几个维度表示
copypasta/dp.go:137
Methoddsu
树上启发式合并 DSU on tree / small to large https://oi-wiki.org/graph/dsu-on-tree/ NOTE: 合并的时候最好先循环计算一遍答案,再循环合并一遍,这样的习惯可避免产生把合并之后的数值算入答案中的 bug 讲解+套题 https://
copypasta/graph_tree.go:1301
FunctiondynamicConnectivity
动态图连通性·离线(求 CC 个数或判断 v 和 w 是否连通) https://en.wikipedia.org/wiki/Dynamic_connectivity https://codeforces.com/gym/100551/problem/A https://codeforces.com
copypasta/union_find.go:381
FunctiondynamicMedians
对顶堆求动态中位数:medians[i] = a[:i+1] 的中位数 https://www.luogu.com.cn/problem/P1168 LC295 https://leetcode-cn.com/problems/find-median-from-data-stream/ 与树状数组结
copypasta/heap.go:97
FunctionearliestAcq
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/3/c/c.go:6
FunctionearliestAndLatest
github.com/EndlessCheng/codeforces-go
leetcode/weekly/245/d/d.go:4
FunctioneatenApples
(apples, days []int)
leetcode/weekly/221/b/b.go:17
FunctioneliminateMaximum
github.com/EndlessCheng/codeforces-go
leetcode/weekly/248/b/b.go:6
Methodempty
()
main/1500-1599/1526C2.go:17
Methodempty
()
copypasta/bst.go:81
Functionencode
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/13/a/a.go:6
FunctionentityParser
(s string)
leetcode/weekly/184/c/c.go:8
Methodequals
(b vecF)
copypasta/geometry.go:189
FunctioneraseOverlapIntervals
LC 435
leetcode/main.go:1276
MethodeulerianPathOnDirectedGraph
(n, m int)
copypasta/graph.go:592
MethodeulerianPathOnUndirectedGraph
欧拉图(欧拉回路) 半欧拉图(欧拉路径) 半欧拉图:具有欧拉路径而无欧拉回路的图 判别法如下 https://oi-wiki.org/graph/euler/#_3 无向图-欧拉回路:连通且没有奇度数点 无向图-欧拉路径:连通且恰有 0 或 2 个奇度数点(若有则选择其中一奇度数点为起点) 有向
copypasta/graph.go:530
Functionevaluate
github.com/EndlessCheng/codeforces-go
leetcode/weekly/234/c/c.go:4
FunctionexecuteInstructions
(n int, startPos []int, s string)
leetcode/weekly/273/b/b.go:6
Functionexist
LC 79
leetcode/main.go:396
Functionexpand
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/2/c/c.go:6
FunctionexpectNumber
(a []int)
leetcode/season/2020spring2/a/a.go:3
FunctionfastIO
快读,适用于输入量巨大的题目 相比 fmt.Fscan,每读入 1e6 个 int 可以加速约 400~450ms(Codeforces/AtCoder)
copypasta/io.go:36
FunctionfasterIO
超快读 以 CF1276B(1e6 数据量)为例,测试结果如下: bufferIO 670 ms fastIO 296 ms fasterIO 202 ms fasterIO 202 ms (use syscall.Read(syscall.Stdin, buf)) 选择 4KB 作为缓
copypasta/io.go:118
FunctionfenwickTree
* 树状数组(Fenwick Tree),二叉索引树(Binary Index Tree, BIT) https://en.wikipedia.org/wiki/Fenwick_tree 树状数组的基本用途是维护序列的前缀和 tree[i] = a[i-lowbit(i)+1] + ... + a[
copypasta/fenwick_tree.go:39
FunctionfilterRestaurants
(restaurants [][]int, veganFriendly int, maxPrice int, maxDistance int)
leetcode/weekly/173/b/b.go:5
FunctionfinalPrices
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/28/a/a.go:4
FunctionfinalValueAfterOperations
github.com/EndlessCheng/codeforces-go
leetcode/weekly/259/a/a.go:4
Methodfind
查找字符串 s
copypasta/trie.go:66
Methodfind
(key int)
copypasta/bst.go:83
FunctionfindAllPeople
* 按照相同时间分组 + 建图 DFS 首先将 $\textit{meetings}$ 按照时间 $\textit{time}$ 排序,然后遍历 $\textit{meetings}$,将时间相同的会议分成一组。 对于每组会议,由于专家可以互相共享秘密,我们可以将这些专家看成图上的点,专家 $\
leetcode/weekly/269/d/d.go:20
FunctionfindAllRecipes
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/68/b/b.go:4
FunctionfindBall
github.com/EndlessCheng/codeforces-go
leetcode/weekly/221/c/c.go:4
← previousnext →6,601–6,700 of 8,098, ranked by callers