# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1093523 | Thanhs | Genetics (BOI18_genetics) | C++14 | 372 ms | 148308 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;
int n, m, k, a[NM][NM], c[NM][5], v[NM];
void solve()
{
cin >> n >> m >> k;
for (int i = 1; i <= n; i++)
v[i] = rand(1, 1e12);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
{
char t;
cin >> t;
a[i][j] = (t == 'A' ? 0 : t == 'C' ? 1 : t == 'G' ? 2 : 3);
c[j][a[i][j]] += v[i];
c[j][4] += v[i];
}
int tar = accumulate(v + 1, v + 1 + n, 0ll) * k;
for (int i = 1; i <= n; i++)
{
int sum = 0;
for (int j = 1; j <= m; j++)
sum += c[j][4] - c[j][a[i][j]];
if (sum == tar - v[i] * k)
{
cout << i;
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... |