当前位置:网站首页>【学习笔记】图的连通性与回路
【学习笔记】图的连通性与回路
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语言ggplot2可视化:使用ggplot2可视化散点图、使用labs参数自定义X轴的轴标签文本(customize X axis labels)
- Postman简介、安装、入门使用方法详细攻略!
- Sorter evolution of ticdc 6.0 principle
- 03_ Dataimport of Solr
- 不相交集
- 03_Solr之dataimport
- The forked VM terminated without saying properly goodbye
- Shen Ziyu, nouveau Président de Meizu: M. Huang Zhang, fondateur de Meizu, agira comme conseiller stratégique pour les produits scientifiques et technologiques de Meizu
- [buuctf.reverse] 152-154
- -Web direction attack and defense world
猜你喜欢

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

Shen Ziyu, nouveau Président de Meizu: M. Huang Zhang, fondateur de Meizu, agira comme conseiller stratégique pour les produits scientifiques et technologiques de Meizu

Lepton 无损压缩原理及性能分析

如何深入理解“有限状态机”的设计思想?

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

物联网应用技术专业是属于什么类

upload (1-6)

魅族新任董事长沈子瑜:创始人黄章先生将作为魅族科技产品战略顾问

为什么我认识的机械工程师都抱怨工资低?

Why do mechanical engineers I know complain about low wages?
随机推荐
upload (1-6)
判断变量是否为数组
LeetCode_ 3 (longest substring without repeated characters)
Zhizhen new energy rushes to the scientific innovation board: the annual revenue is 220million, and SAIC venture capital is the shareholder
LeetCode_2(两数相加)
tidb-dm报警DM_sync_process_exists_with_error排查
无密码身份验证如何保障用户隐私安全?
SAS接口有什么优势特点
Shenziyu, the new chairman of Meizu: Mr. Huang Zhang, the founder, will serve as the strategic adviser of Meizu's scientific and technological products
01 、Solr7.3.1 在Win10平台下使用jetty的部署及配置
[buuctf.reverse] 152-154
Mysql database installation tutorial under Linux
Implementation process of WSDL and soap calls under PHP5
循环不变式
Mingfeng medical sprint technology innovation board: annual revenue of 350million yuan, proposed to raise 624million yuan
LeetCode_3(无重复字符的最长子串)
Financial one account Hong Kong listed: market value of 6.3 billion HK $Ye wangchun said to be Keeping true and true, long - term work
01. Solr7.3.1 deployment and configuration of jetty under win10 platform
动态规划
Interpretation of tiflash source code (IV) | design and implementation analysis of tiflash DDL module