BestCoder Round #73 (div.2) Rikka with Graph 1002
来源:互联网 发布:sql截断字符串 编辑:程序博客网 时间:2024/06/03 20:14
Rikka with Graph
Accepts: 123
Submissions: 525
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
并查集。
暴力删除一条或者两条边。O(N^3)
// Yu 20160221//bestcoder Rikka with Graph#include<iostream>//#include<stdlib.h>//#include<string.h>using namespace std;#define MAX_N 103int set[MAX_N];pair<int,int> p[MAX_N];int find(int x){int r=x;while(set[r]!=r)r=set[r];return r;}int merge(int x,int y){int fx=find(x);int fy=find(y);if(fx==fy)return 0;elseset[fx]=fy;return 1;}int main(){int T;int n;long count,num;cin>>T;while(T--){num=0;cin>>n;for(int i=0;i<=n;i++){cin>>p[i].first>>p[i].second;}for(int i=0;i<=n;i++){for(int j=i;j<=n;j++){count=n;for(int l=0;l<=n;l++){set[l]=l;}for(int k=0;k<=n;k++){if(k!=i&&k!=j){if(merge(p[k].first,p[k].second)==1)count--;}}if(count==1)num++;}}cout<<num<<endl;}}
0 0
- BestCoder Round #73 (div.2) Rikka with Graph 1002
- BestCoder Round #53 (div.2) 1001 Rikka with Graph
- BestCoder Round #53 (div.2) HDOJ5422 Rikka with Graph(floyd)
- Rikka with Graph-------(BestCoder Round #53 (div.2))
- BestCoder Round #73 (div.2)-Rikka with Graph(图的连通性)
- BestCoder Round #73 (div.2) Rikka with Chess 1001
- BestCoder Round #53 (div.2) 1002 Rikka with Tree
- HDU 5631 (BestCoder Round #73 (div.1) 1001)Rikka with Graph(并查集)
- BestCoder Round #53 (div.2)1003 Rikka with Graph II 哈密顿路径 dfs
- BestCoder Round #53 (div.2) HDOJ5424 Rikka with Graph II(dfs & 哈密顿通路判断)
- HDU 5422 Rikka with Graph(水题)——BestCoder Round #53(div.2)
- BestCoder Round #53 (div.2) C.Rikka with Graph II(dfs)
- BestCoder Round #53 (div.2) HDOJ5423 Rikka with Tree(bfs)
- Rikka with Tree-----(BestCoder Round #53 (div.2))
- hdu5634 BestCoder Round #73 (div.1) Rikka with Phi 解题报告
- HDU 5423 Rikka with Tree(bfs or dfs)——BestCoder Round #53(div.1 div.2)
- Rikka with string-------(BestCoder Round #37)
- BestCoder Round #73 (div.2)1002/hdoj5631
- OC语言之内存管理简介
- PHP1
- ON DUPLICATE KEY UPDATE
- 内联函数
- VirtualBox Centos的IP快速配置
- BestCoder Round #73 (div.2) Rikka with Graph 1002
- 吉他入门
- POJ 1200 Crazy Search
- Remove Duplicates from Sorted Array
- MAC地址与IP地址
- C/C++开源项目清单
- 欢迎使用CSDN-markdown编辑器
- java.lang.RuntimeException: native typeface cannot be made
- HDU 5556 Ancient Go 模拟