惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
L
LINUX DO - 热门话题
Blog — PlanetScale
Blog — PlanetScale
博客园 - Franky
J
Java Code Geeks
腾讯CDC
博客园 - 聂微东
The Cloudflare Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
Last Week in AI
Last Week in AI
量子位
Stack Overflow Blog
Stack Overflow Blog
Microsoft Security Blog
Microsoft Security Blog
Google DeepMind News
Google DeepMind News
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Schneier on Security
C
CERT Recently Published Vulnerability Notes
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
有赞技术团队
有赞技术团队
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Securelist
AWS News Blog
AWS News Blog
GbyAI
GbyAI
L
LINUX DO - 最新话题
大猫的无限游戏
大猫的无限游戏
Forbes - Security
Forbes - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Attack and Defense Labs
Attack and Defense Labs
C
CXSECURITY Database RSS Feed - CXSecurity.com
Y
Y Combinator Blog
W
WeLiveSecurity
T
Threatpost
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
P
Proofpoint News Feed
D
DataBreaches.Net
博客园 - 三生石上(FineUI控件)
V
V2EX
N
News and Events Feed by Topic
Google DeepMind News
Google DeepMind News
D
Docker
The Hacker News
The Hacker News
A
About on SuperTechFans
Security Latest
Security Latest
NISL@THU
NISL@THU
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Cisco Talos Blog
Cisco Talos Blog
博客园_首页
H
Hacker News: Front Page

博客园 - saintqdd

hdu 1102 pku 2421 解题报告 pku 2777 Count Color 解体报告 石子合并问题 nkoj1139和乘积最大那题一样. A Tour in Loquat Orchard (FZU 2007 ICPC Qualification Round I tzw) 最大黑区域 滑雪 一道经典题,humble number 今天碰到了一个很诡异的题,Alphacode (zoj 2202) 这两天经常碰到dp题,就写了一个0-1背包 实训以来,到这里的次数少了! 郁闷,乘积最大那题WA原来只是因为我用了pow函数引起的! Smith Number POJ强烈推荐50题 POJ 1014 三十分钟掌握STL STL学习小记 POJ1006,中国剩余定理 POJ1003,简单题
JOJ 2391 words
saintqdd · 2007-08-05 · via 博客园 - saintqdd

大家还记得这道题吗?这是我们集训第一次在吉大网络赛遇到的第一题。问题是,给你一系列的word,从中任选一个做为游戏的开始,选种后,以后选单词的原则就是首字母和上次所单词的尾字母相同,这样一直进行下去,知道找不到毛组要求的单词,这样选中的单词的长度和记为游戏的复杂度,求所有情况中复杂度的最大值。

开始的时候我的思路是:从中按顺序选择,如过选一的复杂度不够大就在选下一个,知道把所有的情况遍历一遍。也就是搜索把。当时没做出来,现在弥补一下,附上我的code:
此题链接:http://acm.jlu.edu.cn/joj/showproblem.php?pid=2391&off=2300

#include<iostream>
int max;
typedef struct{
    char ch[101];
    int f;
}martrix;
int find(martrix a[],int x,int n){
    a[x].f=0;
    char t=a[x].ch[strlen(a[x].ch)-1];
    int i;
    for(i=0;i<n;i++){
        if(a[i].f&&t==a[i].ch[0])
            return strlen(a[i].ch)+find(a,i,n);
    }
    return 0;
}
int main(){
    int n,i,j;
    martrix a[12];
    while(scanf("%d",&n)!=-1){
        i=0;
        while(i<n){
            scanf("%s",a[i].ch);
            a[i].f=1;
            i++;
        }
        int max=0,s;
        for(i=0;i<n;i++){
            s=strlen(a[i].ch)+find(a,i,n);
            if(s>max)
                max=s;
            for(j=0;j<n;j++)
                a[j].f=1;
        }
        printf("%d\n",max);
    }
}