QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#603329#8521. Pattern Search IIwyhaoML 0ms0kbC++14587b2024-10-01 15:58:242024-10-01 15:58:25

Judging History

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

  • [2024-10-01 15:58:25]
  • 评测
  • 测评结果:ML
  • 用时:0ms
  • 内存:0kb
  • [2024-10-01 15:58:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=150005,M=60;
string str[M+5];
int n;
char ch[N];
int main(){
    str[0]="b";
    str[1]="a";
    for(int i=2;i<=M;i++){
        str[i]=str[i-1]+str[i-2];
    }
    scanf("%s",ch+1);
    n=strlen(ch+1);
    int ans=0x3f3f3f3f;
    for(int k=0;k<=5000;k++){
        int s=1;
        for(int i=k,j=1;i<str[M].length();i++,s++){
            if(str[M][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: