日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國(guó)內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁 > 互聯(lián)網(wǎng) > UVA - 10029 Edit Step Ladders (二分+hash)

UVA - 10029 Edit Step Ladders (二分+hash)

來源:程序員人生   發(fā)布時(shí)間:2014-09-09 00:05:46 閱讀次數(shù):2695次

Description

Download as PDF

Problem C: Edit Step Ladders


An edit step is a transformation from one word x to another word y such that x and y are words in the dictionary, and x can be transformed to y by adding, deleting, or changing one letter. So the transformation from dig to dog or from dog to do are both edit steps. An edit step ladder is a lexicographically ordered sequence of words w1, w2, ... wn such that the transformation from wi to wi+1 is an edit step for all i from 1 to n-1.

For a given dictionary, you are to compute the length of the longest edit step ladder.

Input

The input to your program consists of the dictionary - a set of lower case words in lexicographic order - one per line. No word exceeds 16 letters and there are no more than 25000 words in the dictionary.

Output

The output consists of a single integer, the number of words in the longest edit step ladder.

Sample Input

cat
dig
dog
fig
fin
fine
fog
log
wine

Sample Output

5
題意:給你一個(gè)遞增的字符串?dāng)?shù)組,給你三種操作方法變成其他的串,問你最長(zhǎng)的可能
思路:hash+二分,dp[i]表示從i開始的串的最長(zhǎng)變化可能,記憶化搜索
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int MAXN = 25010; const int HASH = 1000010; int n, head[HASH], next[MAXN], f[MAXN]; char b[MAXN][20], temp[20]; int hash(char *s) { int v = 0,seed = 131; while (*s) v = v * seed + *(s++); return (v & 0x7fffffff) % HASH; } void insert(int s) { int h = hash(b[s]); next[s] = head[h]; head[h] = s; } int search(char *s) { int i,h = hash(s); for (i = head[h]; i != -1; i = next[i]) if (!strcmp(b[i],s)) break; return i; } void add(char *s, int p, int d) { int i = 0, j = 0; while (i < p) temp[j++] = s[i++]; temp[j++] = 'a' + d; while (s[i]) temp[j++] = s[i++]; temp[j] = ' 主站蜘蛛池模板: 欧美精品一卡 | 国产精品久久久久久久电影 | 欧美精品1区2区3区 91久久精品一区二区 | 中文字幕免费在线视频 | a级片免费在线 | 日韩高清国产一区在线 | 中文字幕在线观看一区二区三区 | 国产成人精品一区二区 | 精品三级在线观看 | 国产精品一区二区无线 | 色综合天天综合网国产成人网 | 亚洲视频精品一区 | 久久久久久精 | а√最新版天堂中文在线 | 国产一区二区三区精品久久久 | 小草av | 亚洲综合视频一区 | 亚洲欧美中文日韩在线v日本 | 国产激情在线视频 | 免费观看黄色网 | 国产精品99精品久久免费 | 天堂一区二区三区 | 日韩精品一二三四 | 欧美精品一区二区三区四区五区 | 国产精品美女视频 | 成人在线国产视频 | 久久看片网 | 精品久久一区二区三区 | 一区二区免费视频 | 91精品亚洲 | 午夜激情久久久 | 美日韩三级| 亚洲精品66 | 一区二区国产精品 | 欧美二三四区 | 欧美成人性生活视频 | 黄色特级一级片 | 国产在线免 | 久久久免费精品 | 国产一区二区精品久久 | 91精品国产日韩91久久久久久 |