codeforces 508 D. Tanya and Password (fleury算法)
来源:互联网 发布:python批量替换字符串 编辑:程序博客网 时间:2024/05/21 05:41
codeforces 508 D. Tanya and Password (fleury算法)
题目链接:
http://codeforces.ru/problemset/problem/508/D
给出n个长度为3的字符串,如:abc bca aab 如果一个字符串的长度为2的后缀等于,另外一个字符串的长度为2的前缀,则这两个字符串能连起来,比如:aabca,然后这n个字符串可以形成一个图,求图上的一条欧拉通路。
限制:
1 <= n <= 2*10^5,字符串里面有大写字母,小写字母
思路:
把每个字符串当成边,其前缀后缀当作点,如:abc -> ab到bc。
则这个问题化为:有62*62个点,2*10^5条边的图,求一条欧拉通路的题目。
用fleury(弗罗莱),个人感觉用邻接表实现效率比邻接矩阵
ps:这道题dfs会爆栈,把它改成非递归的就行。
附上fleury算法链接
http://www.cnblogs.com/Lyush/archive/2013/04/22/3036659.html
0 0
- codeforces 508 D. Tanya and Password (fleury算法)
- Codeforces 508D Tanya and Password
- Codeforces 508D Tanya and Password
- Codeforces 508D Tanya and Password 欧拉通路Euler
- codeforces 508D Tanya and Password (有向图欧拉通路)
- Codeforces 508D - Tanya and Password (欧拉道路)
- Tanya and Password - CodeForces 508 D 欧拉路径
- CodeForces 508D Tanya and Password(欧拉路径)
- CodeForces 508D Tanya and Password欧拉路径
- codeforces - 508D - Tanya and Password(欧拉通路)
- CodeForces 508D(Codeforces Round #288 (Div. 2))Tanya and Password
- Codeforces Round #288 (Div. 2)---D. Tanya and Password
- codeforces Round#288D Tanya and Password 欧拉通路
- Codeforces Round #288 (Div. 2) D. Tanya and Password
- 【欧拉回路】 Codeforces 288 D Tanya and Password
- Codeforces Round #288 (Div. 2) D Tanya and Password
- Codeforces Round #288 (Div. 2)---D. Tanya and Password
- CF D. Tanya and Password
- 雅克比矩阵、海森矩阵与非线性最小二乘间的关系与在SFM和Pose Estimation中的应用
- CreateFileMapping在N个进程间共享一个HWND类型内存
- 让程序员少走弯路的14个忠告
- Oracle WebLogic Server: How to clear pending XA transactions(Oracle Thin/XA Driver)?
- Xcode6为什么干掉Prefix.pch文件&如何添加pch文件
- codeforces 508 D. Tanya and Password (fleury算法)
- sublime text创建属于自己的插入时间的小插件
- Java_集合操作_使遍历Map时取出的元素顺序与放入时一致
- 领导的境界
- (14) Java 动态代理(JDK)
- Spring Aop实例
- 能长成这样的手机,恐怕只有Project Ara了
- iOS检测代码执行效率
- Hive Join详解