抓住那头牛:利用广度优先算法(队列+访问标记) 摘要:解题思路:队列(两个平行数组 一个是在队列中的位置以及它此时的步数)访问标记(避免访问过的数组再次访问 无用 因为它访问过 它后面的路径就重复了)注意事项:参考代码:#include<stdio…… 题解列表 2025年12月21日 0 点赞 0 评论 28 浏览 评分:0.0
3048: 抓住那头牛 摘要:解题思路:广度优先算法,使用队列的结构注意事项:注意更新状态数组v[MAX_POS+1]参考代码:#include<stdio.h>#include<string.h>#def…… 题解列表 2025年12月11日 0 点赞 0 评论 85 浏览 评分:0.0
抓住那头牛! 双向BFS 摘要:# 双向BFS ###### 更小的时间复杂度,更少的栈空间,更多的代码 ###### tip:小题大做 ``````cpp #include #define ULL unsigned lo…… 题解列表 2024年09月12日 0 点赞 1 评论 354 浏览 评分:9.9
3048: 抓住那头牛 摘要:解题思路: BFS: 三种移动方向 + 1, - 1, 2 * x注意事项:参考代码:#include<iostream> #include<cstring> using namespace st…… 题解列表 2024年04月08日 1 点赞 0 评论 472 浏览 评分:9.9
抓住那头牛(python) 摘要:解题思路:注意事项:参考代码:def catchCow(n, k): if n == k: # 如果农夫和牛的位置相等,那么花费时间为0 return 0 visited …… 题解列表 2024年01月04日 0 点赞 0 评论 312 浏览 评分:0.0
3048: 抓住那头牛 摘要:```cpp #include using namespace std; int n,k; int dfs(int t) { if(t>n>>k; int s=0; …… 题解列表 2023年04月04日 0 点赞 0 评论 631 浏览 评分:9.9
抓住那头牛(广搜) 摘要:解题思路:利用广搜注意事项:参考代码://利用广度优先搜索 //利用广度优先搜索 #include <iostream> #include <queue> using namespace s…… 题解列表 2023年03月31日 1 点赞 0 评论 616 浏览 评分:9.9
dfs+贪心解法 摘要:解题思路:注意事项:参考代码:#include<iostream>using namespace std;int n,k;int dfs(int t){ if(t<=n) { …… 题解列表 2023年03月25日 0 点赞 0 评论 390 浏览 评分:0.0
抓住那头牛,深搜 摘要:``` #include using namespace std; int n,k; //深度搜索 int dfs(int t) //n到t的时间 { //不能乘车 i…… 题解列表 2023年03月20日 0 点赞 0 评论 557 浏览 评分:9.9