QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#276019 | #7618. Pattern Search | ddl_VS_pigeon# | WA | 27ms | 3544kb | C++20 | 866b | 2023-12-05 14:46:09 | 2023-12-05 14:46:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int INF = 0x3fffffff;
array<int,26> readString(){
array<int,26> ans;
ans.fill(0);
string s;
cin >> s;
for(char c:s){
ans[c-'a']++;
}
return ans;
}
void solve(){
auto s = readString();
auto t = readString();
int lt = INF;
for(int i=0;i<26;i++){
if(t[i]>0){
lt = min(lt,t[i]);
}
}
array<int,26> lc;
for(int i=0;i<26;i++){
lc[i] = (t[i]+lt)/(lt+1);
}
int ans = INF;
for(int i=0;i<26;i++){
s[i] -= t[i];
if(s[i]<0){
cout << "0" << '\n';
return;
}
if(lc[i]>0){
s[i] /= lc[i];
ans = min(ans,s[i]+1);
}
}
cout << ans << '\n';
}
int main(void) {
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int T;
cin >> T;
while(T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3424kb
input:
2 bajkaaall aal abca cba
output:
2 1
result:
ok 2 number(s): "2 1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3508kb
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: 3544kb
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'