博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[ACM_模拟] ACM - Draw Something Cheat [n个长12的大写字母串,找出交集,按字母序输出]...
阅读量:6449 次
发布时间:2019-06-23

本文共 3232 字,大约阅读时间需要 10 分钟。

 

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.

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

22ABCDEFGHIJKLABCDEFGHIJKL2SAWBCVUXDTPNZQTLFJYRCGAK

Sample Output

ABCDEFGHIJKLACT 题目大意:第一个T表示有T组,每组一个n表示接下来n个长为12的string,求这些string的交集并安字典序输出。 解题思路:用num_ABC[26]表示交集,用temp_num[26]表示每个string的情况,这里26表示26个大写字母,数组的值表示含该字母的数量
1 #include
2 #include
3 #include
4 #include
5 using namespace std; 6 int main(){ 7 int T;cin>>T; 8 while(T--){ 9 int num_ABC[26];//交集10 int temp_num[26];//每个string的情况11 string str;int n;12 cin>>n;13 for(int i=0;i<26;i++)num_ABC[i]=299999;//初始化很大的14 while(n--){
//n个string过来15 cin>>str;16 memset(temp_num,0,sizeof(temp_num));17 for(int i=0;i<12;i++){18 temp_num[str[i]-'A']++;19 }//统计20 for(int i=0;i<26;i++)if(num_ABC[i]>temp_num[i]){21 num_ABC[i]=temp_num[i];22 }//更新交集23 }24 for(int i=0;i<26;i++){
//输出25 while(num_ABC[i]--){26 cout<<(char)(i+'A');27 }28 }cout<<'\n';29 }return 0;30 }
http://www.cnblogs.com/zjutlitao/p/3603444.html
你可能感兴趣的文章
Linux查看程序端口占用情况
查看>>
jar包冲突案例分析.md
查看>>
控制圈复杂度的9种重构技术总结
查看>>
当软件项目全部能靠自己搞定了,也能接几万元的软件项目时,未必适合创业...
查看>>
数据分析--数字找朋友
查看>>
推荐好用的开源库或软件
查看>>
18年selenium3+python3+unittest自动化测试教程(下)
查看>>
Redis集群中删除/修改节点(master、slave)(实验)
查看>>
memcache数据库和redis数据库的区别(理论)
查看>>
我的友情链接
查看>>
MyBatis+Spring结合
查看>>
shell实例-判断apache是否正常启动
查看>>
SharedPreferences存储复杂对象解决方案
查看>>
Office 365之SkyDrive Pro
查看>>
脑残式网络编程入门(二):我们在读写Socket时,究竟在读写什么?
查看>>
无缝滚动实现原理分析【公告栏】
查看>>
Java Web 高性能开发
查看>>
redis-cli 命令总结
查看>>
CentOS 4.4双网卡绑定,实现负载均衡
查看>>
GitHub页面使用方法
查看>>