QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#683287 | #8334. Gene | goblin_team# | WA | 1ms | 5832kb | C++14 | 1.7kb | 2024-10-27 19:53:09 | 2024-10-27 19:53:11 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
#define M 60010
#define N 310
typedef unsigned long long ull;
string a[N];
ull h1[N][10000],h2[N][10000];
const ull mod=1e9+7;
#define INF 1e9
int S;
int compute(int x,int y,int k,int m,int S){
// cout<<endl<<a[x]<<" "<<a[y]<<endl;
vector<int>dif;
for(int i=0,last=0;last<m;++i,last+=S){
if(h1[x][i]!=h1[y][i])dif.push_back(i);
}
int n=(int)dif.size();
if(n>k)return INF;
int ans=0;
for(int i=0;i<n;++i){
for(int j=S*dif[i];j<min(m,S*(dif[i]+1));++j){
if(a[x][j]!=a[y][j])++ans;
}
}
// cout<<ans<<endl;
if(ans>k)return INF;
return ans;
}
int main(){
cout<<2*(int)sqrt(6000000)<<endl;
int n,q,m,k;
cin>>n>>q>>m>>k;
S=2*(int)sqrt(10*m);
for(int i=0;i<n;++i){
cin>>a[i];
for(int last=0,nexte=S-1,j=0;last<m;last=nexte+1,nexte+=S,++j){
ull t=0;
for(int k=last;k<=min(nexte,m-1);++k){
t=(t*131+a[i][k]-'a'+1)%mod;
}
h1[i][j]=t;
// cout<<t<<" ";
}
// cout<<endl;
}
for(int iii=0;iii<q;++iii){
cin>>a[n];
// cout<<a[n]<<endl;
for(int last=0,nexte=S-1,j=0;last<m;last=nexte+1,nexte+=S,++j){
ull t=0;
for(int k=last;k<=min(nexte,m-1);++k){
t=(t*131+a[n][k]-'a'+1)%mod;
}
h1[n][j]=t;
}
int ans=0;
for(int i=0;i<n;++i){
if(compute(i,n,k,m,S)<=k)++ans;
}
cout<<ans<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5832kb
input:
6 4 4 1 kaki kika manu nana tepu tero kaka mana teri anan
output:
4898 2 2 1 0
result:
wrong answer 1st numbers differ - expected: '2', found: '4898'