问题 K: Dubious Document

时间限制: 1 Sec  内存限制: 128 MB
提交: 34  解决: 28
[提交][状态][讨论版][命题人:admin]

题目描述

Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string.
He will receive a headline which contains one of the strings S1,…,Sn tomorrow. He is excited and already thinking of what string he will create. Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains.
Find the longest string that can be created regardless of which string among S1,…,Sn the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.

Constraints
1≤n≤50
1≤|Si|≤50 for every i=1,…,n.
Si consists of lowercase English letters (a - z) for every i=1,…,n.

输入

Input is given from Standard Input in the following format:
n
S1

Sn

输出

Print the lexicographically smallest string among the longest strings that satisfy the condition. If the answer is an empty string, print an empty line.

样例输入

3
cbaa
daacc
acacac

样例输出

aac

提示

The strings that can be created from each of cbaa, daacc and acacac, are aa, aac, aca, caa and so forth. Among them, aac, aca and caa are the longest, and the lexicographically smallest of these three is aac.

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;int main()
{int n;char str[55];cin>>n;cin>>str;int len = strlen(str);int ans[50]={0};for(int i=0;i<len;i++){ans[str[i]-'a']++;}for(int i=0;i<n-1;i++){cin>>str;len = strlen(str);int temp[55]={0};for(int j=0;j<len;j++){temp[str[j]-'a']++;}for(int i=0;i<26;i++){ans[i] = min(ans[i],temp[i]);}}for(int i=0;i<26;i++){while(ans[i]){printf("%c",i+'a');ans[i]--;}}
}

转载于:https://www.cnblogs.com/hao-tian/p/9152544.html

Dubious Document相关推荐

  1. 平常水题 - Atcoder 058 - C - 怪文書 / Dubious Document(字符串的处理)

    C - 怪文書 / Dubious Document                                                       Time limit : 2sec / ...

  2. 怪文書 / Dubious Document

    原题地址 借助大佬的分析: 题意 :用n个字符串S1-Sn .每个字符串都由小写的a-z中的字母组成.找出每个字符串共有的字符并挑选最少的.如:样例: S1 :cbaa S2 :daacc S3 :a ...

  3. 【ATcode】怪文書 / Dubious Document(题意)

    题目链接 题目大意:给你N个字符串,就是问你这些字符串中的每个字母出现的次数,比如说就是有一个是accc那么就是由一个a个三个c,还有一个是cc,那么答案就是cc 思路:其实上面的例子就是答案了吧,就 ...

  4. AtCoder Regular Contest 071 C - 怪文書 / Dubious Document

    给定一堆字符串,寻找一个字典序最小的字符串,使得该字符串是每个字符串的某个一排列的子串. 感觉这么描述比较诡异,换句话来说就是把每个字符串都切成一堆字符,然后找一个字符串使得切开的字符在每一堆中个数分 ...

  5. 字符串处理 —— 模拟与暴力

    [概述] 在某些题目中,需要对字符串进行处理,不需要很复杂的算法,只需要按照题意进行模拟或暴力枚举即可得出答案. [例题] 1.简单模拟 Minimum Ternary String(CF-1009B ...

  6. AtCoder 杂题训练

    前言: 因为要普及了,今年没一等就可以退役去学文化课了,所以暑假把历年noip普及组都刷了一遍,离noip还有50+天,想弄点强化训练什么的. 想了想,就这些天学文化课之余有空就把AtCoder之前那 ...

  7. AtCoder Regular Contest 071

    C - 怪文書 / Dubious Document 题意:定义一种无序的子序列:在原串中随意地取字符并随意打乱顺序.求多个字符串的最长公共无序子序列. #include<cstdio> ...

  8. Technology Document Guide of TensorRT

    Technology Document Guide of TensorRT Abstract 本示例支持指南概述了GitHub和产品包中包含的所有受支持的TensorRT 7.2.1示例.Tensor ...

  9. js动态创建元素之一--document.write

    以我曾经写过的例子举例 如上图,乡镇街道的名字和数目是根据数据库的数据获取的,有几个乡镇,就会显示出来几个,这就要求动态获取乡镇名称和数目,以下代码中用到了document.write创建动态页面,在 ...

最新文章

  1. PDAL点云处理库介绍
  2. 计算机视觉专家:如何从C++转Python
  3. dede 会员中心编辑添加和修改图集的时候自定义的字段模型显示不出来的问题...
  4. Centos6.8 Mysql 设置自动备份与定期删除备份文件 自测部署安装
  5. vite打包编译后类名混淆冲突问题处理
  6. 为PHP7安装Windows Server 2012 R2过程记录
  7. 小米12系列旗舰最新爆料:内藏5000mAh电池但机身更薄
  8. 小蛮机器人如何联网_机器人视界|数字化时代 机器人成为新晋“代言人”
  9. Elasticsearch--入门-_get查询数据 乐观锁字段---全文检索引擎ElasticSearch工作笔记006
  10. 波卡生态DeFi项目Stone将于3月31日在DODO平台创建DVM流动性池并开启交易
  11. bzoj 3398: [Usaco2009 Feb]Bullcow 牡牛和牝牛(DP)
  12. RS485接口保护电路
  13. python-web自动化测试-对话框的处理
  14. rmats2sashimiplot:可视化rmats的可变剪切结果
  15. 简单电路实践——电路与二进制运算
  16. 【可视化开发】数据大屏可视化技术汇总
  17. mysql使用union顺序混乱
  18. python tensorflow学习笔记(五)矩阵乘法运算
  19. python解常微分方程龙格库_数值常微分方程-欧拉法与龙格-库塔法
  20. 【深度学习】第二章:全连接神经网络

热门文章

  1. 微信小程序引用vant toast 提示 “未找到 van-toast 节点“
  2. (下)开发一款微信小程序的个性简历,能打开大厂之门并获得门票?(附源码)
  3. 周易六十四卦——泽天夬卦
  4. 汇总:所有你该知道的AR/VR/3D技术与发展
  5. 查看软件版本的cmd命令
  6. [字符串题-java实现]LeetCode551. 学生出勤记录 I
  7. H5游戏开发(Egret引擎)及Typescript学习笔记
  8. 帆软复选框根据数据库值显示勾选效果
  9. 链接无线路由器后局域网无法连接服务器,局域网部分电脑连接路由器(交换机)后无法上网该怎么解决?...
  10. MATLAB之Nyquist图和Bode图