# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
62712 | eriksuenderhauf | Genetics (BOI18_genetics) | C++11 | 1396 ms | 111496 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 enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%I64d", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%I64d\n", (n))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 5e3 + 5;
const double eps = 1e-9;
using namespace std;
char str[MAXN][MAXN];
bitset<MAXN> a[MAXN][4];
int cnt[MAXN][4];
int vis[MAXN][MAXN];
int go(char c)
{
if (c == 'A') return 0;
else if (c == 'C') return 1;
else if (c == 'G') return 2;
else if (c == 'T') return 3;
}
int main()
{
int n, m, k;
ni(n), ni(m), ni(k);
for (int i = 0; i < n; i++)
{
scanf("%s", str[i]);
for (int j = 0; j < m; j++)
{
int cur = go(str[i][j]);
a[i][cur][j] = 1;
cnt[j][cur]++;
vis[i][j] = -1;
}
for (int j = m; j < n; j++)
vis[i][j] = -1;
}
for (int i = n - 1; i >= 0; i--)
{
int tmp = 0;
for (int j = 0; j < m; j++)
tmp += n - cnt[j][go(str[i][j])];
if (tmp != k * (n - 1))
continue;
int fl = 0;
for (int j = n - 1; j >= 0; j--)
{
if (i == j)
continue;
int val = 0;
if (vis[i][j] != -1)
val = vis[i][j];
else
{
for (int b = 0; b < 4; b++)
{
val += (a[i][b] ^ a[j][b]).count();
if (val > 2 * k)
break;
}
vis[i][j] = val;
vis[j][i] = val;
}
if (val != 2 * k)
{
fl = 1;
break;
}
}
if (fl)
continue;
return !pri(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... |