POJ3713-Transferring Sylla
来源:互联网 发布:代言宝无水印版源码 编辑:程序博客网 时间:2024/06/09 18:55
Description
After recapturing Sylla, the Company plans to establish a new secure system, a transferring net! The new system is designed as follows:
The Company staff choose N cities around the nation which are connected by "security tunnels" directly or indirectly. Once a week, Sylla is to be transferred to another city through the tunnels. As General ordered, the transferring net must reach a certain security level that there are at least 3 independent paths between any pair of cities a, b. When General says the paths are independent, he means that the paths share only a and b in common.
Given a design of a transferring net, your work is to inspect whether it reaches such security level.
Input
The input consists of several test cases.
For each test case, the first line contains two integers, N ≤ 500 and M ≤ 20000. indicating the number of cities and tunnels.
The following M lines each contains two integers a and b (0 ≤ a, b < N), indicating the city a and city b are connected directly by a tunnel.
The input ends by two zeroes.
Output
For each test case output "YES" if it reaches such security level, "NO" otherwise.
Sample Input
4 60 10 20 31 21 32 34 50 10 20 31 21 37 60 10 20 31 21 32 30 0
Sample Output
YESNONO
Source
题意:给你一个图,判断这个图是不是3连通图(k连通图就是指至少去掉k个点使之不连通的图)
解题思路:枚举两个点,删掉,看剩下的图是否连通,但这样做超时。可以优化为:枚举删去一个点,看是否还存在割点,如果存在割点,则不是3连通图
#include <iostream> #include <cstdio> #include <string> #include <cstring> #include <algorithm> #include <queue> #include <vector> #include <set> #include <stack> #include <map> #include <climits> #include <bitset> using namespace std;#define LL long long const int INF = 0x3f3f3f3f;const int N = 1010;int s[N], nt[2 * N*N], e[2 * N*N];int n, son, m;int subnet[N], dfn[N], low[N], tmpdfn;int vis[N];void init(){tmpdfn = 1, son = 0;memset(dfn, 0, sizeof dfn);memset(low, 0, sizeof low);memset(vis, 0, sizeof vis);memset(subnet, 0, sizeof subnet);}void dfs(int u, int k){low[u] = dfn[u] = tmpdfn++;vis[u] = 1;for (int i = s[u]; ~i; i = nt[i]){int v = e[i];if (vis[v] == 2) continue;if (!vis[v]){dfs(v, k);low[u] = min(low[u], low[v]);if (low[v] >= dfn[u]){if (u != k) subnet[u]++;else son++;}}else low[u] = min(low[u], dfn[v]);}}int main(){while (~scanf("%d%d", &n, &m) && (n + m)){memset(s, -1, sizeof s);int u, v, cnt = 1;for (int i = 1; i <= m; i++){scanf("%d%d", &u, &v);nt[cnt] = s[u], s[u] = cnt, e[cnt++] = v;nt[cnt] = s[v], s[v] = cnt, e[cnt++] = u;}int flag = 0;for (int i = 0; i < n; i++){init();vis[i] = 2;dfs((i + 1) % n, (i + 1) % n);subnet[i] = son - 1;for (int j = 0; j < n; j++)if (subnet[j]) flag = 1;if (flag) break;}if (flag) printf("NO\n");else printf("YES\n");}return 0;}
- POJ3713-Transferring Sylla
- POJ3713: Transferring Sylla 题解
- POJ3713-Transferring Sylla
- poj3713 Transferring Sylla 枚举+tarjan判割点
- POJ-3713-Transferring Sylla
- Transferring Sylla POJ, 3713
- POJ,3713 Transferring Sylla
- Poj 3713 Transferring Sylla 3-连通
- POJ 3713 Transferring Sylla 已翻译
- POJ 3713 Transferring Sylla(图的三联通,tarjan算法
- [POJ 3713] Transferring Sylla (枚举删点+Tarjan求割点)
- poj Transferring Sylla(如何快速的判断一个图是否是3—连通图,求割点,割边)
- Transferring @ Changi airport singapore
- Transferring Jobs 工作调动
- Transferring Files With FTP
- Just only transferring registration
- Converting and transferring data
- rsync Usages For Transferring Files
- Redis常见使用场景
- SDUT-2055
- PAT甲级1005. Spell It Right (20)
- 【转】Rancher部署Træfik实现微服务的快速发现
- TCP空闲扫描原理
- POJ3713-Transferring Sylla
- SVM防止过拟合
- iOS view圆角设置同时又不影响子视图超出父视图部分显示
- VirtualBox相关问题
- 每日一诗词 —— 古诗十九首·其十
- 路灯
- PropertyUtils的使用
- ionic3的页面的三种跳转
- Java反射机制二