HDU5438--Ponds (拓排+BFS)】的更多相关文章

点击打开链接 题意:给定n个池塘,m对池塘相连,现在要将与少于2个池塘相连的池塘拆除,形成森林,求节点数为奇数的树权值之和 思路:按照拓排的思想不断删除度数小于2的节点 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=1e4+5; vector <ll> G[N]; queue <ll> Q;//拓排队列 queue <ll> P;//BFS队列 b…
题目链接:http://codeforces.com/contest/721/problem/C 题意:从1走到n,问在时间T内最多经过多少个点,按路径顺序输出. 思路:比赛的时候只想到拓排然后就不知道怎么办了......先拓扑排序,再按照拓扑的顺序进行DP,dp[to][j](到i点走过j个点最短时间) = min(dp[to][j], dp[i][j] + dis) #include<bits/stdc++.h> using namespace std; typedef long long…
Reward 发工资,以前看过这题,做没做忘了(应该是没做). 很明显的拓排.但数据范围这么大,吓得我当时就不敢动手.后来找题解发现还是相当于两层循环(are you kidding me?)当时卡在了不造怎么分层累加,比如4个人,2个关系,1>2,3>4.那么1,3在同一层,2,4在同一层. 题意:年终奖金最低888,但员工间有要求,n个员工,m个要求,m行每行两个数代表前一个人的工资要多于后一个人的.为了满足所有员工的要求,问boss最少需要多少money. 思路:二维数组爆内存,看到几个…
优化连边然后拓排. #include <iostream> #include <sstream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #include <queue> #include <string> #include <string.h> #inc…
目录 题目地址 题干 代码和解释 参考 题目地址 hdu5438 题干 代码和解释 解答本题时参考了一篇代码较短的博客,比较有意思,使用了STL vector二维数组. 可以结合下面的示例代码理解: #include<iostream> #include<vector> using namespace std; int main() { vector<int> n[100]; int i; for(i=0;i<100;i++){ n[i].clear(); } n…
Ponds Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 533    Accepted Submission(s): 175 Problem Description Betty owns a lot of ponds, some of them are connected with other ponds by pipes, an…
Ponds Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 3204    Accepted Submission(s): 995 Problem Description Betty owns a lot of ponds, some of them are connected with other ponds by pipes, a…
Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 2677    Accepted Submission(s): 850 Problem Description Betty owns a lot of ponds, some of them are connected with other ponds by pipes, and th…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud     Going from u to v or from v to u? Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 14778   Accepted: 3911 Description In order to make their sons brave, Jiajia and Wind take t…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3933 给你两棵无根树,让你判断这两棵树是否同构 不会判断树同构,果断抄了个模板,乱搞给过掉了. 首先由于给的是无根树,而要判断无根树是否同构得以重心为根,然后做一个括号序列…