QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#607548 | #7618. Pattern Search | Yeyin_0 | WA | 0ms | 3604kb | C++14 | 1.1kb | 2024-10-03 15:16:27 | 2024-10-03 15:16:28 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<=(b);i++)
#define LL long long
string s,t;
LL chars[210],chart[210];
void solve()
{
LL Ans=0;
cin>>s>>t;
fo(i,0,26) chars[i]=chart[i]=0;
fo(i,0,s.size()-1){ chars[s[i]-'a']++; }
fo(i,0,t.size()-1){ chart[t[i]-'a']++; }
fo(i,0,25)
{
chars[i]-=chart[i];
if(chars[i]<0)
{
cout<<0<<endl;
return;
}
}
fo(i,1,s.size()-1)
{
bool bb=1;
fo(k,0,25)
{
if(chart[k]/i<chart[k]%i)
{
bb=0;
}
}
if(bb)
{
LL ans=1e9;
fo(k,0,25)
{
LL req=chart[k]/i;
if(req) ans=min(ans,chars[k]/req);
}
Ans=max(Ans,ans);
}
}
LL ans=1e9;
fo(k,0,25)
{
LL req=(chart[k]+1)/2;
if(req) ans=min(ans,chars[k]/req);
}
Ans=max(Ans,ans);
cout<<Ans+1<<endl;
}
int main()
{
int tcase;
cin>>tcase;
while(tcase--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
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: 3604kb
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 1 2 0 0 0 0 1
result:
wrong answer 10th numbers differ - expected: '2', found: '1'