# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
945204 | LucaIlie | Genetics (BOI18_genetics) | C++17 | 448 ms | 52200 KiB |
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;
const int MAX_N = 4100;
const int MAX_M = 4100;
string s[MAX_N];
long long frecv[MAX_N][128], w[MAX_N];
int main() {
int n, m, k;
long long sum = 0;
cin >> n >> m >> k;
for ( int i = 0; i < n; i++ ) {
cin >> s[i];
w[i] = rand() % INT_MAX;
for ( int j = 0; j < m; j++ )
frecv[j][s[i][j]] += w[i];
sum += w[i];
}
for ( int i = 0; i < n; i++ ) {
long long d = 0;
for ( int j = 0; j < m; j++ )
d += sum - frecv[j][s[i][j]];
if ( d == (sum - w[i]) * k ) {
bool ok = true;
for ( int j = 0; j < n && ok; j++ ) {
if ( i == j )
continue;
int d = 0;
for ( int p = 0; p < m; p++ )
d += (s[i][p] != s[j][p]);
if ( d != k )
ok = false;
}
if ( ok ) {
cout << i + 1 << "\n";
return 0;
}
}
}
return 0;
}
Compilation message (stderr)
# | 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... |