当前位置:网站首页>【学习笔记】图的连通性与回路
【学习笔记】图的连通性与回路
2022-07-05 14:10:00 【仰望星空的蚂蚁】
Graph Subset Problem
第一步删点挺妙的 。
如果一个点的度 < K-1 那么显然不会对答案造成贡献,可以用类似拓扑排序的过程把它删去 。
如果将度 <= K-1 的点删完后有剩余的话,可以解决 case 1 。
这题大小为 K 的团并不好找 。
我一开始的做法萎了
考虑在删掉度 = K-1 的点时判断这个点是否在一个团内 。
直接 O ( K 2 ) O(K^2) O(K2) 枚举是否两两有边 。
稍微算一下会发现时间复杂度 O ( m m log n ) O(m\sqrt{m}\log n) O(mmlogn) 。
细节:当一个点出队时才删除这个点以及和它相邻的边,注意一个点不要入队多次 。
Tanya and Password
拆点搞一搞会发现这题就是叫你求欧拉路 。
可以用栈模拟,考虑一个点走不动后,把这条路径倒序压进答案中 。
细节:注意判断图的联通性,因为是有向图所以检查最终序列的长度比较方便。
一定要先判节点的度啊啊啊啊啊啊啊啊啊啊
Data Center Drama
不会
刚开始想歪了 。
其实看到出度入度为偶数的限制很容易想到欧拉回路 。
问题在于欧拉回路保证出度 = 入度,不保证出入度为偶数 。
考虑将欧拉回路中的偶数边取反,这样除终点外路径上经过的点一定满足限制 。
最后判断边的总数,如果为奇数则在起点连一个自环即可 。
边栏推荐
- R language uses the multinom function of NNET package to build an unordered multi classification logistic regression model, and uses the coef function to obtain the log odds ratio corresponding to eac
- Laravel dompdf exports PDF, and the problem of Chinese garbled code is solved
- R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用shadow_mark函数为动画添加静态散点图作为动画背景
- TiFlash 源码解读(四) | TiFlash DDL 模块设计及实现分析
- Brief introduction to revolutionary neural networks
- SSH免密码登录详解
- 非技术部门,如何参与 DevOps?
- R语言使用原生包(基础导入包、graphics)中的boxplot函数可视化箱图(box plot)
- 神经网络物联网未来现状和趋势及看法
- 04_ Use of solrj7.3 of solr7.3
猜你喜欢

Redis如何实现多可用区?

金融壹賬通香港上市:市值63億港元 葉望春稱守正篤實,久久為功

How to deeply understand the design idea of "finite state machine"?

tidb-dm报警DM_sync_process_exists_with_error排查

治臻新能源冲刺科创板:年营收2.2亿 上汽创投是股东

无密码身份验证如何保障用户隐私安全?

Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting

神经网络物联网未来现状和趋势及看法

魅族新任董事長沈子瑜:創始人黃章先生將作為魅族科技產品戰略顧問

Sorter evolution of ticdc 6.0 principle
随机推荐
Tidb DM alarm DM_ sync_ process_ exists_ with_ Error troubleshooting
R语言使用ggplot2包的geom_histogram函数可视化直方图(histogram plot)
LeetCode_69(x 的平方根 )
Detailed explanation of IP address and preparation of DOS basic commands and batch processing
What are the advantages and characteristics of SAS interface
SAS接口有什么优势特点
IP packet header analysis and static routing
魅族新任董事长沈子瑜:创始人黄章先生将作为魅族科技产品战略顾问
Scenario based technology architecture process based on tidb - Theory
R language ggplot2 visual density map: Visual density map by group and custom configuration geom_ The alpha parameter in the density function sets the image transparency (to prevent multiple density c
The speed monitoring chip based on Bernoulli principle can be used for natural gas pipeline leakage detection
R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用shadow_mark函数为动画添加静态散点图作为动画背景
一网打尽异步神器CompletableFuture
R语言ggplot2可视化条形图:通过双色渐变配色颜色主题可视化条形图、为每个条形添加标签文本(geom_text函数)
关于memset赋值的探讨
Use the word "new" to attract curious people
JS takes key and value from an array object to form a new object
如何将 DevSecOps 引入企业?
-Web direction attack and defense world
R语言ggplot2可视化:使用ggplot2可视化散点图、使用labs参数自定义X轴的轴标签文本(customize X axis labels)