QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#749429 | #7618. Pattern Search | shstyle# | WA | 0ms | 5940kb | C++23 | 906b | 2024-11-15 00:43:09 | 2024-11-15 00:43:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=2e6+10;
typedef long long ll;
ll n;
char s1[N],s2[N];
int cnt1[30],cnt2[30];
int cntneed[30];
bool check(int c1[],int c2[]){
for(int i=0;i<26;i++){
if(c1[i]<c2[i]) return false;
c1[i]-=c2[i];
}
return true;
}
void HuangGuangsheng(){
scanf("%s",s1+1);
scanf("%s",s2+1);
int n1=strlen(s1+1),n2=strlen(s2+1);
memset(cnt1,0,sizeof cnt1);
memset(cnt2,0,sizeof cnt2);
memset(cntneed,0,sizeof cntneed);
for(int i=1;i<=n1;i++) cnt1[s1[i]-'a']++;
for(int i=1;i<=n2;i++) cnt2[s2[i]-'a']++;
for(int i=0;i<26;i++) cntneed[i]=(cnt2[i]+1)/2;
int ans=0;
if(check(cnt1,cnt2)) ans++;
else{
puts("0");
return;
}
while(check(cnt1,cntneed)) ans++;
printf("%d\n",ans);
}
int main(){
int hgs;
cin>>hgs;
while(hgs--){
HuangGuangsheng();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3912kb
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: 5940kb
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'