随笔分类 - 数据结构--队列
摘要:题目链接https://www.luogu.com.cn/problem/P4017 知识点:拓扑排序+动态规划 一、刚开始审题不清,误认为是求AOV最长生物链上生物的个数,便出现如下代码 1 #include<bits/stdc++.h> 2 using namespace std; 3 cons
阅读全文
摘要:CCF2020 CSP-j2第二题 https://www.luogu.com.cn/problem/P5661 方法一:纯模拟(40分) 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, bs[100005], p[100005],
阅读全文
摘要:先把如下代码熟悉,再学习BFS的框架 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxN=100; 4 int que[maxN];//定义数组模拟队列 5 int f, r;//队首队尾信息 6 int n;//输入数
阅读全文
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1361 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int M=20; 4 int n,k,a[M],b[M]; 5 bool fla
阅读全文
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1362 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, k;//按要求输入 4 int a, b;//按要求输入 5 int rel[1
阅读全文
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1256 1 #include<bits/stdc++.h> 2 using namespace std; 3 int t, row, col; 4 char mp[205][205]; 5 int dir
阅读全文
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1250 此题目难点: 1.利用二进制的与运算判断与隔壁房间是否有墙,从而求出下一步的方向 2.与运算的优先性 3.代码的调试 1 #include<bits/stdc++.h> 2 using names
阅读全文
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1249&teacher=2 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, m; 4 char mp[120][120]; 5 int
阅读全文
摘要:题目链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1257 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, l; 4 int sx, sy; 5 int ex, ey; 6 st
阅读全文
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1360 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, a, b; 4 int k[205]; 5 bool vis[205]; 6 s
阅读全文
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1253 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, k; 4 struct node{ //结构体表示数轴位置和所用时间 5 int
阅读全文
摘要:题目链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1251 1 #include<bits/stdc++.h> 2 using namespace std; 3 int m, n; 4 char mp[25][25]; 5 int sx, sy,
阅读全文
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1330 1 #include<bits/stdc++.h> 2 using namespace std; 3 int ax, ay, bx, by; 4 struct node{ //结构体标记当前位置坐
阅读全文
摘要:http://ybt.ssoier.cn:8088/problem_show.php?pid=1329 方法一:DFS 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n, m; 4 char c; 5 char a[1000][1000
阅读全文
摘要:有向图、无向图,DFS和BFS的不同遍历方式:https://segmentfault.com/a/1190000010348783
阅读全文
摘要:题目连接(本题目链接失效内容同《围圈报数》):http://ybt.ssoier.cn:8088/problem_show.php?pid=1418 围圈报数链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1334 从队列到循环单链表写了一下午都写
阅读全文
摘要:题目链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1360 方法一:BFS 其实这是个最短路问题,于是还可以用以下两种算法 方法二:floyd算法 方法三:dijkstra算法
阅读全文
摘要:题目链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1359 【思路分析】这个题属于逆向思维,直接统计围成面积很难,换种思路,将面积以外的所有0点置1再统计0数即为围成面积,这样就转换成4连通块的问题了!当然这儿有个小思考就是外围面积置1时一定要从
阅读全文
摘要:题目链接:http://ybt.ssoier.cn:8088/problem_show.php?pid=1335 方法一:dfs 方法二:bfs:STL优美展示--笑脸 方法三:并查集???大佬博客传送门 一种题多种写法,深化对算法对理解 【类型题扩展】 四连通》》八连通(什么鬼https://bl
阅读全文