Join the Conversation
2014-11-03 23:41
127 查看
Join the Conversation
pdf
解决方案:最长公共升子序列的模型,此题的最大问题就是名字的获取问题,没发现名字中间可能有'@',一直没发觉,wa了很多次,TT
code:
解决方案:最长公共升子序列的模型,此题的最大问题就是名字的获取问题,没发现名字中间可能有'@',一直没发觉,wa了很多次,TT
code:
#include <iostream> #include<cstdio> #include<cstring> #include<map> using namespace std; char input[2000]; char name[2000]; char mention[2000]; int dp[600000]; int fa[600000]; int path[600000]; map<string,int>Max; map<string,int >key; int main() { int t; // freopen("in.txt","r",stdin); //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); while(~scanf("%d",&t)) { Max.clear(); key.clear(); getchar(); int MMax=1,en=1; memset(dp,0,sizeof(dp)); memset(fa,-1,sizeof(fa)); for(int s=1; s<=t; s++) { gets(input); int len=strlen(input); int i,j=0,u=0; for(i=1; i<len; i++) { if(input[i]==':') break; name[j++]=input[i]; } name[j]='\0'; int temp=1; int n=i+1; for(n; n<len; n++) { if((input[n-1]==' '||n==i+1)&&input =='@') { int k; u=0; for(k=n+1; input[k]!=' '&&k<len; k++) { mention[u++]=input[k]; } mention[u]='\0'; // cout<<name<<" "<<mention<<endl; if(strcmp(name,mention)==0) { n=k; continue; } else { n=k; if(Max[mention]) { if(Max[mention]+1>temp) { fa[s]=key[mention]; temp=Max[mention]+1; } } } } } dp[s]=temp; if(Max[name]<temp) { Max[name]=temp; key[name]=s; } if(MMax<dp[s]) { MMax=dp[s]; en=s; } } printf("%d\n",MMax); int o=0; path[o++]=en; while(fa[en]!=-1) { path[o++]=fa[en]; en=fa[en]; } for(int mm=o-1; mm>=0; mm--) { printf("%d%c",path[mm],mm==0?'\n':' '); } } return 0; }
相关文章推荐
- UVaLive 6680 Join the Conversation (DP)
- UVALive 6680 Join the Conversation (DP)
- 1880: Join the Conversation
- UVALive 6680 Join the Conversation
- UVALive 6680 Join the Conversation (模拟)
- UVALive 6680 Join the Conversation
- What is the difference between left join and left outer join?
- android: create your own personal project and join the github community
- org.hibernate.QueryException: query specified join fetching, but the owner of the fetched associatio
- How to Switch the Driving Table in a Hash Join (文档 ID 171940.1)
- use case when on the outer join condition
- rpmdb: unable to join the environment的解决办法
- Use PowerShell to Replace netdom Commands to Join the Domain
- 【HDU】5743 Join The Future【dp】
- Redis集群一直提示Waiting for the cluster to join....的终极解决方案
- 【HDU5743 2016 Multi-University Training Contest 2J】【dfs展开式DP 前缀和思想】Join The Future 40个数已知区间和为奇或偶输出方案
- mysql练习----The JOIN operation
- 【解决Hiberate】 query specified join fetching, but the owner of the fetched association..
- sqlzoo练习答案--The JOIN operation
- Hibernate异常:query specified join fetching, but the owner of the fetched association was not present in the select list