QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#733306 | #8334. Gene | NiCue | Compile Error | / | / | C++14 | 1.8kb | 2024-11-10 18:12:55 | 2024-11-10 18:12:55 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int P = 13331;
typedef pair<int,int> PII;
typedef unsigned long long ull;
int n,q,m,k,ans;
string s[310];
ull h[310][60010],h2[60010],p[60010];
void init(){
p[0]=1;
for(int i=1;i<=n;i++){
h[i][1]=0;
for(int j=1;j<=m;j++){
h[i][j]=h[i][j-1]*P+s[i][j];
}
p[i]=p[i-1]*P;
}
}
void init2(string& t){
h2[0]=0;
for(int i=1;i<=m;i++){
h2[i]=h2[i-1]*P+t[i];
}
}
ull get1(int i,int l,int r){
return h[i][r]-h[i][l-1]*p[r-l+1];
}
ull get2(int l,int r){
return h2[r]-h2[l-1]*p[r-l+1];
}
bool check(int i,int l,int r){
return get1(i,l,r)==get2(l,r);
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin>>n>>q>>m>>k;
for(int i=1;i<=n;i++){
cin>>s[i];
s[i]=" "+s[i];
}
//预处理哈希
init();
//处理询问
while(q--){
ans=0;
string t;
cin>>t;
t=" "+t;
//对每一个t进行哈希
init2(t);
//对哈希进行二分
int cnt;
for(int i=1;i<=n;i++){
cnt=0;
int l=0,r=m+1;
while(true){
while(l+1!=r){
int mid=(l+r)>>1;
if(check(i,l+1,mid)) l=mid;
else r=mid;
}
if(r>=1&&r<=m){
l=r;
r=m+1;
cnt++;
}else if(r==m+1){
break;
}
if(cnt>k){
break;
}
}
if(cnt<=k){
ans++;
}
}
cout<<ans<
Details
answer.code: In function ‘int main()’: answer.code:79:19: error: expected primary-expression at end of input 79 | cout<<ans< | ^ answer.code:79:19: error: expected ‘}’ at end of input answer.code:46:15: note: to match this ‘{’ 46 | while(q--){ | ^ answer.code:79:19: error: expected ‘}’ at end of input 79 | cout<<ans< | ^ answer.code:35:1: note: to match this ‘{’ 35 | { | ^