이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
using str = string;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9+7;
int main() {
cin.tie(0)->sync_with_stdio(0);
int N, M, K; cin >> N >> M >> K;
vector<str> A(N); for(auto& x : A) cin >> x;
vector<int> ans(N); iota(begin(ans), end(ans), 0);
auto rnd = [&]() {
return (rng() * 1LL * rng()) % MOD;
};
for(int t = 0; ; t++) {
set<int> in(begin(ans), end(ans));
int n = size(ans);
// cout << n << endl;
int I = ans[rnd() % n];
// cout << I << endl;
int W = 0;
vector<int> nans;
for(int k = 0; k < N; k++) {
int c = 0;
for(int j = 0; j < M; j++) {
if (A[k][j] != A[I][j]) c++;
}
if (c == K) {
W++;
if (in.count(k)) nans.push_back(k);
}
}
if (W == N-1) {
cout << I+1 << nl;
return 0;
}
ans.swap(nans);
}
assert(false);
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... |