#include <bits/stdc++.h>
using namespace std;
bool compare(string a, string b) {
int len = min(a.length(), b.length());
for (int i = 0; i < len; i++) {
if (a[i] != b[i]) {
return a[i] < b[i];
}
}
return a.length() < b.length();
}
int main() {
int n, m;
cin >> n >> m;
vector<string> words(n);
for (int i = 0; i < n; i++) {
cin >> words[i];
}
sort(words.begin(), words.end(), compare);
for (int i = 0; i < n; i++) {
bool satisfiesCondition = true;
for (int j = 0; j < n; j++) {
if (i != j && words[i] == words[j]) {
satisfiesCondition = false;
break;
}
for (int k = 0; k < m; k++) {
if (words[i][k] < words[j][k]) {
satisfiesCondition = false;
break;
}
}
if (!satisfiesCondition) {
break;
}
}
if(n=1){
cout<<"1";
return 0;
}
if (satisfiesCondition) {
cout << "0";
} else {
cout << "1";
}
}
cout << endl;
return 0;
}
此代码过第一个点(也是唯一一个特判过的,也能过样例,但是其他就没办法了,求调)