# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
520172 | Killer2501 | Genetics (BOI18_genetics) | C++14 | 600 ms | 83676 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 ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;
const int N = 4e3+150;
const int M = 21;
const ll inf = 4e9;
const int mod = 1e9+7;
int n, t, m, k, ans, tong, a[N][N], b[N], f[N][4];
pii dp[N];
vector<int> vi;
mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
void add(int &x, int y)
{
x += y;
if(x >= mod)x -= mod;
}
string s;
int get(char c)
{
if(c == 'A')return 0;
else if(c == 'C')return 1;
else if(c == 'G')return 2;
return 3;
}
void sol()
{
cin >> n >> m >> k;
for(int i = 1; i <= n; i ++)b[i] = mt() % mod;
char c;
for(int i = 1; i <= n; i ++)
{
for(int j = 1; j <= m; j ++)
{
cin >> c;
a[i][j] = get(c);
add(f[j][a[i][j]], b[i]);
}
}
for(int i = 1; i <= n; i ++)
{
tong = 0;
for(int j = 1; j <= n; j ++)if(i != j)add(tong, 1ll * b[j] * k % mod);
ans = 0;
for(int j = 1; j <= m; j ++)
{
for(int p = 0; p < 4; p ++)
{
if(p != a[i][j])add(ans, f[j][p]);
}
}
if(ans == tong)
{
cout << i;
return;
}
}
}
int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
#define task "test"
if(fopen(task".inp", "r"))
{
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int ntest = 1;
//cin >> ntest;
while(ntest -- > 0)
sol();
}
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... |