QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#226149#7618. Pattern Searchtselmegkh#WA 0ms3636kbC++171.0kb2023-10-25 16:55:422023-10-25 16:55:42

Judging History

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

  • [2023-10-25 16:55:42]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2023-10-25 16:55:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
    string s, t;
    cin >> s >> t;
    vector<int> fs(26);
    for (char c : s) {
        fs[c - 'a']++;
    }
    vector<int> ft(26);
    for (char c : t) {
        ft[c - 'a']++;
    }
    int mn = 1e9;
    for (int i = 0; i < 26; i++) {
        if (ft[i] > 0) {
            mn = min(mn, ft[i]);
        }
    }
    vector<int> a(26);
    for (int i = 0; i < 26; i++) {
        a[i] = ft[i] / mn;
        ft[i] %= mn;
    }
    int c = 1e9;
    vector<int> b(26);
    for (int i = 0; i < 26; i++) {
        if (a[i] == 0) continue;
        b[i] = fs[i] / a[i];
        c = min(c, b[i]);
    }
    int ans = max(0, c - mn);
    bool ok = c >= mn;
    for (int i = 0; i < 26; i++) {
        if (ft[i] > fs[i] - a[i] * c) {
            ok = 0;
        }
    }
    if (ok) ans++;
    cout << ans << "\n";
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3532kb

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

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
2

result:

wrong answer 10th numbers differ - expected: '2', found: '1'