This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define fori(i, l, r) for(int i = (int) (l); i <= (int) (r); i++)
#define ford(i, r, l) for(int i = (int) (r); i >= (int) (l); i--)
#define ii pair<int, int>
#define fi first
#define se second
#define vi vector<int>
#define eb emplace_back
#define sp ' '
#define endl '\n'
mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());
const int maxn = 4105;
int n, m, k;
string s[maxn];
bool ok[maxn];
int comp(string &s, string &t) {
int cnt = 0; fori(i, 0, m - 1) cnt += s[i] != t[i];
return cnt;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> k;
fori(i, 1, n) cin >> s[i];
vector<int> ord(n, 0);
iota(begin(ord), end(ord), 1);
shuffle(begin(ord), end(ord), rng);
fori(idx, 0, min(n - 1, 5) ) {
int i = rng() % n + 1;
fori(j, 1, n) {
if(comp(s[i], s[j]) != k) ok[j] = 0;
}
}
fill(ok, ok + n + 1, 1);
for(int i: ord) {
for(int j: ord) {
if(!ok[i]) break;
if(i == j) continue;
if(comp(s[i], s[j]) != k) {
ok[i] = ok[j] = 0;
}
}
if(ok[i]) {
cout << i;
return 0;
}
}
}
# | 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... |