ZOJ 3603 Draw Something Cheat
来源:互联网 发布:破解版360企业云盘mac 编辑:程序博客网 时间:2024/05/17 22:23
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.
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
22ABCDEFGHIJKLABCDEFGHIJKL2SAWBCVUXDTPNZQTLFJYRCGAK
Sample Output
ABCDEFGHIJKLACT
a,用来存储答案,
b,用来存储当前字符出现的频率;
多个字符可出现多次
#include<iostream>#include<stdio.h> #include<string.h> #include<stdlib.h> using namespace std;char str[1000];int main(){int N;cin>>N;while(N--){int n,i,j,b[26];int a[26];cin>>n;cin>>str;int len=strlen(str);memset(a,0,sizeof(a));for(i=0;i<len;i++){a[str[i]-'A']++;}for(int k=1;k<n;k++){cin>>str;len=strlen(str);memset(b,0,sizeof(b));for(i=0;i<len;i++){b[str[i]-'A']++;}for(i=0;i<26;i++)a[i]=min(a[i],b[i]);//这里更新答案}for(i=0;i<26;i++)while(a[i]--)printf("%c",i+'A');cout<<endl;}}
- zoj 3603 Draw Something Cheat
- ZOJ 3603 Draw Something Cheat
- ZOJ 3603 Draw Something Cheat
- ZOJ 3603 Draw Something Cheat
- ZOJ 3603 Draw Something Cheat
- ZOJ 3603 Draw Something Cheat
- ZOJ 3603 Draw Something Cheat
- ZOJ 3603 Draw Something Cheat
- ZOJ 3603 Draw Something Cheat
- zoj 3603 Draw Something Cheat
- zoj 3603 Draw Something Cheat(模拟)
- ZOJ Problem Set - 3603||Draw Something Cheat
- ZOJ 3603Draw Something Cheat(模拟)
- ZOJ 3603 Draw Something Cheat (模拟)
- ZOJ 3603 Draw Something Cheat【模拟】
- ZOJ-3603-Draw Something Cheat【字符串】【9th浙江省赛】
- ZOJ 3603 Draw Something Cheat (字符串,小陷阱)
- ZOJ3603-Draw Something Cheat
- Climbing Stairs
- ORACLE函数 非著名函数之单值函数
- SQL优化【基础03】 - 从执行计划中看出问题所在及对应解决办法
- 基于GTK创建ARDrone 2.0控制线程
- java 匿名内部类(Anonymous Class)
- ZOJ 3603 Draw Something Cheat
- QT DOM方式写入xml文件
- 黑马程序员--iOS默认状态栏文字颜色更改
- 博客为什么要有题目呢?
- 面向对象编程实例——句柄类的使用
- character 7 depts_wo_emps.sql
- QT DOM方式读取xml文件(QDomElement)
- HDU1715 大菲波数 【C版本】
- 矩阵乘法+快速幂+序列递推公式