点我看题目

题意 : 给你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. SpriteFrameCache 精灵帧缓存

    //获取精灵帧缓存的单例对象 auto  spriteFrameCache = SpriteFrameCache::getInstance(); //从plist文件添加多个精灵帧 spriteFra ...

  2. JAXB - The JAXB Context

    As we have seen, an object of the class JAXBContext must be constructed as a starting point for othe ...

  3. Java - 使用 XSD 校验 XML

    package com.huey.dream.utils; import java.io.IOException; import java.io.InputStream; import javax.x ...

  4. h2database源码浅析:集群

    Clustering / High Availability This database supports a simple clustering / high availability mechan ...

  5. GIT学习(二)

    学习地址: http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 常用git命令: 1. ...

  6. C#中调用存储过程

    [csharp] view plain copy print? string strsql = "Data Source=192.168.24.53;Initial Catalog=JF_C ...

  7. WCF与Web API 区别(应用场景)

    Web api  主要功能: 支持基于Http verb (GET, POST, PUT, DELETE)的CRUD (create, retrieve, update, delete)操作 请求的回 ...

  8. ###《Video Event Detection by Inferring Temporal Instance Lables》

    论文作者:Kuan-Ting Lai, Felix X. Yu, Ming-Syan Chen and Shih-Fu Chang. #@author: gr #@date: 2014-01-25 # ...

  9. 02_线程的创建和启动_继承Thread方式

    [简述] java使用Thread类代表线程,所有的线程都必须是Thread或者其子类的实例. 每个线程的任务就是完成一定的任务,实际上就是执行一段程序流. [创建并启动多线程的步骤(集成Thread ...

  10. Python快速入门学习笔记(二)

    注:本学习笔记参考了廖雪峰老师的Python学习教程,教程地址为:http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb49318210 ...