QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#392871 | #7618. Pattern Search | i_am_noob# | WA | 0ms | 3616kb | C++14 | 972b | 2024-04-17 21:35:28 | 2024-04-17 21:35:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define pb push_back
#define all(a) a.begin(),a.end()
#define sz(a) ((int)a.size())
const int C=26;
int a[C],b[C];
void ahcorz(){
memset(a,0,sizeof a);
memset(b,0,sizeof b);
{
string s,t; cin >> s >> t;
for(auto c: s) a[c-'a']++;
for(auto c: t) b[c-'a']++;
}
int mn=1e9;
for(int i=0; i<C; ++i) if(b[i]) mn=min(mn,a[i]/b[i]);
int res=mn;
int n=accumulate(b,b+C,0);
for(int k=1; k<=n; ++k){
mn=1e9;
for(int i=0; i<C; ++i) if(b[i]){
int x=(b[i]+k)/(k+1);
if(b[i]-x*k<0){
mn=0;
break;
}
mn=min(mn,a[i]/x);
}
res=max(res,mn);
}
cout << res << "\n";
}
signed main(){
ios_base::sync_with_stdio(0),cin.tie(0);
int t=1; cin >> t;
while(t--) ahcorz();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 3572kb
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 1 1 0 1 1 3 2 1 1 0 0 3
result:
wrong answer 5th numbers differ - expected: '0', found: '1'