QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#128271#6567. Repetitive String Inventioninstallb#Compile Error//C++141.0kb2023-07-20 19:58:212023-07-20 19:58:22

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-20 19:58:22]
  • 评测
  • [2023-07-20 19:58:21]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define M 805
char S[M];
int lcp[M][M],n;
using ll = long long;
int pre[M],suf[M];
int main(){
    scanf("%s",S+1);
    n=strlen(S+1);
    for(int i=n;i>=1;i--){
        lcp[i][i] = n-i+1;
        for(int j=1;j<=n;j++){
            if(S[i]==S[j])lcp[i][j] = lcp[i+1][j+1]+1;
            else lcp[i][j] = 0;
        }
    }
    ll ans = 0;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            ans += min(lcp[i][j],j-i);
    for(int l=2;l<=n;l++){
        for(int r=l;r+1<=n;r++){
            int len = r-l+1;
            for(int i=n;i>=1;i--){
                suf[i] = suf[i+1];
                if(lcp[i][l] >= len) suf[i]++;
            }
            for(int i=1;i<=n;i++){
                pre[i] = pre[i-1];
                if(i-len>=0&&lcp[i-len+1][l] >= len)pre[i]++;
            }
            for(int k = 1, ed = min(l-1,n-r);k<=ed;k++){
                ans += suf[r+k+1] + pre[l-k-1];
            }

        }
    }
    cout<<ans<<endl;
    return 0;
}asd

詳細信息

answer.code:41:2: error: ‘asd’ does not name a type
   41 | }asd
      |  ^~~
answer.code: In function ‘int main()’:
answer.code:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |     scanf("%s",S+1);
      |     ~~~~~^~~~~~~~~~