# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1097370 | vjudge1 | Genetics (BOI18_genetics) | C++14 | 235 ms | 33636 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;
int n,m,k;
const int mod=1e9+7,base=331;
ll const_string[5000],Sum,pos[70][5000],Hash[5000];
string xau[5000];
void Solve()
{
for(int i=1;i<=n;i++)
{
ll tong=0;
for(int j=1;j<=m;j++)
{
tong+=pos[xau[i][j]-'A'][j]-const_string[i];
}
if(tong==(Sum-const_string[i])*(m-k))
{
cout<<i;
return;
}
}
}
void Input()
{
cin>>n>>m>>k;
Sum=0;
for(int i=1;i<=n;i++)
{
cin>>xau[i];
xau[i]=" "+xau[i];
Hash[0]=0;
for(int j=1;j<=m;j++)
{
Hash[j]=(Hash[j-1]*base%mod+xau[i][j]-'A')%mod;
}
const_string[i]=Hash[m];
Sum+=const_string[i];
for(int j=1;j<=m;j++)
{
pos[xau[i][j]-'A'][j]+=const_string[i];
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
if(fopen("a.inp","r"))
{
freopen("a.inp","r",stdin);
freopen("a.out","w",stdout);
}
Input();
Solve();
}
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... |