怪文書 / Dubious Document

Problem Statement

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,...,SnS1,...,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,...,SnS1,...,Sn the headline contains. If there are multiple such strings, find the lexicographically smallest one among them.

Constraints

  • 1≤n≤501≤n≤50
  • 1≤|Si|≤501≤|Si|≤50 for every i=1,...,ni=1,...,n.
  • SiSi consists of lowercase English letters (a - z) for every i=1,...,ni=1,...,n.

Input

Input is given from Standard Input in the following format:

nn
S1S1
......
SnSn

Output

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


Sample Input 1 Copy

Copy

3
cbaa
daacc
acacac

Sample Output 1 Copy

Copy

aac

The strings that can be created from each of cbaadaacc and acacac, are aaaacacacaa and so forth. Among them, aacaca and caa are the longest, and the lexicographically smallest of these three is aac.


Sample Input 2 Copy

Copy

3
a
aa
b

Sample Output 2 Copy

Copy

 

The answer is an empty string.

 题意:
给你n个字符串,

找每个字符串都包含的字符,其个数为在字符串中出现次数最少的,用这些字符重新组成一个字典序最小的字符串。

S1  :cbaa

S2  :daacc

S3  :acacac           

都含有的字符为a,c;

s1中a出现两次,c出现一次;

s2中a出现两次,c出现两次;

s3中a出现三次,c出现3次;

所以用a,a,c;构成一个字典序最小的字符串为aac;     

代码:
      

#include<bits/stdc++.h>
using namespace std;
char s[500000];
int a[100][30];
char s2[500000];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%s",s);
        int len=strlen(s);
        if(i==1)
        {
            for(int j=0;j<len;j++)
            {
                int x=s[j]-'a';
                a[i][x]++;
            }
        }
        if(i>1)
        {
           for(int j=0;j<len;j++)
            {
                int x=s[j]-'a';
                a[i][x]++;
                a[i][x]=min(a[i-1][x],a[i][x]);
            }
        }
    }
    int k=0;
    for(int i=0;i<=25;i++)
    {
        if(a[n][i]>0)
        {
            for(int j=1;j<=a[n][i];j++)
            {
                s2[k++]='a'+i;
            }
        }
    }
    sort(s2,s2+k);
    printf("%s",s2);
}

 

这个错误提示是由于在Git仓库中检测到了不确定的所有权问题导致的。在引用和引用中,这个问题是由于在重置Windows 10后更改了用户名所致。根据这些引用中的建议,你可以通过在Git Bash中运行以下命令来解决该问题: git config --global --add safe.directory G:/Git 这个命令将在Git的全局配置中添加一个安全目录的例外,以解决这个问题。然而,需要注意的是,这个解决方法仅适用于当前的Git仓库,如果你有其他的Git仓库也出现了相同的问题,你需要针对每个仓库都执行相同的操作。此外,运行git config -l命令可能会显示一长串的这些操作,但这不会影响Git的正常运行。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Git异常fatal: detected dubious ownership in repository at](https://blog.csdn.net/weixin_43359484/article/details/130624732)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [git fatal: detected dubious ownership in repository 解决方法](https://blog.csdn.net/tcjy1000/article/details/127129224)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值