# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
872055 | ThMinh_ | Genetics (BOI18_genetics) | C++14 | 1088 ms | 59104 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
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;
ll w[N], tr[26][N];
bool 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) res[i] = 1;
for(int timer = 1; timer <= 30; ++timer) {
ll sum = 0;
for(int i = 1; i <= n; ++i) {
w[i] = rnd(1, 1e9);
sum += w[i];
}
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) for(int j = 1; j <= m; ++j) {
int c = s[i][j - 1] - 'A';
tr[c][j] += w[i];
}
for(int i = 1; i <= n; ++i) {
ll ans = 0;
for(int j = 1; j <= m; ++j) {
int c = s[i][j - 1] - 'A';
ans += tr[c][j] - w[i];
}
res[i] &= (ans == (sum - w[i]) * (m - k));
}
}
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... |