QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#629167 | #7618. Pattern Search | rotcar07 | WA | 0ms | 3812kb | C++20 | 753b | 2024-10-11 07:47:49 | 2024-10-11 07:47:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main(){
std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int T;cin>>T;
while(T--){
string s,t;cin>>s>>t;
int cs[26]={},ct[26]={};
for(auto x:s) cs[x-'a']++;
for(auto x:t) ct[x-'a']++;
int mn=1e9,ans=0;
for(int w:ct)if(w) mn=min(mn,w);bool ff=0;
for(int i=0;i<26;i++)if(cs[i]<ct[i]) ff=1;
if(ff){puts("0");continue;}
for(int i=0;i<=mn;i++){
int res=1e9;
for(int j=0;j<26;j++)if(ct[j]){
int p=(ct[j]+i)/(i+1);
res=min(res,(cs[j]-ct[j])/p);
}
ans=max(ans,res);
}
cout<<ans+1<<' ';cout<<'\n';
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
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: 3812kb
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 2 1 1 1 2 2 1 0 0 0 0 0 0 0 0
result:
wrong answer 2nd numbers differ - expected: '0', found: '2'