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;
#define fori(i, l, r) for(int i = (int) (l); i <= (int) (r); i++)
#define ford(i, r, l) for(int i = (int) (r); i >= (int) (l); i--)
#define ii pair<int, int>
#define fi first
#define se second
#define vi vector<int>
#define eb emplace_back
#define sp ' '
#define endl '\n'
#define int long long
mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());
const int maxn = 4105, mod = 1e9 + 9;
int n, m, k;
string s[maxn];
int pw[maxn];
int Hash[maxn][4];
int sum[maxn];
int cv(int c) {
return c == 'A'? 0: c == 'C'? 1: c == 'G'? 2: 3;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m >> k;
pw[0] = 1;
fori(i, 1, maxn - 1) pw[i] = pw[i - 1] * (k + 1) % mod;
fori(i, 1, n ) {
cin >> s[i];
}
fori(i, 0, m - 1) {
fori(j, 1, n) {
(Hash[i][cv(s[j][i])] += pw[j]) %= mod;
}
fori(j, 1, n) {
fori(c, 0, 3) {
if(c != cv(s[j][i])) (sum[j] += Hash[i][c]) %= mod;
}
}
}
int des = 0; fori(i, 1, n) (des += k * pw[i]) %= mod;
fori(i, 1, n) {
if((sum[i] + k * pw[i]) % mod == des) {
cout << i << endl;
}
}
}
# | 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... |