QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#603311 | #8521. Pattern Search II | wyhao | WA | 0ms | 4140kb | C++14 | 582b | 2024-10-01 15:53:29 | 2024-10-01 15:53:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=150005;
string str[25];
int n;
char ch[N];
int main(){
str[0]="b";
str[1]="a";
for(int i=2;i<=20;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<=10;k++){
int s=1;
for(int i=k,j=1;i<str[20].length();i++,s++){
if(str[20][i]==ch[j]){
j++;
}
if(j==n+1) break;
}
ans = min(ans,s);
}
printf("%d",ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3832kb
input:
aabbaab
output:
8
result:
ok 1 number(s): "8"
Test #2:
score: 0
Accepted
time: 0ms
memory: 4092kb
input:
a
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
b
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
aa
output:
2
result:
ok 1 number(s): "2"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
bb
output:
3
result:
ok 1 number(s): "3"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
ab
output:
2
result:
ok 1 number(s): "2"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
ba
output:
2
result:
ok 1 number(s): "2"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
bbba
output:
7
result:
ok 1 number(s): "7"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
abbbbbbbab
output:
20
result:
ok 1 number(s): "20"
Test #10:
score: -100
Wrong Answer
time: 0ms
memory: 4140kb
input:
abbbbabbbabbbabbabaabbabb
output:
44
result:
wrong answer 1st numbers differ - expected: '43', found: '44'