Ming's Blog
  • 首页
  • 归档
  • 分类
  • 标签
  • 关于

Binary Search 二分搜索

有序数组的二分搜索 Example - Counting Haybales https://usaco.org/index.php?page=viewproblem2&cpid=666 import sys sys.stdin = open("haybales.in", "r") sys.stdout = open("haybale
2026-02-05
Sorting & Searching

Two Pointer - Problems

Problems  01-Subarray Sums 与 Solution - Books 做法类似。不同之处在于,更新 ans 时改为判断 当前子数组之和 cur 是否等于 目标和 x ,是的话 ans + 1 https://cses.fi/problemset/task/1660 n, x = map(int, input().split()) arr = list(map(i
2026-02-04
Sorting & Searching

Two Pointers 双指针

Two Pointers 双指针 概念 双指针方法通过在数组中迭代两个指针来跟踪满足某些条件的索引。有两种常见的变体: 两个指针从数组的两端开始,并相互移动。 两个指针以不同速度沿同一方向移动。这种变体被称为滑动窗口算法。 Sum of Two Values https://cses.fi/problemset/task/1640 Solution 我们要找到两个索引 i
2026-01-30
Sorting & Searching
#双指针

Graph 图

Graph 图 邻接表 python N, 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 v
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 的 huggingf
2026-01-30
bug修复
#bug修复 #TypeError

数据结构

Queues  队列 队列是一种先进先出 First In First Out(FIFO)的数据结构,支持三种操作,所有操作的时间复杂度均为 𝒪(1) 。 std::queue push: 在队列的末尾插入 pop: 从队列的前端删除 front: 获取前端元素但不将其移除 queue<int> q; q.push(1); //
2025-12-19
algorithm
#队列

使用递归的穷举搜索

使用递归的穷举搜索 Subsets  子集 https://cses.fi/problemset/task/1623 递归生成子集 编写一个递归函数,遍历所有可能的分组方式。 在某个索引处,我们要么将 applei​ 添加到第一个集合,要么添加到第二个集合,存储两个总和 sum1​ 和 sum2​ ,分别表示每个集合中值的总和。 一旦到达数组的末尾,我们返回这两个总和的差值。 #
2026-01-30
Graphs
#穷举搜索 #递归

05_Cow_Gymnastics

问题描述 USACO 2019 December Contest, Bronze Problem 1. Cow Gymnastics https://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 Liars https://usaco.org/index.php?page=viewproblem2&cpid=1228 农夫约翰有 N 头奶牛(不包括 Bessie)。每头牛给出一条关于 Bessie 躲藏位置的陈述: 若某头牛说 L :意思是 _Be
2025-11-20
Complete_Search
12

搜索

Hexo Fluid