# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
871955 | ThMinh_ | Genetics (BOI18_genetics) | C++14 | 52 ms | 15708 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;
const int N = 1e5 + 10;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//mt19937 rng(192374385783);
int n, m, k;
int p[N], tr[26][N];
bool vis[N], res[N];
string s[N];
int rnd(int f, int l) {
return f + rng() % (l - f + 1);
}
int main () {
cin.tie(0)->sync_with_stdio(0);
if(fopen("Task.inp", "r")) {
freopen("Task.inp", "r", stdin);
freopen("WA.out", "w", stdout);
}
cin>>n>>m>>k;
for(int i = 1; i <= n; ++i) cin>>s[i];
for(int i = 1; i <= n; ++i) {
p[i] = i;
res[i] = 1;
}
shuffle(p + 1, p + n + 1, rng);
for(int timer = 1; timer <= 10; ++timer) {
int t = rnd(n / 2, n);
// cout<<t<<" ";
for(int i = 1; i <= n; ++i) vis[i] = 0;
for(int j = 1; j <= m; ++j) for(int o = 0; o <= 25; ++o) {
tr[o][j] = 0;
}
for(int i = 1; i <= n; ++i) vis[p[i]] = (i <= t);
// for(int i = 1; i <= n; ++i) cout<<vis[i]<<" "; cout<<"\n";
for(int i = 1; i <= t; ++i) for(int j = 1; j <= m; ++j) {
int c = s[p[i]][j - 1] - 'A';
tr[c][j]++;
}
for(int i = 1; i <= n; ++i) {
int ans = 0;
for(int j = 1; j <= m; ++j) {
int c = s[i][j - 1] - 'A';
ans += tr[c][j] - vis[i];
}
// cout<<ans<<"\n";
res[i] &= (ans == (t - vis[i]) * (m - k));
}
// cout<<"\n\n";
}
for(int i = 1; i <= n; ++i) if(res[i]) cout<<i;
}
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... |