• 数组


    开个数组保存有多少个字母,然后输出微笑Good morning。everybody!

    G - 7
    Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu

    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.

    Process to the end of file.


    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 <stdio.h>
    #include <stdlib.h>
    #include <malloc.h>
    #include <limits.h>
    #include <ctype.h>
    #include <string.h>
    #include <string>
    #include <math.h>
    #include <algorithm>
    #include <iostream>
    #include <queue>
    #include <stack>
    #include <deque>
    #include <vector>
    #include <set>
    //#include <map>
    using namespace std;
    #define MAXN 15
    char map[MAXN][MAXN];
    
    int main(){
        int n,m,p;
        int i,j;
        char b[120];
        int num[50];
    
        while(~scanf("%d%d%d",&n,&m,&p)){
            memset(num,0,sizeof(num));
            for(i=0;i<n;i++){
                scanf("%s",map[i]);
                for(j=0;j<m;j++){
                    num[map[i][j]-'A']++;
                }
            }
            for(i=0;i<p;i++){
                scanf("%s",b);
                int len = strlen(b);
                for(j=0;j<len;j++){
                    num[b[j]-'A']--;
                }
            }
            for(i=0;i<26;i++){
                while(num[i]>0){
                    printf("%c",i+'A');
                    num[i]--;
                }
            }
            printf("
    ");
        }
    
        return 0;
    }
    


  • 相关阅读:
    Eclipse汉化教程
    php课程---文件操作及文件上传的代码总结
    php课程---Json格式规范需要注意的小细节
    php课程---php使用PDO方法详解(转)
    php课程---随机数
    php课程---Ajax(老师详解)
    php课程---JavaScript与Jquery的区别
    php课程---JavaScript与Jquery的区别(转)
    php课程---初学PDO
    php课程---练习(联系人信息表)
  • 原文地址:https://www.cnblogs.com/gavanwanggw/p/7265902.html
Copyright © 2020-2023  润新知