# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
593901 | AlesL0 | Genetics (BOI18_genetics) | C++17 | 751 ms | 2388 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.
#pragma GCC optimize("03")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int comp(string a, string b){
int r = 0;
for (int i = 0; i < a.size(); i++)if (a[i] != b[i])r++;
return r;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, k; cin >> n >> m >> k;
if (n <= 100 && m <= 100){
string x[n];
for (int i = 0; i < n; i++)cin >> x[i];
for (int i = 0; i < n; i++){
bool flag10 = 1;
for (int j = 0; j < n; j++){
if (i == j)continue;
if (comp(x[i], x[j]) != k){
flag10 = 0;
break;
}
}
if (flag10){
cout << i+1;
break;
}
}
}
else {
bitset <4100> b[n];
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
char c; cin >> c;
if (c == 'A')b[i].set(j);
}
}
for (int i = 0; i < n; i++){
bool flag10 = 1;
int x = min(1000, n);
for (int j = 0; j < x; j++){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
if (flag10){
x = max(0, n-999);
for (int j = n-1; j >= x; j--){
if (i == j)continue;
if ((b[i]^b[j]).count() != k){
flag10 = 0;
break;
}
}
}
if (flag10){
cout << i+1;
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... |