QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#603352 | #8521. Pattern Search II | wyhao | ML | 0ms | 0kb | C++14 | 619b | 2024-10-01 16:06:32 | 2024-10-01 16:06:34 |
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