QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#426228#7618. Pattern Searchreal_sigma_team#WA 0ms3620kbC++231.1kb2024-05-30 23:27:252024-05-30 23:27:28

Judging History

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

  • [2024-05-30 23:27:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-05-30 23:27:25]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int tests;
    cin >> tests;
    while (tests--) {
        string t, s;
        cin >> t >> s;
        vector<int> cs(26), ct(26);
        for (auto i: t) ct[i - 'a']++;
        for (auto i: s) cs[i - 'a']++;
        bool fl = true;
        for (int i = 0; i < 26; ++i)
            if (ct[i] < cs[i]) {
                cout << 0 << '\n';
                fl = false;
            }
        if (!fl)
            continue;
        int n = (int)s.size(), ans = 0;
        for (int l = 1; l <= n; ++l) {
            int mn = 1e9;
            for (int i = 0; i < 26; ++i) {
                if (cs[i] == 0)
                    continue;
                int cnt = (cs[i] + l - 1) / l;
                if (cnt * (l - 1) > cs[i])
                    mn = -1e9;
                else
                    mn = min(mn, ct[i] - cs[i] / cnt);
            }
            ans = max(ans, 1 + mn);
        }
        cout << ans << '\n';
    }
}

详细

Test #1:

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

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

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
3
2
0
0
0
0
0
4

result:

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