(poj 3177) Redundant Paths】的更多相关文章

题目链接 :http://poj.org/problem?id=3177 Description In order to <= F <= ,) grazing fields (which are numbered ..F) to another field, Bessie and the rest of the herd are forced to cross near the Tree of Rotten Apples. The cows are now tired of often bei…
求出每个边双连通分量缩点后的度,度为1的点即叶子节点.原图加上(leaf+1)/2条边即可变成双连通图. #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <map> using namespace std; const int N = 5010; const int M = 10010; struct Edge { int…
http://poj.org/problem?id=3177 又写了一遍手动栈... 把边双都缩点,缩成一棵树,答案就是树中度数为1的点的个数除2上取整. 为什么呢?因为1个度数为1的点的树需要多连0条边,2个度数为1的点的树需要多连1条边,3个度数为1的点的树需要多连2条边. 然后对于n(n>3)个度数为1的点的树,连一次边后再缩点能变成有n-2个度数为1的点的树. 无向图边双跟有向图强连通分量的求法很像喔,重点在于特判后继节点是否是自己的father连过来的边. #include<cstd…
Starting in the top left corner of a 22 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. How many such routes are there through a 2020 grid? 题目大意: 从一个22网格的左上角开始,有6条(不允许往回走)通往右下角的路. 对于2020…
Charm Bracelet    POJ 3624 就是一道典型的01背包问题: #include<iostream> #include<stdio.h> #include<algorithm> #include<string.h> using namespace std; ],b[]; ]; int main() { int n,m,i,j; while(scanf("%d%d",&n,&m)!=EOF) { ;i&l…
Scout YYF I Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5565   Accepted: 1553 Description YYF is a couragous scout. Now he is on a dangerous mission which is to penetrate into the enemy's base. After overcoming a series difficulties,…
题目链接:http://vjudge.net/contest/view.action?cid=51369#problem/A   (A - Children of the Candy Corn) http://poj.org/problem?id=2488   (A Knight's Journey) (不知道为什么,名字竟然不同哇~~~~还是poj 改名改得好) 题目意思:给出一个p * q 的棋盘,行用阿拉伯数字1,2,...,p-1, p 来表示,列从大写字母'A'开始表示.我这里为了简化…
取石子游戏 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 37662   Accepted: 12594 Description 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两堆中同时取走相同数量的石子.最后把石子全部取完者为胜者.现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者…
题目:Find The Multiple 题意:求给出的数的倍数,该倍数是只由 1与 0构成的10进制数. 思路:nonzero multiple  非零倍数  啊. 英语弱到爆炸,理解不了题意..... STL 在c++过不了,  一直TLE, 最后只好看了下大神的代码. #include <iostream> #include <algorithm> #include <stdlib.h> #include <time.h> #include <c…
题目:食物链 题意:给定一些关系.判断关系的正确性,后给出的关系服从之前的关系: 思路:难点不在并查集,在于关系的判断,尤其是子节点与根节点的关系的判断: 这个关系看似没给出,但是给出子节点与父节点的关系AND父节点与根节点的关系之后,子节点与根节点的关系是可以确定的. Rank[]存的是与父节点的关系,0是同类,1是被吃,2是吃 1.若Find(x) == Find(y) ,则x y有关系,直接判断关系: 1)  d == 1, Rank[x] == Rank[y] ,  否则fake++:…