D - Draw Something Cheat(水)
来源:互联网 发布:sai软件多大 编辑:程序博客网 时间:2024/06/05 02:01
Description
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
题意:n行,找公共字母,按照字母表输出
#include<iostream>#include<cstring>using namespace std;int main(){ int t; cin>>t; while(t--) { int h[30],p[30]; memset(h,0,sizeof(h)); int n; string s; cin>>n; cin>>s; int len=s.size(); for(int i=0; i<len; i++) h[s[i]-'A']++; for(int i=1; i<n; i++) { memset(p,0,sizeof(p)); cin>>s; for(int j=0; j<len; j++) { p[s[j]-'A']++; } for(int j=0;j<27;j++) { h[j]=p[j]<h[j]?p[j]:h[j]; } } for(int i=0;i<27;i++) { if(h[i]>0) { while(h[i]--) cout<<char(i+'A'); } } cout<<endl; } return 0;}
- D - Draw Something Cheat(水)
- zoj 3603 Draw Something Cheat(模拟)
- ZOJ3603-Draw Something Cheat
- 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 3603 Draw Something Cheat (字符串,小陷阱)
- The 9th Zhejiang Provincial Collegiate Programming Contest->Problem D:D - Draw Something Cheat
- The 9th Zhejiang Provincial Collegiate Programming Contest->Problem D:D - Draw Something Cheat
- ZOJ Problem Set - 3603||Draw Something Cheat
- hdu-3436-Queue-jumpers-伸展树
- 玩转html5(一)-----盘点html5新增的那些酷酷的input类型和属性
- 黑马程序员10--File类
- Spring mvc redirect传递参数时异常RedirectAttributes
- Vmware中的Windows主机与主机Windows进行文件共享
- D - Draw Something Cheat(水)
- Json数据的序列化与反序列化的三种常用方法介绍
- 中断服务程序设计实验
- android 布局之滑动探究 scrollTo 和 scrollBy 方法使用说明
- 二叉树之二叉链表
- K - Yet Another Story of Rock-paper-scissors
- 黑马程序员11--集合
- C++风格的四种类型转换
- 1012.畅通工程