POJ1628Fillword


  一夜落寞,万物失色。

Fillword
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 1338 Accepted: 697

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

 题目还是比较简单的,对于这个题,简直就是个字符串预计题目
#include <cstring>
#include <cstdio>
using namespace std;
char a[1003];
int sum[507];
int main()
{
    int n,m,q;
    scanf("%d%d%d",&n,&m,&q);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",a);
        int len=strlen(a);
        for(int j=0;j<len;j++)
        {
            sum[a[j]]++;
        }
    }
    for(int i=1;i<=q;i++)
    {
        scanf("%s",a);
        int len=strlen(a);
        for(int j=0;j<len;j++)
        {
            sum[a[j]]--;
        }
    }
    for(int i=1;i<=507;i++)
    {
        if(sum[i])
            for(int j=1;j<=sum[i];j++)
                printf("%c",i);
    }
 return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值