QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#603338#8521. Pattern Search IIwyhaoML 0ms0kbC++14628b2024-10-01 16:00:092024-10-01 16:00:10

Judging History

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

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

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<=10000;k++){
        if(str[M][k]!=ch[1]) continue;
        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;
}

详细

Test #1:

score: 0
Memory Limit Exceeded

input:

aabbaab

output:


result: