Two Pointer - Problems Problems01-Subarray Sums与 Solution - Books 做法类似。不同之处在于,更新 $ans$ 时改为判断 当前子数组之和 $cur$ 是否等于 目标和 $x$ ,是的话 $ans+1$ https://cses.fi/problemset/task/1660 n, x = map(int, input().split()) arr = list(map(int 2026-02-04 Sorting & Searching
Two Pointers 双指针 Two Pointers 双指针概念双指针方法通过在数组中迭代两个指针来跟踪满足某些条件的索引。有两种常见的变体: 两个指针从数组的两端开始,并相互移动。 两个指针以不同速度沿同一方向移动。这种变体被称为滑动窗口算法。 Sum of Two Valueshttps://cses.fi/problemset/task/1640 Solution我们要找到两个索引 $i$ 和 $j$ ,使得 2026-01-30 Sorting & Searching #双指针
Graph 图 Graph 图邻接表pythonN, M = map(int, input().split()) adj = [[] for _ in range(N)] for i in range(M): u, v = map(int, input().split()) adj[u].append(v) adj[v].append(u) u = 1 # print number of vertice 2026-01-30 Graphs #图搜索算法 #DFS #BFS
bug修复:GPU内存不足问题 nvidia-smi kill -9 34069 # 占用最多的进程 # 或者使用pkill pkill -f "python" 2026-01-30 bug修复 #bug修复 #GPU内存不足
expected str, bytes or os.PathLike object, not MultiplexedPath 错误信息显示: TypeError: expected str, bytes or os.PathLike object, not MultiplexedPath 这个错误是因为 tn库(text normalization库)在创建缓存目录时收到了一个 MultiplexedPath对象而不是字符串路径。 MultiplexedPath是 HuggingFace 的 huggingface_hu 2026-01-30 bug修复 #bug修复 #TypeError
数据结构 Queues 队列队列是一种先进先出 First In First Out(FIFO)的数据结构,支持三种操作,所有操作的时间复杂度均为 $\mathcal{O}(1)$ 。 std::queue push: 在队列的末尾插入 pop: 从队列的前端删除 front: 获取前端元素但不将其移除 queue<int> q; q.push(1); 2025-12-19 algorithm #队列
使用递归的穷举搜索 使用递归的穷举搜索Subsets 子集https://cses.fi/problemset/task/1623 递归生成子集编写一个递归函数,遍历所有可能的分组方式。 在某个索引处,我们要么将 $\texttt{apple}_i$ 添加到第一个集合,要么添加到第二个集合,存储两个总和 $\texttt{sum}_1$ 和 $\texttt{sum}_2$ ,分别表示每个集合中值的总和。 一 2026-01-30 Graphs #穷举搜索 #递归
05_Cow_Gymnastics 问题描述USACO 2019 December Contest, Bronze Problem 1. Cow Gymnasticshttps://usaco.org/index.php?page=viewproblem2&cpid=963 奶牛们正在进行体操训练,Bessie 记录了 K 次训练课中 N 头奶牛的排名。我们需要找出所有”一致”的奶牛对,即其中一头奶牛在每次训练课中都表现得比 2025-11-20 Complete_Search
04_Counting_Liars 问题描述USACO 2022 US Open Contest, Bronze Problem 2. Counting Liarshttps://usaco.org/index.php?page=viewproblem2&cpid=1228 农夫约翰有 $N$ 头奶牛(不包括 Bessie)。每头牛给出一条关于 Bessie 躲藏位置的陈述: 若某头牛说 $L$ :意思是 _Bessie 2025-11-20 Complete_Search
02_Diamond_Collector 问题描述USACO 2016 US Open Contest, Bronze Problem 1. Diamond Collectorhttps://usaco.org/index.php?page=viewproblem2&cpid=639 给定长度为 $N$ 的数组和 $K$ ,输出 $subsequence$ 最长的长度,要求 $subsequence$ 中任意两数之差不超过 $K$ 2025-10-29 Complete_Search