博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 2138 最长路
阅读量:6976 次
发布时间:2019-06-27

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

思路:

如果j能由i得到 则i向j连一条边

答案就是最长路的末节点所代表的string

//By SiriusRen#include 
#include
#include
using namespace std;#define N 3005int n,first[N],next[N*N],v[N*N],tot=1,t,head,tail=1,q[N*N];struct Node{char a[1088];int len;}str[1005];void add(int x,int y){v[tot]=y,next[tot]=first[x],first[x]=tot++;}int main(){ scanf("%d",&n); for(int i=0;i<=n;i++)scanf("%s",str[i].a),str[i].len=strlen(str[i].a); for(int i=0;i<=n;i++) for(int j=0;j<=n;j++) if(str[i].len+1==str[j].len){ int tempa=0,tempb=str[j].len-1; while(str[i].a[tempa]==str[j].a[tempa])tempa++; while(str[i].a[tempb-1]==str[j].a[tempb])tempb--; if(tempa>=tempb)add(i,j); } while(head

这里写图片描述

转载于:https://www.cnblogs.com/SiriusRen/p/6532190.html

你可能感兴趣的文章
揭开Annotation的面纱
查看>>
使用DPM2007备份还原Exchange2007邮箱数据库
查看>>
zabbix企业应用之监控oracle
查看>>
FOSCommentBundle功能包:设置Doctrine ODM映射
查看>>
[Web 开发] 定制IE下载对话框的按钮(打开/保存)
查看>>
无法访问D盘,执行页内操作时的错误
查看>>
我的家庭私有云计划-13
查看>>
转载:什么才是程序员的核心竞争力
查看>>
android:关于主工程和library project
查看>>
Windows 7 开发新特性
查看>>
在客户端调用MOSS的搜索服务,实现更加灵活的搜索控制
查看>>
C++:STL标准入门汇总
查看>>
1001: 整数求和
查看>>
How to develop Silverlight 4 using Visual Studio Express 2010
查看>>
浏览器前进后退对下拉框数据的丢失(省市联动实现和例子)
查看>>
构建安全的 ASP.NET 应用程序
查看>>
从源代码编译里程碑的 ICS ROM
查看>>
Flex通信-Java服务端通信实例
查看>>
Nginx学习笔记(一) Nginx架构
查看>>
JavaScript sync and async(同步和异步)
查看>>