#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, k; cin>>n>>m>>k;
string s[n + 1];
for (int i = 1; i <= n; i++){
cin>>s[i];
}
auto f = [&](int i, int j){
int cnt = 0;
for (int x = 0; x < m; x++){
cnt += (s[i][x] != s[j][x]);
}
return (cnt == k);
};
mt19937 rng((int) time(0));
vector<int> p(n + 1);
for (int i = 1; i <= n; i++) p[i] = i;
shuffle(p.begin() + 1, p.end(), rng);
int d[m][26];
for (int i = 0; i < m; i++){
for (int j = 0; j < 26; j++){
d[i][j] = 0;
}
}
for (int i = 1; i <= n; i++){
for (int j = 0; j < m; j++){
d[j][s[i][j] - 'A']++;
}
}
const int S = m + (n - 1) * (m - k);
bool bad[n + 1];
for (int i = 1; i <= n; i++){
int cnt = 0;
for (int j = 0; j < m; j++){
cnt += d[j][s[i][j] - 'A'];
}
bad[i] = 0;
if (cnt != S){
bad[i] = 1;
}
}
for (int i = 1; i <= n; i++){
for (int j = i + 1; j <= n; j++){
if (bad[p[i]] && bad[p[j]]) continue;
if (!f(p[i], p[j])){
bad[p[i]] = bad[p[j]] = 1;
}
}
}
for (int i = 1; i <= n; i++){
if (!bad[i]){
cout<<i<<"\n";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |