MCPcopy Create free account

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

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

FunctioncheckIfExist
(arr []int)
leetcode/weekly/175/a/a.go:3
FunctioncheckIfPangram
github.com/EndlessCheng/codeforces-go
leetcode/weekly/237/a/a.go:4
FunctioncheckIfPrerequisite
(n int, prerequisites [][]int, queries [][]int)
leetcode/biweekly/27/c/c.go:3
FunctioncheckOnesSegment
github.com/EndlessCheng/codeforces-go
leetcode/weekly/231/a/a.go:6
FunctioncheckOverlap
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/23/c/c.go:6
FunctioncheckPalindromeFormation
(a, b string)
leetcode/weekly/210/c/c.go:27
FunctioncheckPartitioning
github.com/EndlessCheng/codeforces-go
leetcode/weekly/226/d/d.go:4
FunctioncheckPowersOfThree
(n int)
leetcode/biweekly/47/b/b.go:11
FunctioncheckStraightLine
(ps [][]int)
leetcode/weekly/159/a/a.go:3
FunctioncheckZeroOnes
github.com/EndlessCheng/codeforces-go
leetcode/weekly/242/a/a.go:4
FunctioncherryPickup
(g [][]int)
leetcode/biweekly/27/d/d.go:3
FunctioncircleGame
github.com/EndlessCheng/codeforces-go
leetcode/season/2021fall/d/d.go:6
FunctioncircularPermutation
(n int, start int)
leetcode/weekly/160/b/b.go:3
FunctioncircumcenterR
EXTRA: 外接圆半径 R 下面交换了一下乘除的顺序,减小精度的丢失 todo https://codeforces.com/problemset/problem/274/C
copypasta/geometry.go:274
FunctioncircumcenterR2
(a, b, c vecF)
copypasta/geometry.go:278
Functioncity
github.com/EndlessCheng/codeforces-go
misc/nowcoder/10323/c/c.go:6
FunctioncloseStrings
github.com/EndlessCheng/codeforces-go
leetcode/weekly/215/b/b.go:6
FunctionclosedIsland
(grid [][]int)
leetcode/weekly/162/c/c.go:3
FunctionclosestCost
github.com/EndlessCheng/codeforces-go
leetcode/weekly/230/b/b.go:4
FunctionclosestDivisors
(num int)
leetcode/weekly/177/c/c.go:3
FunctionclosestRoom
(a, qs [][]int)
leetcode/biweekly/51/d/d.go:84
FunctionclosestToTarget
github.com/EndlessCheng/codeforces-go
leetcode/weekly/198/d/d.go:4
Methodcmp
(b Int)
copypasta/big.go:19
Methodcmp
(b rat)
copypasta/big.go:39
Functioncollections
()
leetcode/weekly/163/main.go:8
FunctioncolorTheGrid
(m, n int)
leetcode/weekly/249/c/c.go:6
FunctioncombinationSum
LC 39
leetcode/main.go:152
FunctioncombinationSum2
LC 40
leetcode/main.go:175
FunctioncombinationSum3
LC 216
leetcode/main.go:942
FunctioncombinatoricsCollection
* 组合数学 https://en.wikipedia.org/wiki/Combination https://en.wikipedia.org/wiki/Enumerative_combinatorics https://en.wikipedia.org/wiki/Binomial_theore
copypasta/math.go:2916
FunctioncommonCollection
解决问题的一般方法 https://codeforces.com/blog/entry/92248?#comment-809401 General ideas https://codeforces.com/blog/entry/48417 从特殊到一般:尝试修改条件或缩小题目的数据范围,先研究某个特
copypasta/common.go:106
FunctionconcatenatedBinary
todo O(log n) ? github.com/EndlessCheng/codeforces-go
leetcode/weekly/218/c/c.go:8
FunctionconfusingNumberII
(n int)
leetcode/biweekly/2/d/d.go:29
Functionconnect
LC 117, O(1) 空间复杂度
leetcode/main.go:529
FunctionconnectSticks
(sticks []int)
leetcode/biweekly/7/c/c.go:16
FunctionconnectTwoGroups
github.com/EndlessCheng/codeforces-go
leetcode/weekly/207/d/d.go:4
FunctionconstrainedSubsetSum
(a []int, k int)
leetcode/weekly/186/d/d.go:61
Functionconstruct2DArray
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/62/a/a.go:4
Functionconstructor
()
leetcode/testutil/leetcode_test.go:95
Methodcontain
bst 存的是互不相交的区间 [key,value),现查询是否包含区间 [l,r)
copypasta/bst.go:191
FunctioncontainsCycle
(g [][]byte)
leetcode/biweekly/33/d/d.go:7
FunctioncontainsPattern
github.com/EndlessCheng/codeforces-go
leetcode/weekly/204/a/a.go:4
FunctioncontinuedFractionCollections
()
copypasta/math_continued_fraction.go:8
FunctionconvertBST
LC 538 1038 反序中序遍历
leetcode/main.go:1325
FunctioncopyMatrix
(a matrix)
copypasta/math_matrix.go:42
FunctioncosineRule
余弦定理,输入两边及夹角,计算对边长度
copypasta/geometry.go:250
FunctioncosineRuleVec
(va, vb vecF, angle float64)
copypasta/geometry.go:253
FunctioncountBalls
github.com/EndlessCheng/codeforces-go
leetcode/weekly/226/a/a.go:4
FunctioncountCharacters
(words []string, chars string)
leetcode/weekly/150/a/a.go:3
FunctioncountCombinations
(pieces []string, positions [][]int)
leetcode/biweekly/64/d/d.go:55
FunctioncountConsistentStrings
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/41/a/a.go:4
MethodcountCycle3
todo 极大团计数 分团覆盖问题 Clique cover https://en.wikipedia.org/wiki/Clique_cover todo 图的同构 todo 树的同构 AHU 算法 https://oi-wiki.org/graph/tree-ahu/ todo hashing
copypasta/graph.go:3898
MethodcountCycle4
四元环计数/判定 O(m√m) 同三元环那样定向,将四元环拆成左右各两条边,这两条边为一条无向边和一条有向边,然后统计无向+有向的对数 具体参见 https://blog.csdn.net/weixin_43466755/article/details/112985722 https://cdn.l
copypasta/graph.go:3939
FunctioncountDifferentSubsequenceGCDs
github.com/EndlessCheng/codeforces-go
leetcode/weekly/235/d/d.go:4
FunctioncountDigitOne
LC 233 小于等于 n 的非负整数中数字 1 出现的个数
leetcode/main.go:1006
MethodcountDistinctSubstring
s 的本质不同子串数量 O(n^2) 做法是插入每个后缀,统计节点数。但题目往往会带上额外的条件 https://codeforces.com/problemset/problem/271/D 注:这题还可以用后缀数组+前缀和二分来做到 O(nlogn)
copypasta/trie.go:185
FunctioncountGoodNumbers
(n int64)
leetcode/weekly/248/c/c.go:6
FunctioncountGoodRectangles
github.com/EndlessCheng/codeforces-go
leetcode/weekly/224/a/a.go:4
FunctioncountGoodSubstrings
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/53/a/a.go:4
FunctioncountGoodTriplets
github.com/EndlessCheng/codeforces-go
leetcode/weekly/200/a/a.go:4
FunctioncountHighestScoreNodes
github.com/EndlessCheng/codeforces-go
leetcode/weekly/264/c/c.go:4
FunctioncountHomogenous
github.com/EndlessCheng/codeforces-go
leetcode/weekly/228/b/b.go:4
FunctioncountKDifference
O(n) 做法 github.com/EndlessCheng/codeforces-go
leetcode/biweekly/61/a/a.go:6
FunctioncountLargestGroup
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/23/a/a.go:4
FunctioncountLetters
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/8/a/a.go:4
FunctioncountLimitXOR
上面也可以用哈希表做
copypasta/trie01.go:151
MethodcountLimitXOR
求与 v 异或值不超过 limit 的元素个数 核心原理是,当 limit+1 的某一位是 1 的时候,若该位异或值取 0,则后面的位是可以取任意数字的 如果在 limit 上而不是 limit+1 上讨论,就要处理当前异或为 1 的情况了,比较麻烦 LC1803/周赛233D https://le
copypasta/trie01.go:131
FunctioncountMatches
github.com/EndlessCheng/codeforces-go
leetcode/weekly/230/a/a.go:4
FunctioncountMaxOrSubsets
O(2^n) 子集或写法 github.com/EndlessCheng/codeforces-go
leetcode/weekly/263/c/c.go:6
MethodcountMode
EXTRA: countDiff 区间不同元素个数 做法是维护左侧相同元素的位置 todo 参考 https://www.luogu.com.cn/problem/solution/SP3267 https://www.luogu.com.cn/problem/P1972 https://www.l
copypasta/segment_tree.go:671
FunctioncountNegatives
二分亦可。
leetcode/weekly/176/a/a.go:4
FunctioncountNodes
LC 222 完全二叉树节点个数 O(logn) 解法
leetcode/main.go:967
FunctioncountOdds
(low, high int)
leetcode/biweekly/31/a/a.go:3
FunctioncountOfAtoms
(s string)
leetcode/weekly/58/c/c.go:11
FunctioncountOrders
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/20/d/d.go:6
FunctioncountPairs
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/47/d/d.go:6
FunctioncountPairs
github.com/EndlessCheng/codeforces-go
leetcode/weekly/222/b/b.go:4
FunctioncountPairs
(nums []int, low, high int)
leetcode/weekly/233/d/d.go:28
FunctioncountPairs2
(a []int, low, high int)
leetcode/weekly/233/d/d.go:103
FunctioncountPalindromicSubsequence
* 枚举回文子序列的中间字符,并枚举其左右字符(从 $\texttt{a}$ 到 $\texttt{z}$),若该字符在中间字符左右侧均存在,则找到一个回文子序列 我们可以在枚举中间字符的同时,计算字符串的前缀和与后缀和,这样就能判断某个字符在中间字符左右侧均存在 由于题目要求相同的子序列只计数一次
leetcode/weekly/249/b/b.go:13
FunctioncountPaths
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/59/c/c.go:4
FunctioncountPoints
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/50/b/b.go:4
FunctioncountPoints
(s string)
leetcode/weekly/271/a/a.go:8
MethodcountPrefixOfString
结合 rank 和 kth,可以求出一个字符串的前驱和后继 见 bst.go 中的 prev 和 next 返回字符串 s 在 trie 中的前缀个数 https://www.acwing.com/problem/content/144/ https://codeforces.com/gym/101
copypasta/trie.go:154
FunctioncountPyramids
* 动态规划 先求正金字塔。 定义 $\textit{dp}[i][j]$ 表示金字塔顶端位于 $(i,j)$ 时的最大层数($1$ 层也算)。如果顶端在 $(i,j)$ 的金字塔最大能有 $x$ 层,那么顶端在 $(i,j)$ 的金字塔也可以有 $x-1,x-2,\cdot,\1$ 层。由于要
leetcode/biweekly/66/d/d.go:22
FunctioncountQuadruplets
github.com/EndlessCheng/codeforces-go
leetcode/weekly/257/a/a.go:4
MethodcountRange
EXTRA: 查询区间 [l,r] 中在 [low,high] 范围内的元素个数 low 和 high 为离散化后的值(从 1 开始) http://acm.hdu.edu.cn/showproblem.php?pid=4417 https://codeforces.com/problemset/p
copypasta/segment_tree.go:643
FunctioncountRangeSum
LC 327 基于求逆序对的思路
leetcode/main.go:1136
FunctioncountRestrictedPaths
(n int, edges [][]int)
leetcode/weekly/231/c/c.go:44
MethodcountRoots
st 所处连通分量的大小
copypasta/union_find.go:283
FunctioncountRoutes
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/34/d/d.go:4
FunctioncountServers
(grid [][]int)
leetcode/weekly/164/b/b.go:3
FunctioncountSpecialSubsequences
(nums []int)
leetcode/weekly/252/d/d.go:22
FunctioncountSquares
(mat [][]int)
leetcode/weekly/165/c/c.go:3
FunctioncountSteppingNumbers
github.com/EndlessCheng/codeforces-go
leetcode/biweekly/10/c/c.go:9
MethodcountStringHasPrefix
返回 trie 中前缀为 p 的字符串个数 此时 o.cnt 保存子树字符串个数 https://codeforces.com/gym/101628/problem/K LC1804 https://leetcode-cn.com/problems/implement-trie-ii-prefix-
copypasta/trie.go:170
FunctioncountSubIslands
(grid1, grid2 [][]int)
leetcode/weekly/246/c/c.go:13
FunctioncountSubTrees
(n int, edges [][]int, s string)
leetcode/weekly/198/b/b.go:3
FunctioncountSubgraphsForEachDiameter
github.com/EndlessCheng/codeforces-go
leetcode/weekly/210/d/d.go:4
FunctioncountSubstrings
注:复杂度 O(nm) 的做法: 定义 dp[i][j] 表示以 s[i] 和 t[j] 结尾的所有子串对中,恰好只有一个字符不同的子串对的数目 github.com/EndlessCheng/codeforces-go
leetcode/biweekly/38/c/c.go:7
← previousnext →6,501–6,600 of 8,098, ranked by callers