QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#733306#8334. GeneNiCueCompile Error//C++141.8kb2024-11-10 18:12:552024-11-10 18:12:55

Judging History

你现在查看的是最新测评结果

  • [2024-11-10 18:12:55]
  • 评测
  • [2024-11-10 18:12:55]
  • 提交

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<

詳細信息

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 | {
      | ^