QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#461979#5037. 回文grass8cow#Compile Error//C++171.1kb2024-07-03 11:33:532024-07-03 11:33:53

Judging History

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

  • [2024-07-03 11:33:53]
  • 评测
  • [2024-07-03 11:33:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,q;
char c[201000],b[401000],a[400100];
int kmp[401000];
int bru(int m){
    for(int i=1;i<=m;i++)a[m-i+1]=a[i+m]=b[i];
    for(int i=2,j=0;i<=m*2;i++){
        while(j&&a[j+1]!=a[i])j=kmp[j];
        if(a[j+1]==a[i])j++;kmp[i]=j;
    }
    int u=m*2,s=0;while(u)s+=(u<=m),u=kmp[u];
    return s;
}
int OP[200100];
int L[200100],R[200100],X[200100],ans[200100];
char E[201000];
int main(){
    scanf("%s",c+1);n=strlen(c+1);
    scanf("%d",&q);
    for(int i=1;i<=q;i++){
        scanf("%d",&OP[i]);
        if(OP[i]==1){char o[2];scanf("%d%s",&X[i],o),E[i]=o[0];}
        else scanf("%d%d",&L[i],&R[i]);
    }
    bool gg=0;
    for(int i=1;i<=q;i++)if(OP[i]==2){
        gg=1;
        for(int j=i-1;j;j--){ans[j]=L[i]^1;if(OP[j]==2)break;}
    }
    if(!gg)return 0;
    for(int i=1;i<=q;i++){
        if(!ans[i]&&OP[i]==2){
            for(int i=1;i<=n;i++)b[i]=c[i];
            printf("%d\n",brute(n));
            return 0;
        }
        if(OP[i]==1){c[X[i]^ans[i]]=E[i];}
        else printf("%d\n",ans[i]);
    }
    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:35:27: error: ‘brute’ was not declared in this scope; did you mean ‘bru’?
   35 |             printf("%d\n",brute(n));
      |                           ^~~~~
      |                           bru
answer.code:19:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |     scanf("%s",c+1);n=strlen(c+1);
      |     ~~~~~^~~~~~~~~~
answer.code:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
answer.code:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |         scanf("%d",&OP[i]);
      |         ~~~~~^~~~~~~~~~~~~
answer.code:23:37: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |         if(OP[i]==1){char o[2];scanf("%d%s",&X[i],o),E[i]=o[0];}
      |                                ~~~~~^~~~~~~~~~~~~~~~
answer.code:24:19: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |         else scanf("%d%d",&L[i],&R[i]);
      |              ~~~~~^~~~~~~~~~~~~~~~~~~~