zoukankan      html  css  js  c++  java
  • ZOJ 3603 Draw Something Cheat



    Draw Something Cheat

    Time Limit: 2 Seconds      Memory Limit: 65536 KB

    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
    Author: LI, Cheng
    Contest: The 9th Zhejiang Provincial Collegiate Programming Contest



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

    using namespace std;

    char str[25];
    int un[30],tm[30];

    void jishu()
    {
        memset(tm,0,sizeof(tm));
        for(char c='A';c<='Z';c++)
        {
            int cnt=0;
            for(int i=0;i<12;i++)
            {
                if(str==c)
                {
                    cnt++;
                }
            }
            tm[c-'A']=cnt;
        }
    }

    int main()
    {
        int T,n;
        scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        scanf("%s",str);
        jishu();
        for(int i=0;i<26;i++)
        {
           un=tm;
        }
        for(int i=1;i<n;i++)
        {
            scanf("%s",str);
            jishu();
            for(int j=0;j<26;j++)
            {
                un[j]=min(un[j],tm[j]);
            }
        }

        for(int i=0;i<26;i++)
        {
            while(un)
            {
                putchar(i+'A');
                un--;
            }
        }
        putchar(10);
    }

        return 0;
    }




  • 相关阅读:
    重新学习C#系列-02.静态类、静态字段和静态方法
    Appcan学习笔记(3)——tabview 静止页面左右滑动切换
    Appcan学习笔记(2)——子页面调用父页面的方法
    Appcan学习笔记(1)——父页面调用子页面的方法
    重新学习C#系列-01.方法参数
    WP8.1 Runtime应用利用HttpClient初始化数据的一些考虑
    C# socket通讯使用域名的方法
    RSA私钥加密
    RSA公钥加密
    13位时间戳转换成标准时间C#代码
  • 原文地址:https://www.cnblogs.com/CKboss/p/3350934.html
Copyright © 2011-2022 走看看