摘要: 传送门 迷宫中不能有回路,还要连通 如果最后集合数是一个那就是连通,否则不联通 要合并的两个顶点在相同集合内,表示出现了回路 输入时注意一下 1 #include<bits/stdc++.h> 2 using namespace std; 3 int f[100005]; 4 int getf(in 阅读全文
posted @ 2018-11-20 20:58 柠檬加糖 阅读(284) 评论(0) 推荐(0) 编辑
摘要: 传送门 最少好要修多少条路太能使全部城镇连通。只要用并查集算可以连通的城市的组数,修的路就是组数减1 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define C getchar() 4 template <typename T> 5 in 阅读全文
posted @ 2018-11-20 19:10 柠檬加糖 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 传送门 第一道拓扑排序题 每次删除入度为0的点,并输出 这题要求队名小的排前面,所以要用到重载的优先队列 1 #include<bits/stdc++.h> 2 using namespace std; 3 priority_queue<int,vector<int>,greater<int> > 阅读全文
posted @ 2018-11-20 16:09 柠檬加糖 阅读(278) 评论(0) 推荐(0) 编辑
摘要: 传送门 成语接龙,找每个单词都需要一点时间,问最少的时间 把字符串用map处理成数字编号,之后用floyd 1 #include<bits/stdc++.h> 2 using namespace std; 3 map<string,int>g; 4 int road[1005][1005]; 5 i 阅读全文
posted @ 2018-11-20 14:02 柠檬加糖 阅读(195) 评论(0) 推荐(0) 编辑