0x00 Link
-
Source
-AtCoder
-
Tag
-芝士水题
-
Time
- ∗ * ∗
0x01 Source Code
//
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const int N = 11;
string s[N];
int idx[N];
void solve() {
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> s[i];
idx[i] = i;
}
do {
bool f = 1;
for (int i = 2; i <= n; i++) {
int cnt = 0;
for (int j = 0; j < m; j++) {
cnt += (s[idx[i - 1]][j] != s[idx[i]][j]); // idx[]
}
if (cnt > 1) {
f = 0;
break;
}
}
if (f) {
cout << "Yes" << endl;
return ;
}
}while (next_permutation(idx + 1, idx + n + 1));
cout << "No" << endl;
}
signed main() {
IOS
int t = 1;
// cin >> t;
while (t--) solve();
return 0;
}
0x10 Diagram
-
404
0x11 Reference
-
404
作者 | 乐意奥AI