QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#625075 | #7618. Pattern Search | JustinWu# | WA | 1ms | 3904kb | C++14 | 739b | 2024-10-09 17:21:22 | 2024-10-09 17:21:22 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int T,a[400],b[400];
char s[2000005];
int check;
int main(){
scanf("%d",&T);
while(T--){
scanf("%s",s+1);
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
check=0;
for(int i=1;i<=strlen(s+1);i++){
a[s[i]]++;
}
scanf("%s",s+1);
for(int i=1;i<=strlen(s+1);i++){
b[s[i]]++;
}
for(int i='a';i<='z';i++){
if(b[i])check++;
}
if(check!=1)
for(int i='a';i<='z';i++){
a[i]-=b[i]/2;
b[i]=b[i]/2+b[i]%2;
}
else {
for(int i='a';i<='z';i++){
if(b[i]){
a[i]-=b[i]-1;
b[i]=1;
}
}
}
int mi=1e9;
for(int i='a';i<='z';i++){
if(b[i])mi=min(mi,a[i]/b[i]);
}
printf("%d\n",max(0,mi));
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3836kb
input:
2 bajkaaall aal abca cba
output:
2 1
result:
ok 2 number(s): "2 1"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3904kb
input:
16 a a a b b a aa a ab aa ab b ab c aaz az abcde edcba aaaaaaaaaaaabbb aaaaaaaaabb aaaaaazz az aaaaaaaaaz zzzzz gggggggggggggggggggge ggggeeee hyphyphyphyphyphyphyphyphyphyphyphyp eeeeeeeeee hyphyphyphyphyphyphyphyphyphyphyphype eeteeteeteet aaaabbbbbbcccccccc aaabbbbbcccccc
output:
1 0 0 2 0 1 0 1 1 1 2 0 0 0 0 1
result:
wrong answer 10th numbers differ - expected: '2', found: '1'