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 int long long
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int GetRand(int l,int r){
return (rng()%(r-l+1))+l;
}
signed main(){
int n,m,k;
cin >> n >> m >> k;
char grid[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin >> grid[i][j];
}
}
int val[n];
int pre[m][4];
int sum=0;
memset(pre,0,sizeof(pre));
for(int i=0;i<n;i++){
val[i]=GetRand(1,1e12);
sum+=val[i];
}
for(int j=0;j<m;j++){
for(int i=0;i<n;i++){
if(grid[i][j]=='A'){
pre[j][0]+=val[i];
}
else if(grid[i][j]=='C'){
pre[j][1]+=val[i];
}
else if(grid[i][j]=='G'){
pre[j][2]+=val[i];
}
else{
pre[j][3]+=val[i];
}
}
}
for(int i=0;i<n;i++){
int curr=0;
for(int j=0;j<m;j++){
curr+=sum;
if(grid[i][j]=='A'){
curr-=pre[j][0];
}
else if(grid[i][j]=='C'){
curr-=pre[j][1];
}
else if(grid[i][j]=='G'){
curr-=pre[j][2];
}
else{
curr-=pre[j][3];
}
}
if(curr==(sum-val[i])*k){
cout << i+1;
break;
}
}
}
# | 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... |