QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#426231 | #7618. Pattern Search | real_sigma_team# | WA | 1ms | 3636kb | C++23 | 1.1kb | 2024-05-30 23:31:55 | 2024-05-30 23:31:56 |
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';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
2 bajkaaall aal abca cba
output:
2 1
result:
ok 2 number(s): "2 1"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3580kb
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 2 2 0 0 0 0 0 1
result:
wrong answer 16th numbers differ - expected: '1', found: '0'