QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#225639 | #7618. Pattern Search | KIK313# | WA | 27ms | 5884kb | C++17 | 1.3kb | 2023-10-24 21:48:56 | 2023-10-24 21:48:57 |
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=1;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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5840kb
input:
2 bajkaaall aal abca cba
output:
2 1
result:
ok 2 number(s): "2 1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 5840kb
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: 27ms
memory: 5884kb
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'