QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#603352#8521. Pattern Search IIwyhaoML 0ms0kbC++14619b2024-10-01 16:06:322024-10-01 16:06:34

Judging History

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

  • [2024-10-01 16:06:34]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:0kb
  • [2024-10-01 16:06:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=150005,M=50;
string sa,sb,sc;
int f[N];
int n;
char ch[N];
int main(){
    sa="b";sb="a";
    for(int i=1;i<=M;i++){
        sc=sb+sa;
        sa=sb;sb=sc;
    }
    scanf("%s",ch+1);
    n=strlen(ch+1);
    int ans=0x3f3f3f3f;
    for(int k=0;k<=20000;k++){
        if(sc[k]!=ch[1]) continue;
        int s=1;
        for(int i=k,j=1;i<sc.length();i++,s++){
            if(sc[i]==ch[j]){
                j++;
            }
            if(j==n+1) break;
        }
        ans = min(ans,s);
    }
    printf("%d",ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Memory Limit Exceeded

input:

aabbaab

output:


result: