QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#426228 | #7618. Pattern Search | real_sigma_team# | WA | 0ms | 3620kb | C++23 | 1.1kb | 2024-05-30 23:27:25 | 2024-05-30 23:27:28 |
Judging History
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'