C - 怪文書 / Dubious Document

题意:定义一种无序的子序列:在原串中随意地取字符并随意打乱顺序。求多个字符串的最长公共无序子序列。

#include<cstdio>
#include<algorithm>
using namespace std;
 
int n,m,s[26],q[26];
char c[100];
int main(){
    scanf("%d",&n);
    for (int i=0;i<26;i++) s[i]=51;
    while (n--){
        scanf("%s",c);
        for (int i=0;i<26;i++) q[i]=0;
        for (int i=0;c[i];i++) q[c[i]-'a']++;
        for (int i=0;i<26;i++) s[i]=min(s[i],q[i]);
    }
    for (int i=0;i<26;i++)
    while (s[i]--) putchar('a'+i);
}
View Code

相关文章:

  • 2021-05-19
  • 2022-01-02
  • 2021-12-03
  • 2021-10-16
  • 2021-06-17
  • 2021-06-11
  • 2021-10-01
  • 2021-07-31
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2022-02-07
  • 2021-09-17
  • 2022-02-07
  • 2021-06-24
相关资源
相似解决方案