编程介的小学生 2019-10-03 20:07 采纳率: 20.5%
浏览 86

Fillword 填写文字的问题

Description

Alex likes solving fillwords. Fillword is a word game with very simple rules. The author of the fillword takes rectangular grid (M cells width, N cells height) and P words. Then he writes letters in the cells of the grid (one letter in one cell) so that each word can be found on the grid and the following conditions are met:

no cell belongs to more than one word

no cell belongs to any word more than once

Some word W (let us consider its length being k) is found on the grid if you can find such sequence of cells (x1, y1), (x2, y2), ..., (xk, yk) that:

(xi, yi) and (xi+1, yi+1) are neighbors (|xi-xi+1| + |yi-yi+1| = 1) for each i = 1, 2, ..., k-1

W[i] is written in the cell with coordinates (xi, yi).

The task is to find all the words on the grid. After they are found, you see that the letters in some cells are not used (they do not belong to any found word). You make up a secret word using these letters and win a big prize.

To make things clear, let us consider the following example (the words are BEG and GEE):

Your task is to help Alex to solve fillwords. You should find out which letters will be left after he finds all the words on the grid. The most difficult task -- to make up a secret word out of them -- we still reserve to Alex.
Input

The first line of the input file contains three integer numbers -- N, M (2 <= M, N <= 10) and P (P <=100). Next N lines contain M characters each, and represent the grid. The following P lines contain words that are to be found on the fillword grid.

Fillword will always have at least one solution. All characters occurring in fillword will be capital English letters.
Output

Output letters from, which a secret word should be made up. Letters should be output in lexicographical order.
Sample Input

3 3 2
EBG
GEE
EGE
BEG
GEE
Sample Output

EEG

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥200 uniapp长期运行卡死问题解决
    • ¥15 latex怎么处理论文引理引用参考文献
    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
    • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?