QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#287832#7618. Pattern SearchUFRJWA 0ms3564kbC++201.0kb2023-12-21 01:48:582023-12-21 01:48:58

Judging History

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

  • [2023-12-21 01:48:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3564kb
  • [2023-12-21 01:48:58]
  • 提交

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']++;
        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: 3564kb

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: 3564kb

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
2
2
1
1
0
0
1

result:

wrong answer 5th numbers differ - expected: '0', found: '1'