# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
757961 | LeSonnn | Genetics (BOI18_genetics) | C++17 | 346 ms | 36396 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>
#define task "TXKCK"
using namespace std;
//typedef long long int64_t;
const int64_t oo = (1ll << 61) - 1;
int n, m, k;
void add(int64_t &a, int64_t b)
{
a += b;
if (a >= oo)
{
a -= oo;
}
}
void progress()
{
//cout << oo << " ";
cin >> n >> m >> k;
vector<std::string> S(n);
for (auto &e : S)
{
cin >> e;
}
vector<int64_t> H(n);
mt19937 mt(100);
uniform_int_distribution<int64_t> dist(0, oo - 1);
for (auto &e : H)
{
e = dist(mt);
}
vector<std::array<int64_t, 4>> hl(m, {0, 0, 0, 0});
auto get_id = [&](char x)
{
if (x == 'A')
return 0;
if (x == 'C')
return 1;
if (x == 'G')
return 2;
return 3;
};
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
add(hl[j][get_id(S[i][j])], H[i]);
}
}
for (int i = 0; i < n; ++i)
{
int64_t sum(0);
for (int j = 0; j < m; ++j)
{
const int v = get_id(S[i][j]);
for (int x = 0; x < 4; ++x)
{
if (x == v)
{
continue;
}
add(sum, hl[j][x]);
}
}
int64_t expr(0);
for (int j = 0; j < n; ++j)
{
if (i == j)
{
continue;
}
add(expr, H[j]);
}
expr = (int64_t)(__int128_t(expr) * __int128_t(k) % __int128_t(oo));
if (expr == sum)
{
cout << i + 1 << '\n';
break;
}
}
}
// main
int main()
{
// Written by Shyn_
ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);
if (fopen(task ".inp", "r"))
{
freopen(task ".inp", "r", stdin);
freopen(task ".out", "w", stdout);
}
int64_t nt = 1;
// cin >> nt;
for (; nt--;)
{
progress();
}
}
/** LeSonnn_ **/
/** LCG **/
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... |