QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#603329 | #8521. Pattern Search II | wyhao | ML | 0ms | 0kb | C++14 | 587b | 2024-10-01 15:58:24 | 2024-10-01 15:58:25 |
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