点我看题目

题意 : 给你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. appium +python api 新手

    发现一个网址的内容比较好,就转过来了   #默认系统语言对应的Strings.xml文件内的数据. get_app_string() #查找某一个语言环境对应的字符串文件Strings.xml内数据 ...

  2. java和html的区别

    Java 不是一门程序语言,它是一个平台,也可以说是一门技术. Java 包括 1.Java 程式语言 一个类似 C++ 或 Smalltalk 的物件导向程式语言.学习 Java 程式语言类似学人类 ...

  3. 第五章 jQuery中的动画

    通过jQuery中的动画方法,能轻松地为网页添加精彩的视觉效果,给用户一种全新体验. 1.show()方法和hide()方法 该方法的功能与css()方法设置display属性效果相同. 给show( ...

  4. 20160502-struts2入门--国际化

    一.国际化 准备资源文件,资源文件的命名格式如下: baseName_language_country.properties baseName_language.properties baseName ...

  5. c/c++中const使用总结(金典)

    原文地址:http://www.cnblogs.com/yc_sunniwell/archive/2010/07/14/1777416.html 个人总结:          (1)const只对它左 ...

  6. ###《Effective STL》--Chapter1

    点击查看Evernote原文. #@author: gr #@date: 2014-09-12 #@email: forgerui@gmail.com Chapter1 容器 Topic 4: 调用e ...

  7. 第十篇、HTML5实战篇——1

    <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <!--支持IE ...

  8. sea.js说明文档

    Sea.js 手册与文档 首页 | 索引 目录 模块定义 define id dependencies factory exports require require.async require.re ...

  9. CenOS6.4 系统升级内核

    获取要升级的内核版本的包 #wget -c https://www.kernel.org/pub/linux/kernel/v3.x/内核版本 若得到的内核的压缩格式为tar.xz,则需要两步解压 # ...

  10. jquery 在页面中按回车 响应 事件

    为了用户方便我们往往会在用户回车之后做一些事,比如登陆的时候,填完表单过后,我们习惯性的会直接按回车,当然要处理这个,jquery是很简单的,我们来看看怎么做吧. $(document).ready( ...