当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4181:Insidious Branding

题目描述
A brand designer came up with a strategy that you think will be the key to the success of your company, and therefore, you. The strategy is to use a brand name that has two possible decompositions into a pair of frequently used everyday words, and then expose the consumer to the four words repeatedly in brief episodes of sensory bombardment. The feeble mind of the consumer will jar, and the brand will then ease its way into the victim's long-term memory. Your task is to write a program that sifts through a dictionary for combinations of four words (not necessarily distinct), say A, B, C and D, which satisfy the equation A + B = C + D where '+' denotes concatenation, '=' denotes an exact string match, the length of the word A is strictly less than the length of the word C, and all four strings are not empty.
输入解释
The input consists of multiple cases where one dictionary is used for each case. A case starts with an integer W (1 <= W < 100,000) that indicates the number of words in the dictionary on a line by itself. Each of the following W lines contains a single word. The words are in no particular order, and they are all distinct within a test case. Each word is a string that consists of L lowercase letters and contains no spaces. 1 <= L <= 30. The input is terminated by a zero on a line by itself.
输出解释
The output consists of a single integer, on a line by itself, that represents the number of equations that can be formed.
输入样例
4
catchment
ally
catch
mentally
0
输出样例
1
来自杭电HDUOJ的附加信息
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-4181

最后修改于 2020-10-25T23:11:01+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
10000/3000MS(Java/Others) 327680/327680K(Java/Others)