点我看题目

题意 : 给你n个字符串,让你找出在每个字符串中出现的字母,按字典序输出来。

思路 :一开始想差了,以为记录下每个字符出现次数,然后找次数大于1的,可是我忘了可能在一个字符串中有AA,而另一个字符串中一个A都没有的情况。稍微改一下就是出现过的标记一下次数,然后存到另一个数组里,反正就才26个字母,因为有可能出现我说的A的那种情况,但最后就只能输出一个A,所以每次都比较一下,找出字符串里出现次数最少的。

#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <string> #define INF 99999999 using namespace std; char str[];
int hash[], minn[]; int main()
{
int T, n;
scanf("%d", &T);
while (T--)
{
scanf("%d", &n);
for(int i = ; i < ; i++)
minn[i] = INF;
for(int i = ; i < n; i++)
{
scanf("%s", str);
int len = strlen(str) ;
memset( hash, , sizeof(hash));
for(int j = ; j < len; j++ )
hash[str[j]-'A']++;
for(int j = ; j < ; j++)
minn[j] = min(minn[j],hash[j]);
}
for(int i = ; i < ; i++)
for(int j = ; j < minn[i] ; j++)
printf("%c", i + 'A');
printf("\n") ;
}
return ;
}

ZOJ 3603 Draw Something Cheat的更多相关文章

  1. zjuoj 3603 Draw Something Cheat

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3603 Draw Something Cheat Time Limit: 2 ...

  2. [ZOJ 3063] Draw Something Cheat

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4706 思路:字符串是一个集合(由0到多个A~Z字符组成),我们可以假 ...

  3. ZOJ 3603字符串操作

    解题思路:找到公共子串然后升序输出 坑的地方就在于输入是存在相同字母的 #include <stdio.h> #include <algorithm> #include < ...

  4. [ACM_模拟] ACM - Draw Something Cheat [n个长12的大写字母串,找出交集,按字母序输出]

    Description Have you played Draw Something? It's currently one of the hottest social drawing games o ...

  5. ZOJ 3603 DP LCS

    已经5年没有做OJ了, 曾经沧海难为水,除去巫山不是云" 准备每周刷1-2题! 题目大意:给出N个字符串,且各个字符串都包含唯一的字母,即不存在"ABCA"(A重复了), ...

  6. The 9th Zhejiang Provincial Collegiate Programming Contest->Problem D:D - Draw Something Cheat

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3603 题意:在给出的字符串中找出每行都出现的字母按字典序排序. #incl ...

  7. 2012-2014 三年浙江 acm 省赛 题目 分类

    The 9th Zhejiang Provincial Collegiate Programming Contest A    Taxi Fare    25.57% (166/649)     (水 ...

  8. ZOJ 3544 / HDU 4056 Draw a Mess( 并查集好题 )

    方法参见:http://blog.acmol.com/?p=751 从最后一个线段开始倒着处理(因为之后的线段不会被它之前的线段覆盖),把这条线段所覆盖的所有线段编号合并到一个集合里,并以最左边线段编 ...

  9. Help Me Escape (ZOJ 3640)

    J - Help Me Escape Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:32768KB ...

随机推荐

  1. Leetcode 94. Binary Tree Inorder Traversal (中序遍历二叉树)

    Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tr ...

  2. wordpress 提取头像的src

    获取用户头像,可以通过 $avatar_html = get_avatar( $email ); 获取到头像的html /** * Retrieve the avatar url for a user ...

  3. .Net 中表达式的转换

    .Net 中表达式的转换 如: a>0  && (c>a || a <b ) || (a>b || c>1)    转换后  (((a > 0) a ...

  4. django 学习-1

    1.首先是安装django 解压包然后 python setup.py install  安装成功 2.建立一个项目 django-admin.py startproject  study 3. 再到 ...

  5. ASP连接11种数据库的常用语法

    1.Access数据库的DSN-less连接方法: 以下为引用的内容: set adocon=Server.Createobject("adodb.connection") ado ...

  6. iOS中 常用的mac终端指令

    1.使用caffeinate阻止Mac运行屏幕保护和睡眠 caffeinate能阻止Mac进入睡眠状态,而且屏幕保护也不会激活.我们最好使用-t为命令加入具体的时间.比如下面的命令可以使Mac一小时内 ...

  7. html-----020----事件

    html事件 <body> <a href="http://www.cctv.com" accesskey="k" target=" ...

  8. 折腾ghost。。。

    1.启动 NODE_ENV=production node index.js 如果出现启动不了的情况,在该命令加sudo sudo NODE_ENV=production node index.js ...

  9. linux下搭建nginx+php(FastCGI)+mysql运行环境

    一.安装环境 1.CentOS5.5 2.php5.4 3.MySQL5.5.19 二.安装程序依赖库和开发环境 为了省事把所需要的库文件全都安装上,可以使用rpm包安装,也可以用yum命令安装, 1 ...

  10. java 泛型 窜讲

    一.为什么使用泛型      复用性:泛型的本质就是参数化类型,因而使用编写的泛型代码可以被许多不同类型的对象所复用.      安全性:在对类型Object引用的参数操作时,往往需要进行显式的强制类 ...