QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#392871#7618. Pattern Searchi_am_noob#WA 0ms3616kbC++14972b2024-04-17 21:35:282024-04-17 21:35:29

Judging History

你现在查看的是最新测评结果

  • [2024-04-17 21:35:29]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2024-04-17 21:35:28]
  • 提交

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'