蒟蒻求助
#include<bits/stdc++.h>
using namespace std;
vector<string>a,b;
string t;
int n,m;
string f(string x){
int t[50] = {0};
string ret="";
for(int i = 0;i<x.size();i++)t[x[i]-'a']++;
for(int i = 'z';i>='a';i--)
for(int j = 0;j<t[i-'a'];j++)ret = (char)i+ret;
return ret;
}
int main(){
cin>>n>>m;
for(int i = 0;i<n;i++){
cin>>t;
a.push_back(t);
}
for(int i =0 ;i<n;i++){
b = a;
t = f(a[i]);
b[i] = t;
sort(b.begin(),b.end());
if(b[0]==t)cout<<1;
else cout<<0;
}
}
望各位大佬指点