Pursuit For Artifacts CodeForces - 652E Johnny is playing a well-known computer game. The game are in some country, where the player can freely travel, pass quests and gain an experience. In that country there are n islands and m bridges between them…
https://vjudge.net/problem/CodeForces-652E 边双啊,就是点双那个tarjan里面,如果low[v]==dfn[v](等同于low[v]>dfn[u]),表示v及其子节点只能访问到v本身,不能访问到v的祖先,那么边(u,v)是一条桥 然后再dfs一遍,不经过桥,每一次dfs得到的连通块就是一个边双.可以把一个边双缩成一个点,各个边双之间就由桥相连,得到一棵树 对于此题,可以发现,如果在一个边双内有两点a,b,还有一条边(c,d),那么一定存在一条路径从a到…
似乎我搞得太复杂了? 先tarjan缩点然后dfs就行了QAQ. (我不说我被一个sb错调了半个小时....不要以为缩点后dfs就可以肆无忌惮的不加特判判vis了.. bfs的做法:减反图,然后从大到小枚举(贪心),标记即可 #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include <algorit…
K - Cut 'em all! CodeForces - 982C 给一棵树 求最多能切几条边使剩下的子树都有偶数个节点 如果n是奇数 那么奇数=偶数+奇数 不管怎么切 都会有奇数 直接打印-1 贪心 如果子树中的点是偶数 就可以直接切了 最后答案要减一 因为原来的树也是偶数个节点 会被统计进去 #include <cstdio> #include <vector> #include <algorithm> using namespace std; ; int res…
求联通分量个数,在dfs一次 #include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <vector> #include <queue> #include <stack> #include <cstdlib> #include <iomanip> #include <cmath…
Kuro is living in a country called Uberland, consisting of nn towns, numbered from 11to nn, and n−1n−1 bidirectional roads connecting these towns. It is possible to reach each town from any other. Each road connects two towns aa and bb. Kuro loves wa…
本文转自:www.cnblogs.com/collectionne/p/6847240.html 供大家学习 前言:之前翻译过一篇英文的关于割点的文章(英文原文.翻译),但是自己还有一些不明白的地方,这里就再次整理了一下.有兴趣可以点我给的两个链接. 割点的概念 在无向连通图中,如果将其中一个点以及所有连接该点的边去掉,图就不再连通,那么这个点就叫做割点(cut vertex / articulation point). 例如,在下图中,0.3是割点,因为将0和3中任意一个去掉之后,图就不再连通…
本文可转载,转载请注明出处:www.cnblogs.com/collectionne/p/6847240.html .本文未完,如果不在博客园(cnblogs)发现此文章,请访问以上链接查看最新文章. 前言:之前翻译过一篇英文的关于割点的文章(英文原文.翻译),但是自己还有一些不明白的地方,这里就再次整理了一下.有兴趣可以点我给的两个链接. 割点的概念 在无向连通图中,如果将其中一个点以及所有连接该点的边去掉,图就不再连通,那么这个点就叫做割点(cut vertex / articulation…
Cleaning Robot (bfs+dfs) Here, we want to solve path planning for a mobile robot cleaning a rectangular room floor with furniture. Consider the room floor paved with square tiles whose size fits the cleaning robot (1 * 1). There are 'clean tiles' and…
点此看题面 大致题意: 一个由\(R*C\)间矩形宫室组成的宫殿中的\(N\)间宫室里埋藏着宝藏.由一间宫室到达另一间宫室只能通过传送门,且只有埋有宝藏的宫室才有传送门.传送门分为3种,分别可以到达同行的任一宫室(横天门).同列的任一宫室(纵寰门)和以该宫室为中心周围8个的任一宫室(自 由 门).现在你可以从任一宫室开始寻宝,并可以在任一宫室结束寻宝,请求出最多可获得的宝藏数目(每个宝藏只能获得一次). 一个简单的想法 显然,我们可以将每个宫室与它能到达的宫室之间连一条边.由于可能会出现环,我们…