博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Gym 101334C 无向仙人掌
阅读量:6951 次
发布时间:2019-06-27

本文共 1475 字,大约阅读时间需要 4 分钟。

给出图,求他的“仙人掌度”,即求包括他自身的生成子图有多少?

只能删去仙人掌上的叶子的一条边,然后根据乘法原理相乘;

1、怎么求一个仙人掌叶子上有多少边? 可以利用点,边双连通的时间戳这个概念,但是绝对时间是不对的,只能用相对的时间戳。

2、怎么把第二种情况剔除掉?    就是记录每一个点加入环中的次数;

3、第三种情况,就是判连通了;

1 #include 
2 3 using namespace std; 4 5 const int maxn = 20000 + 5; 6 7 struct Sol { 8 vector
G[maxn]; 9 int cyclecnt; 10 int cycle[maxn]; 11 int dfn[maxn]; 12 int c[maxn]; 13 int n; 14 int num[maxn]; 15 16 void init(int n) { 17 this->n = n; 18 for(int i=0; i<=n; i++) 19 G[i].clear(); 20 memset(dfn,0,sizeof(dfn)); 21 memset(cycle,0,sizeof(cycle)); 22 memset(num,0,sizeof(num)); 23 cyclecnt = 0; 24 dfn[1] = 1; 25 } 26 27 void AddEdge (int from,int to) { 28 G[from].push_back(to); 29 G[to].push_back(from); 30 } 31 32 void dfs(int u,int fa) { 33 for(int i=0; i
1||dfn[i]==0) { 52 puts("0"); 53 return; 54 } 55 //int res = 1; 56 //for(int i=0;i
=0; i--) 79 printf("%d",num[i]); 80 puts(""); 81 } 82 83 84 85 } sol; 86 87 int main() { 88 freopen("cactus.in","r",stdin); 89 freopen("cactus.out","w",stdout); 90 int n,m; 91 scanf("%d%d",&n,&m); 92 93 sol.init(n); 94 95 for(int i=0; i
View Code

 

转载于:https://www.cnblogs.com/TreeDream/p/6936595.html

你可能感兴趣的文章
MySQL cluster 7.2集群部署配置
查看>>
iptables开放端口的使用方法总结
查看>>
MySQL数据库如何解决大数据量存储问题
查看>>
页面增加Cookie
查看>>
CENTOS6.5 yum配置
查看>>
Cmake编译mysql出错Could NOT find Curses (missing: CURSES_LIBR
查看>>
python操作mysql数据库
查看>>
linux环境下 PYTHONPATH怎么添加
查看>>
查询01_DML锁和DDL锁的处理
查看>>
python读取xml文件
查看>>
ansible 批量部署zabbix客户端
查看>>
组策略中"受限制的组"
查看>>
Java IO与NIO 学习
查看>>
走进JavaWeb
查看>>
【C#】MD5 小程序编写
查看>>
以目标为导向
查看>>
linux下清理日志的脚本
查看>>
Is AI a Risk to Humanity?
查看>>
oracle的service 脚本
查看>>
源码编译安装mysql5.6报错及解决方法
查看>>