QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#426175#7618. Pattern Searchreal_sigma_team#WA 1ms3772kbC++20997b2024-05-30 21:59:292024-05-30 21:59:29

Judging History

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

  • [2024-05-30 21:59:29]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3772kb
  • [2024-05-30 21:59:29]
  • 提交

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']++;
        int g = 0;
        for (auto i : cs) g = gcd(g, i);
        if (g > 1) {
            int cc = 1e9;
            for (int i = 0; i < 26; ++i) {
                if (cs[i] == 0) continue;
                cc = min(cc, ct[i] / (cs[i] / g));
            }
            cout << max(0, cc - g + 1) << '\n';
        } else {
            int mn = 1e9;
            for (int i = 0; i < 26; ++i) {
                if (cs[i] == 0) continue;
                int bank = max(0, ct[i] - (cs[i] / 2));
                mn = min(mn, bank / (cs[i] - (cs[i] / 2)));
            }
            cout << mn << '\n';
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
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: 3772kb

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'