当前位置:网站首页>【学习笔记】图的连通性与回路
【学习笔记】图的连通性与回路
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
不会
刚开始想歪了 。
其实看到出度入度为偶数的限制很容易想到欧拉回路 。
问题在于欧拉回路保证出度 = 入度,不保证出入度为偶数 。
考虑将欧拉回路中的偶数边取反,这样除终点外路径上经过的点一定满足限制 。
最后判断边的总数,如果为奇数则在起点连一个自环即可 。
边栏推荐
- Show strength. In this way, the mobile phone will not be difficult to move forward
- 基于 TiDB 场景式技术架构过程 - 理论篇
- Make the seckill Carnival more leisurely: the database behind the promotion (Part 2)
- 为什么我认识的机械工程师都抱怨工资低?
- 广发期货排名多少?网上办理广发期货开户安全可靠吗?
- Mysql database installation tutorial under Linux
- Enjoy what you want. Zhichuang future
- 最简单不用证书也可以多开功能的方式
- 一网打尽异步神器CompletableFuture
- 03_ Dataimport of Solr
猜你喜欢

世界环境日 | 周大福用心服务推动减碳环保

Tiflash compiler oriented automatic vectorization acceleration

Brief introduction to revolutionary neural networks

TiFlash 源码解读(四) | TiFlash DDL 模块设计及实现分析

What category does the Internet of things application technology major belong to

循环不变式

The IPO of Ruineng industry was terminated: the annual revenue was 447million and it was planned to raise 376million

Introduction, installation, introduction and detailed introduction to postman!

LeetCode_ 2 (add two numbers)

openGauss数据库源码解析系列文章—— 密态等值查询技术详解(下)
随机推荐
如何深入理解“有限状态机”的设计思想?
神经网络物联网未来发展趋势怎么样
Introduction, installation, introduction and detailed introduction to postman!
Implementation process of WSDL and soap calls under PHP5
Linux下mysql数据库安装教程
LeetCode_ 69 (square root of x)
Lepton 无损压缩原理及性能分析
What category does the Internet of things application technology major belong to
循环不变式
登录界面代码
Simple process of penetration test
04_solr7.3之solrJ7.3的使用
VC development of non MFC program memory leak tracking code
The simplest way to open more functions without certificates
怎么叫一手一机的功能方式
不相交集
R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用shadow_mark函数为动画添加静态散点图作为动画背景
Tdengine biweekly selection of community issues | phase III
R语言ggplot2可视化条形图:通过双色渐变配色颜色主题可视化条形图、为每个条形添加标签文本(geom_text函数)
LeetCode_ 3 (longest substring without repeated characters)