이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
mt19937 rng;
int INF = 1LL<<30;
int n,m,k;
int match(string &s1, string &s2) {
int ct=0;
for (int i=0; i<m; i++) {
ct+=s1[i]!=s2[i];
}
return ct;
}
signed main() {
/*#ifndef ONLINE_JUDGE
// for getting input from input.txt
freopen("input.txt", "r", stdin);
// for writing output to output.txt
freopen("output.txt", "w", stdout);
#endif*/
rng.discard(time(NULL)%1000);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m >> k;
vector<string> ar(n);
vector<int> order(n);
vector<int> visited(n,0);
for (int i=0; i<n; i++) {
int r = (rng()+rng()+rng())%n;
while (visited[r]) {
r = rng()%n;
r+=rng();
r%=n;
}
assert(r>=0 && r<n && !visited[r]);
visited[r] = 1;
order[i] = r;
//assert(order[i]<n);
//cout << i <<" " <<r << endl;
}
for (int i=0; i<n; i++) {
string s; cin >> s; ar[i] = s;
}
for (int i=0; i<n; i++) {
int gg = 1;
for (int j=0; j<n; j++) {
if (order[i]==order[j]) continue;
//assert(ar[order[j]].size()==m);
if (match(ar[order[i]],ar[order[j]])!=k) {
gg=0;
break;
}
}
if (gg) {
cout << order[i]+1 << endl;
break;
}
}
}
# | 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... |