# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1093513 | Thanhs | Genetics (BOI18_genetics) | C++14 | 2061 ms | 82768 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;
#define fi first
#define se second
// #define int long long
#define endl '\n'
#define setmin(x, y) x = ((x) < (y) ? (x) : (y))
#define setmax(x, y) x = ((x) > (y) ? (x) : (y))
mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);}
const int NM = 4100 + 5;
vector<int> pos, perm;
int n, m, k, a[NM][NM], c[NM][4], id[NM];
void solve()
{
cin >> n >> m >> k;
perm.resize(n + 1);
iota(perm.begin(), perm.end(), 0);
shuffle(perm.begin() + 1, perm.end(), hdp);
for (int i = 1; i <= n; i++)
id[perm[i]] = i;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
{
char t;
cin >> t;
a[perm[i]][j] = (t == 'A' ? 0 : t == 'C' ? 1 : t == 'G' ? 2 : 3);
c[j][a[perm[i]][j]]++;
}
for (int i = 1; i <= n; i++)
{
int sum = 0;
for (int j = 1; j <= m; j++)
sum += n - c[j][a[i][j]];
if (sum == (n - 1) * k)
pos.push_back(i);
}
shuffle(pos.begin(), pos.end(), hdp);
while (!pos.empty())
{
int t = pos.back();
pos.pop_back();
bool b = 1;
for (int i = 1; i <= n; i++)
{
if (i == t)
continue;
int cnt = 0;
for (int j = 1; j <= m; j++)
{
if (a[i][j] != a[t][j])
cnt++;
}
if (cnt != k)
{
b = 0;
break;
}
}
if (b)
{
cout << id[t];
return;
}
}
}
signed main()
{
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
if (fopen("in.txt", "r"))
{
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
}
// freopen("storagebox.inp", "r", stdin);
// freopen("storagebox.out", "w", stdout);
int tc = 1;
// cin >> tc;
while (tc--)
solve();
}
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... |