QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#287833 | #7618. Pattern Search | UFRJ | WA | 52ms | 3644kb | C++20 | 1.2kb | 2023-12-21 01:51:51 | 2023-12-21 01:51:51 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using lint = int64_t;
int main(){
cin.tie(nullptr)->sync_with_stdio(false);
int t_;
cin>>t_;
while(t_--){
string s, t;
cin>>s>>t;
vector<int>fs(26), ft(26);
int n = (int)s.size(), m = (int)t.size();
for(char ch : s) fs[ch - 'a']++;
for(char ch : t) ft[ch - 'a']++;
bool w = true;
for(int j=0;j<26;j++){
if(fs[j] < ft[j]) w = false;
}
if(!w){
cout<<"0\n";
continue;
}
int ans = 0;
for(int k=1;k<=m;k++){
vector<int>ct(26), rt(26);
bool ok = true;
for(int j=0;j<26;j++){
ct[j] = (ft[j] + k - 1) / k;
rt[j] = ft[j] - ct[j] * (k - 1);
if( rt[j] < 0) ok = false;
}
if(!ok) break;
int cnt = n;
bool one_more = true;
for(int j=0;j<26;j++){
if(!ct[j]) continue;
int c = (fs[j] - ft[j]) / ct[j] + 1;
cnt = min(cnt, c);
}
ans = max(ans, cnt);
}
cout<<ans<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3644kb
input:
2 bajkaaall aal abca cba
output:
2 1
result:
ok 2 number(s): "2 1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3560kb
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: 52ms
memory: 3576kb
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 1 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 77th numbers differ - expected: '2', found: '1'