[ACM_模拟] ACM - Draw Something Cheat [n个长12的大写字母串,找出交集,按字母序输出]
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
2
2
ABCDEFGHIJKL
ABCDEFGHIJKL
2
SAWBCVUXDTPN
ZQTLFJYRCGAK
Sample Output
ABCDEFGHIJKL
ACT 题目大意:第一个T表示有T组,每组一个n表示接下来n个长为12的string,求这些string的交集并安字典序输出。
解题思路:用num_ABC[26]表示交集,用temp_num[26]表示每个string的情况,这里26表示26个大写字母,数组的值表示含该字母的数量
#include<iostream>
#include<string.h>
#include<cstring>
#include<string>
using namespace std;
int main(){
int T;cin>>T;
while(T--){
int num_ABC[];//交集
int temp_num[];//每个string的情况
string str;int n;
cin>>n;
for(int i=;i<;i++)num_ABC[i]=;//初始化很大的
while(n--){//n个string过来
cin>>str;
memset(temp_num,,sizeof(temp_num));
for(int i=;i<;i++){
temp_num[str[i]-'A']++;
}//统计
for(int i=;i<;i++)if(num_ABC[i]>temp_num[i]){
num_ABC[i]=temp_num[i];
}//更新交集
}
for(int i=;i<;i++){//输出
while(num_ABC[i]--){
cout<<(char)(i+'A');
}
}cout<<'\n';
}return ;
}
[ACM_模拟] ACM - Draw Something Cheat [n个长12的大写字母串,找出交集,按字母序输出]的更多相关文章
- zjuoj 3603 Draw Something Cheat
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3603 Draw Something Cheat Time Limit: 2 ...
- The 9th Zhejiang Provincial Collegiate Programming Contest->Problem D:D - Draw Something Cheat
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3603 题意:在给出的字符串中找出每行都出现的字母按字典序排序. #incl ...
- [ACM_模拟] POJ1068 Parencodings (两种括号编码转化 规律 模拟)
Description Let S = s1 s2...s2n be a well-formed string of parentheses. S can be encoded in two diff ...
- ACM_查找ACM(加强版)
查找ACM(加强版) Time Limit: 2000/1000ms (Java/Others) Problem Description: 作为一个acmer,应该具备团队合作能力和分析问题能力.给你 ...
- [ZOJ 3063] Draw Something Cheat
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4706 思路:字符串是一个集合(由0到多个A~Z字符组成),我们可以假 ...
- Linux下使用USB模拟ACM串口设备
这个想法之前就在脑袋里有过,最近公司产品要用到,所以多做了些了解. 1. USB 简介 USB 是 Universal Serial Bus 的缩写,从字面上看,就是通用串行总线的意思.从物理上看,其 ...
- [ACM_模拟][ACM_数学] LA 2995 Image Is Everything [由6个视图计算立方体最大体积]
Description Your new company is building a robot that can hold small lightweight objects. The robo ...
- [ACM_模拟] UVA 10881 Piotr's Ants[蚂蚁移动 数组映射 排序技巧]
"One thing is for certain: there is no stopping them;the ants will soon be here. And I, for one ...
- [ACM_模拟][ACM_暴力] Lazier Salesgirl [暴力 懒销售睡觉]
Description Kochiya Sanae is a lazy girl who makes and sells bread. She is an expert at bread making ...
随机推荐
- dubbo 使用总结
第一步: 安装注册中心Register,这里选择 zookeeper 1.zookeeper下载url:http://zookeeper.apache.org; 2.下载解压完后如下: 3.将zoo_ ...
- 关于ES、PES、PS/TS 码流
一.基本概念 )ES ES--Elementary Streams (原始流)是直接从编码器出来的数据流,可以是编码过的视频数据流(H.264,MJPEG等),音频数据流(AAC),或其他编码 ...
- mysqldb模块的简单用法
# - *- coding:utf-8-*-import urllib2import reimport MySQLdbimport sysreload(sys)sys.setdefaultencodi ...
- Android Studio鼠标悬停显示注释
Android Studio鼠标悬停显示注释 在AS中配置 如果你想从网上查看注释,到这一步就操作完成. 下面说明让软件使用本地注释: 使用本地注释 以Windows为例: 找到下面文件 C:\Use ...
- iOS出现<object returned empty description>的解决方法
iOS出现<object returned empty description>的解决方法: 使用 [str length] <= 0 判断处理
- Android 环境通过国内映像快速搭建
Android 环境通过国内映像快速搭建 转眼大半年没有写android程序了,回顾从环境搭建开始. 因为google受国内限制,因此下载android的SDK相当慢,因此寻找国内的镜像进行搭建. 首 ...
- WCF三种通信模式
WCF在通信过程中有三种模式:请求与答复.单向.双工通信. 请求与答复模式 描述:客户端发送请求,然后一直等待服务端的响应(异步调用除外),期间处于假死状态,直到服务端有了答复后才能继续执行其他程序 ...
- 【实(dou)力(bi)首(mai)发(meng)】第四次CCF软件能力认证题解
这次的题总体上相对前三次偏简单.由于实力有限,就分析前四题. 试题编号: 201503-1 试题名称: 图像旋转 时间限制: 5.0s 内存限制: 256.0MB 问题 ...
- apache.http.client.HttpClient
前言 HTTP 协议可能是现在 Internet 上使用得最多.最重要的协议了,越来越多的 Java 应用程序需要直接通过 HTTP 协议来访问网络资源.虽然在 JDK 的 java net包中已经提 ...
- Oracle列操作(增加列,修改列,删除列)
Oracle列操作 增加一列: alter table emp4 add test varchar2(10); 修改一列: alter table emp4 modify test varchar2( ...