编程介的小学生 2019-04-08 10:37 采纳率: 20.5%
浏览 152

用字符串实现单词置换字母的程序的算法,采用C语言的编写代码的技术的实现怎么做

Problem Description
Lingo is a once popular game show where the contestants have to guess words. In the original version the contestants would have to guess a five-letter word each round.
In between the rounds of regular word guessing, the contestants can win a bonus prize if they can guess a ten-letter word. The ten-letter word is displayed with the letters permuted. Some letters are colored indicating that they are displayed in the right position. Since there are not that many ten-letter words, it happens frequently that the word is actually a compound: a word constructed by concatenating two shorter words. In this problem we
assume that the ten-letter word is always of this form.
Given a dictionary and a sequence of ten letters, you must calculate the possible solutions to the ten-letter word game. Two solutions are considered different if they are constructed from different parts, even if their concatenation is the same. This is illustrated by the the second sample case.

Input
On the first line an integer t (1 <= t <= 100): the number of test cases. Then for each test case:

One line with an integer n (1 <= n <= 200): the number of words in the dictionary.

n lines with a single word in the dictionary. Each word is between 1 and 9 (inclusive) characters long and consists of only lowercase letters.

One line with an integer q (1 <= q <= 100): the number of queries.

q lines with a single query string. Each query is exactly 10 characters long and will consist of uppercase and lowercase letters. Lowercase letters are in the right position and uppercase letters may be in the wrong position.
All words in the dictionary for a single test case are distinct.

Output
For each test case, output for each query:

One line with an integer s: the number of solutions.

min(1000, s) lines, each a solution formatted as two dictionary words separated by a hyphen (-).

The solutions to a single query must be ordered lexicographically. If the number of solutions exceeds 1000, then only output the first 1000 solutions.

Notes
If s and t are strings of equal length and si denotes the ith character of s, then s precedes t lexicographically if for some i: si < ti and sj = tj for all j < i. In this problem statement, the hyphen precedes all letters lexicographically.

Sample Input
2
5
gunner
integral
relating
tail
un
4
TAILGUNNER
unINTEGRAL
UNrelating
IMPOSSIBLE
3
aaaa
aaaaa
aaaaaa
1
AAAAAAAAAA

Sample Output
6
gunner-tail
integral-un
relating-un
tail-gunner
un-integral
un-relating
2
un-integral
un-relating
1
un-relating
0
3
aaaa-aaaaaa
aaaaa-aaaaa
aaaaaa-aaaa

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥50 易语言把MYSQL数据库中的数据添加至组合框
    • ¥20 求数据集和代码#有偿答复
    • ¥15 关于下拉菜单选项关联的问题
    • ¥20 java-OJ-健康体检
    • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
    • ¥15 使用phpstudy在云服务器上搭建个人网站
    • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
    • ¥15 vue3+express部署到nginx
    • ¥20 搭建pt1000三线制高精度测温电路
    • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况