连通图(sf14d) 解题思路:注意事项:真的很无语参考代码:#includeusingnamespacestd;shortfather[20005];intn,m,w;intx,y;intfindfather(intx){while(x!=father[x])x=father[x];retu 题解列表 2025年06月01日 0 点赞 0 评论 420 浏览 评分:0.0
连通图(sf14b) 解题思路:注意事项:参考代码:#includeusingnamespacestd;constintN=100005;intfather[N];//找根节点intFind(intx){if(x==father[x])returnx;elsereturnfather[x]=F 题解列表 2025年06月01日 0 点赞 0 评论 393 浏览 评分:0.0
连通图是否连通(sf14a) 解题思路:注意事项:记得压缩路径参考代码:#includeusingnamespacestd;constintN=1005;intfather[N];//找根节点intFind(intx){if(x==father[x])returnx;elsereturnfather[ 题解列表 2025年06月01日 0 点赞 0 评论 429 浏览 评分:0.0
dfs深度(sf13e) 解题思路:注意事项:参考代码:#includeusingnamespacestd;intn,m,cnt=0;inta[102];intvisited[101];voiddfs(intindex,intsum){if(sum>m)return;if(sum==m){/*fo 题解列表 2025年06月01日 0 点赞 0 评论 511 浏览 评分:0.0
DFS深度(sf13d) 摘要:解题思路:深度:一个个遍历下去,不撞南墙不回头(南墙:前面没有可以遍历的对象,回头:回到最近的岔路口,走没有走过的其他岔路)&n…… 题解列表 2025年05月30日 1 点赞 0 评论 457 浏览 评分:0.0
链表合并map(sf13c) 摘要:解题思路:map<int,int>mp;//一个是键,一个是值//map有自动排序特性注意事项:注意map的输入和输出的方式参考代码:#include<bits/stdc…… 题解列表 2025年05月29日 1 点赞 0 评论 826 浏览 评分:10.0
有序线表合并(sf13b) 解题思路:L1.push_back(x);//容器L1的尾部添加元素xL1.push_front(x)//容器L1的首部添加元素x、L1.merge(L2);//合并,原来有序,合并后也有序,反之注意事项:题目为多组数据参考代码:#includeusingnamespac 题解列表 2025年05月29日 0 点赞 0 评论 599 浏览 评分:0.0
队列queue(sf13a) 解题思路:注意事项:在操作2时,当队列为空时,输出no,且return0(退出);参考代码:#includeusingnamespacestd;intmain(){intn,op,x;//op为操作queueq;cin>>n;//一共有多少个指令while(n- 题解列表 2025年05月29日 0 点赞 0 评论 486 浏览 评分:0.0