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

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3603

    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

    分析:

    给一个母串,N - 1行子串,在母串中找出公共子串即可。

    AC代码:

     1 #include<stdio.h>
     2 #include<string.h>
     3 #include<iostream>
     4 #define min(a,b) a>b?b:a
     5 using namespace std;
     6 int main()
     7 {
     8     int T,a[25][30];
     9     scanf("%d",&T);
    10     while(T--)
    11     {
    12         int n,i,j;
    13         char s[15];
    14         scanf("%d",&n);
    15         memset(a,0,sizeof(a));
    16         for(i=0;i<n;i++)
    17         {
    18             scanf("%s",s);
    19             for(j=0;j<12;j++)
    20                 a[i][s[j]-'A']++;
    21         }
    22         for(i=0;i<26;i++)
    23         {
    24             int minn=a[0][i];
    25             for(j=1;j<n;j++)
    26                 minn=min(minn,a[j][i]);
    27             for(j=1;j<=minn;j++)
    28                 printf("%c",i+'A');
    29         }
    30         printf("
    ");
    31     }
    32     return 0;
    33 }
    View Code
  • 相关阅读:
    ASP.NET Ajax基础-1
    项目管理必读之书-》人月神话
    Discuz2.5菜鸟解析-1
    Jquery初学者指南-1
    敏捷日记
    精品图书大推荐2
    Jquery初学者指南-2
    纯javaScript脚本来实现Ajax功能例子一
    周五面试笑话一则
    JavaScript基础-4
  • 原文地址:https://www.cnblogs.com/jeff-wgc/p/4472212.html
Copyright © 2011-2022 走看看