题解列表

筛选

连通图(sf14d)

解题思路:注意事项:真的很无语参考代码:#includeusingnamespacestd;shortfather[20005];intn,m,w;intx,y;intfindfather(intx){while(x!=father[x])x=father[x];retu

连通图(sf14b)

解题思路:注意事项:参考代码:#includeusingnamespacestd;constintN=100005;intfather[N];//找根节点intFind(intx){if(x==father[x])returnx;elsereturnfather[x]=F

连通图是否连通(sf14a)

解题思路:注意事项:记得压缩路径参考代码:#includeusingnamespacestd;constintN=1005;intfather[N];//找根节点intFind(intx){if(x==father[x])returnx;elsereturnfather[

dfs深度(sf13e)

解题思路:注意事项:参考代码:#includeusingnamespacestd;intn,m,cnt=0;inta[102];intvisited[101];voiddfs(intindex,intsum){if(sum>m)return;if(sum==m){/*fo

DFS深度(sf13d)

摘要:解题思路:深度:一个个遍历下去,不撞南墙不回头(南墙:前面没有可以遍历的对象,回头:回到最近的岔路口,走没有走过的其他岔路)&n……

链表合并map(sf13c)

摘要:解题思路:map<int,int>mp;//一个是键,一个是值//map有自动排序特性注意事项:注意map的输入和输出的方式参考代码:#include<bits/stdc……

有序线表合并(sf13b)

解题思路:L1.push_back(x);//容器L1的尾部添加元素xL1.push_front(x)//容器L1的首部添加元素x、L1.merge(L2);//合并,原来有序,合并后也有序,反之注意事项:题目为多组数据参考代码:#includeusingnamespac

队列queue(sf13a)

解题思路:注意事项:在操作2时,当队列为空时,输出no,且return0(退出);参考代码:#includeusingnamespacestd;intmain(){intn,op,x;//op为操作queueq;cin>>n;//一共有多少个指令while(n-