多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

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

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

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

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
題意:給你一個遞增的字符串數(shù)組,給你三種操作方法變成其他的串,問你最長的可能
思路:hash+二分,dp[i]表示從i開始的串的最長變化可能,記憶化搜索
#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] = ' 主站蜘蛛池模板: 日本一区二区不卡视频 | 亚洲在线免费视频 | 一级做片爱性视频免费 | 韩日精品| 男人边吃奶边做好爽男女视频 | 在线视频一区二区三区四区 | 日本性欧美 | 日本人护士免费xxxx视频 | 噜噜片| 日韩精品一区二区三区中文在线 | 国产精品高清久久久久久久 | 黄大片日本一级在线a | 亚洲一级香蕉视频 | 欧美xxxx成人免费网站 | 欧美视频三区 | 美国毛片一级视频在线aa | 欧美性生交xxxxx久久久 | 日本亚洲成高清一区二区三区 | 日本高清免费中文字幕不卡 | 欧美另类高清xxxxx | 特级黄aaaaaaaaa毛片 | 日本做爰免费大片视频 | h小视频在线观看 | 久草在线免费色站 | 一区二区视频在线 | 在线观看h视频播放高清 | 2020久久精品永久免费 | 最近中文字幕免费国语 | 印度美女freesex性hd | 亚洲色域网 | 亚洲成在人线久久综合 | 一区二区三区四区在线 | 国产无套免费网站 | 国产h视频免费观看 | 最新国产精品亚洲二区 | 欧美一级特黄特黄毛片 | 亚洲精彩视频 | 鸥美性 | 欧美国产第一页 | 中文字幕无线码一区二区三区 | 亚洲精品久久久久影 |