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 ll long long
const int MX = 4105;
int N, M, K, wt[MX]; ll sum[MX][4];
string s[MX];
int index(char c){
if(c == 'A') return 0;
else if(c == 'C') return 1;
else if(c == 'G') return 2;
else return 3;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> N >> M >> K;
for(int i = 0; i < N; i++) cin >> s[i];
random_device rd;
mt19937 rng(rd());
uniform_int_distribution<> distrib(1, 1 << 31);
ll tot_wt = 0;
for(int i = 0; i < N; i++){
wt[i] = distrib(rng);
tot_wt += wt[i];
}
for(int i = 0; i < N; i++){
for(int j = 0; j < M; j++) sum[j][index(s[i][j])] += wt[i];
}
for(int i = 0; i < N; i++){
ll total = 0;
for(int j = 0; j < M; j++){
for(int k = 0; k < 4; k++){
if(index(s[i][j]) == k) continue;
total += sum[j][k];
}
}
ll hash = 1ll * K * tot_wt - 1ll * K * wt[i];
if(total == hash){
cout << i + 1 << '\n';
return 0;
}
}
}
# | 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... |