解题思路:找到公共子串然后升序输出

坑的地方就在于输入是存在相同字母的

 #include <stdio.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define MIN( x, y ) ( (x) < (y) ? (x) : (y) )
#define INF 0x7fffffff
#define KIND 26
#define MAXN 12
using namespace std; char str[MAXN];
int hash[KIND], ans[KIND]; int main(){
int cas, n, i, j;
scanf("%d", &cas);
while ( cas-- ){
scanf("%d", &n);
for( i = ; i < KIND; ++i )
ans[i] = INF;
for( i = ; i < n; ++i ){
scanf("%s", str);
memset( hash, , sizeof( hash ) );
for( j = ; j < MAXN; ++j )
hash[str[j]-'A']++;
for( j = ; j < KIND; ++j )
ans[j] = MIN( ans[j], hash[j] );
}
for( i = ; i < KIND; ++i )
while(ans[i]--)
printf("%c", i + 'A');
printf("\n");
}
return ;
}

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.

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

ZOJ 3603字符串操作的更多相关文章

  1. D - D ZOJ - 1151 (字符串操作)

    For each list of words, output a line with each word reversed without changing the order of the word ...

  2. python学习笔记(字符串操作、字典操作、三级菜单实例)

    字符串操作 name = "alex" print(name.capitalize()) #首字母大写 name = "my name is alex" pri ...

  3. shell编程常用的截取字符串操作

    1.          常用的字符串操作 1.1.           替换字符串:$ echo ${var/ /_}#支持正怎表达式 / /表示搜索到第一个替换,// /表示搜索到的结果全部替换. ...

  4. php字符串操作集锦

    web操作, 主要就是对字符文本信息进行处理, 所以, 字符串操作几乎占了很大一部分的php操作.包括 注意strstr 和 strtr的区别? 前者表示字符串查找返回字符串,后者表示字符串中字符替换 ...

  5. java 字符串操作和日期操作

    一.字符串操作 创建字符串 String s2 = new String("Hello World"); String s1 = "Hello World"; ...

  6. [No000078]Python3 字符串操作

    #!/usr/bin/env python3 # -*- coding: utf-8 -*- '''Python 字符串操作 string替换.删除.截取.复制.连接.比较.查找.包含.大小写转换.分 ...

  7. Python 字符串操作及string模块使用

    python的字符串操作通过2部分的方法函数基本上就可以解决所有的字符串操作需求: python的字符串属性函数 python的string模块 1.字符串属性方法操作: 1.>字符串格式输出对 ...

  8. C语言字符串操作总结大全

    1)字符串操作 strcpy(p, p1)  复制字符串  函数原型strncpy(p, p1, n)   复制指定长度字符串  函数原型strcat(p, p1)   附加字符串  函数原型strn ...

  9. c# 字符串操作

    一.字符串操作 //字符串转数组 string mystring="this is a string" char[] mychars=mystring.ToCharArray(); ...

随机推荐

  1. [置顶] js综合应用:表格的四则运算

    在做调查问卷的过程中,遇到一个表格的统计问题,算是需要些js方面的综合知识,所以记录下来. 在上次完成了基本的求和的基础上,添加了基本的加减乘除四则运算. 基本需求简化后如下: 对应的htm了为: & ...

  2. <input type="text">文本输人框

    type类型: text  文本框 password  口令密码输人框 reset  重置或清除 buttou  命令按钮 checkbox  复选框 radio  单选框 submit  提交 fi ...

  3. linux下移动或者复制文件覆盖相同文件夹时,文件夹里面的每个文件都提示是否覆盖

    链接地址:http://blog.chinaunix.net/uid-23683795-id-2391087.html # vi ~/.bashrc   如果你看到如下内容,以下命令都会用别名执行了, ...

  4. 杭电ACM 2052 Picture

    Picture Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  5. BZOJ 1823: [JSOI2010]满汉全席( 2-sat )

    2-sat...假如一个评委喜好的2样中..其中一样没做, 那另一样就一定要做, 这样去建图..然后跑tarjan. 时间复杂度O((n+m)*K) ------------------------- ...

  6. c++ 容器、继承层次、句柄类

    一.容器与继承 在容器中保存有继承关系的对象,如果定义成保存基类对象,则派生类将被切割,如果定义成保存派生类对象,则保存基类对象又成问题(基类对象将被强制转换成派生类对象,而派生类中定义的成员未被初始 ...

  7. php随笔5-thinkphp OA系统 人力资源管理

    最近闲来无事,自己尝试通过thinkphp3.1.3框架开发一套自己的OA系统,目前已完成了人力资源管理部分的内容,遇到并解决了几个问题. 1.由于刚开始不太熟悉thinkphp的框架,花费了一些功夫 ...

  8. Nginx 开启 debug 日志的办法

    译序:一般来讲,Nginx 的错误日志级别是 error,作为 Nginx 用户来讲,你设置成 info 就足够用了.         但有时有些难以挖掘的 bug,需要看到更详细的 debug 级别 ...

  9. unity3d大型手游 可以打包obb文件

    用unity3d开发手游,有个很大的问题就是apk的size太大, 如果超过50M,一般很多平台就不会肯上线. 一个好的方法是把app打成apk + obb数据包的方式. 1. 编译成obb数据包的方 ...

  10. 【JavaScript】强制缓存刷新

    1.在js引用时加入时间戳. <script> document.write('<script src="xxx.js?_dc='+new Date().getTime() ...