QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#225641 | #7618. Pattern Search | KIK313# | WA | 33ms | 6028kb | C++17 | 1.3kb | 2023-10-24 21:52:39 | 2023-10-24 21:52:39 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int T,t[33],h[33];
char c[2000100],s[2000100];
int main() {
scanf("%d",&T);
while(T--) {
scanf("%s",c+1);
int l=strlen(c+1); int o=l;
for(int i=0;i<=30;i++) t[i]=h[i]=0;
for(int i=1;i<=l;i++) {
t[c[i]-'a']++;
}
scanf("%s",s+1);
l=strlen(s+1);
for(int i=1;i<=l;i++) {
h[s[i]-'a']++;
}
bool flag=1;
for(int i=0;i<26;i++) {
if(h[i]>t[i]) {
flag=0;
break;
}
}
if(!flag) {
printf("0\n");
continue;
}
for(int i=0;i<26;i++) t[i]-=h[i];
int minl=l;
for(int i=0;i<26;i++) {
if(h[i]>0) minl=min(h[i],minl);
}
int res=0;
for(int i=0;i<=minl;i++) {
int ans=o;
for(int j=0;j<26;++j) {
if(h[j]==0) continue;
if(h[j]%(i+1)) {
int r=(h[j]/(i+1))+1;
ans=min(ans,t[j]/r);
} else {
int r=h[j]/(i+1);
ans=min(ans,t[j]/r);
}
}
res=max(res,ans);
}
printf("%d\n",res+1);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 5972kb
input:
2 bajkaaall aal abca cba
output:
2 1
result:
ok 2 number(s): "2 1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 6028kb
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 2 2 0 0 0 0 1
result:
ok 16 numbers
Test #3:
score: -100
Wrong Answer
time: 33ms
memory: 5984kb
input:
90522 cyykzyylklyll ylcyllklzk ttusuuudtdtqus uuddu uefyqfkiblyfkyd ffyyqde qfxqecljeqeedea jqdxf prrbfxdxffpbpp ffppd ynjgygygjnjnjg jgynjggn maenpaksmxyya saxkep nrdnbnjipnjowjz djbwojzrpni oputuoufoojupu uoouopo mphmhphpkpkpmhp phmhpppp zwznzpzqyjczzy wczjnpzqy pfxfxxkfffpfx fxffkffxpx hzdhzhhh h...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 2 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 2 3 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 2 1 1 1 1 4 1 2 1 1 1 1 1 3 1 1 3 1 1 1 1 1 1 1 1 1 1 1 3 1 1 4 1 1 1 1 1 1 1 1 1 1 5 1 7 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 ...
result:
wrong answer 5721st numbers differ - expected: '1', found: '2'