n=1 的情况已经判了,但是还是会 WA 1 个点。求 hack。(已删 freopen)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
#define il inline
#define ret return
#define ll long long
#define deb(x) cerr<<#x<<"="<<x<<" on line "<<__LINE__<<endl;
const int N=3000;
int n,m,cnt[N+10][30],a[N+10],b[N+10];
string s[N+10];
il int get(char c){
ret c-'a';
}
bool check(int x){
for(int i=1;i<=n;i++){
if(x==i){
continue;
}
if(a[x]>b[i]){
ret 0;
}
if(a[x]==b[i]&&a[x]>a[i]){
ret 0;
}
if(a[x]==b[i]&&a[x]==a[i]&&cnt[i][a[i]]<cnt[x][a[i]]){
ret 0;
}
}
ret 1;
}
int main(void){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>s[i];
for(int j=0;j<m;j++){
cnt[i][get(s[i][j])]++;
}
}
for(int i=1;i<=n;i++){
for(int j=0;j<26;j++){
if(cnt[i][j]){
a[i]=j;
break;
}
}
for(int j=25;j>=0;j--){
if(cnt[i][j]){
b[i]=j;
break;
}
}
}
for(int i=1;i<=n;i++){
if(check(i)){
cout<<"1";
}else{
cout<<"0";
}
}
cout<<endl;
return 0;
}