Draw Something Cheat(历经磨难的题目)

Have you played Draw Something? It's currently one of the hottest social drawing games on Apple iOS and Android Devices! In this game, you and your friend play in turn. You need to pick a word and draw a picture for this word. Then your friend will be asked what the word is, given the picture you have drawn. The following figure illustrates a typical scenario in guessing the word.

word guessing in draw something

As you see, when guessing a word you will be given the picture and 12 letters. You must pick some of these letters to form a word that matches the picture. Each letter can only be used once. It is a lot of fun if your friend is a talented painter, but unfortunately some drawings from your friend are totally incomprehensible. After several times of becoming mad by the drawings, you find a way to cheat in the game.

In this game, letters not included in the correct answer are randomly generated. If you cannot find the correct answer when guessing, you can write down all the letters and restart the game. Then you would find some of these letters are changed. Of course these changed letters will never appear in the answer. By eliminating these letters you are a step closer to the answer.

So In this problem, you need to write a program to automate the cheating process. Given N strings of letters to the same picture, you need to eliminate as many letters as possible, and output the remaining letters.

Input

There are multiple test cases. The first line of the input is an integer T ≈ 1000 indicating the number of test cases.

Each test case begins with a positive integer N ≤ 20 indicating the number of times you have entered the game. Then N lines follow. Each line is a string of exactly 12 uppercase letters, indicating the candidate letters in one guess. It is guaranteed that the answer has at least 1 letter and has no more than 12 letters.

Output

For each test case, output the remaining letters in alphabet order after the process described above. One line for each test case.

Sample Input
2
2
ABCDEFGHIJKL
ABCDEFGHIJKL
2
SAWBCVUXDTPN
ZQTLFJYRCGAK
Sample Output
ABCDEFGHIJKL
ACT
 
  

题意如下:

     画家的画是打乱,他要你把这些字母组成一个单词相匹配的图片,先给你画家打乱的画,之后有n-1行,表示给你的提示。

    输入的第一行表示,有T个样例,之后就是输入n,表示给你的信,输出把这些字母组成一个单词相匹配的图片。

思路:

     其实就是求第一行,与n-1行之间的关系,求共同单词,(要按照字典序排序输出。)

注意:

    每一个单词不一定只有一个(坑点。)

代码如下:

#include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

int str[29],str1[29];

int main()
{
    int T,n,i,j;
    char a[15];
    cin>>T;
    while (T--)
    {
        memset(str,0,sizeof(str));
        memset(str1,0,sizeof(str1));
        cin>>n;
        cin>>a;
        for(int i=0; i<strlen(a); i++)
            str[a[i]-'A']++;
        n-=1;
        while(n--)
        {
            cin>>a;
            for(int i=0; i<strlen(a); i++)
                str1[a[i]-'A']++;
            for(int i=0; i<26; i++)
            {
                if(str[i]!=0 && str1[i]!=0)
                    str[i] = min(str[i],str1[i]);
                else
                    str[i] = 0;
                str1[i] =0;
            }
        }
        for(int i=0; i<26; i++)
        {
            while(str[i]>0)
            {
                printf("%c",'A'+i);
                str[i]--;
            }
        }
        printf("\n");
    }
    return 0;
}

转载于:https://www.cnblogs.com/new-zjw/p/8540935.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值