QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#246524 | #7618. Pattern Search | DateTree | WA | 33ms | 4008kb | C++17 | 1.3kb | 2023-11-10 21:40:39 | 2023-11-10 21:40:40 |
Judging History
answer
#include <bits/stdc++.h>
int main() {
//freopen("in", "r", stdin);
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int ttt;
std::cin >> ttt;
while (ttt--) {
std::string x, y;
std::cin >> x >> y;
std::vector<int> s(26), t(26);
for (auto &c: x)
++s[c - 'a'];
for (auto &c: y)
++t[c - 'a'];
bool flag = 0;
for (int i = 0; i < 26; ++i) {
if (s[i] < t[i]) {
puts("0");
flag = 1;
break;
}
}
if (flag)
continue;
int min = std::min(x.length(), y.length());
int ans = 1;
for (int k = 1; k <= min; ++k) {
bool f = 0;
int tmp = 1e9 + 7;
for (int i = 0; i < 26; ++i) {
if (!t[i])
continue;
if (t[i] + 1 < k) {
f = 1;
break;
}
int p = (t[i] + k - 1) / k;
tmp = std::min(tmp, 1 + (s[i] - t[i]) / p);
//printf("tmp %d\n", tmp);
}
if (!f)
ans = std::max(ans, tmp);
}
printf("%d\n", ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 4008kb
input:
2 bajkaaall aal abca cba
output:
2 1
result:
ok 2 number(s): "2 1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3744kb
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 1
result:
ok 16 numbers
Test #3:
score: -100
Wrong Answer
time: 33ms
memory: 3972kb
input:
90522 cyykzyylklyll ylcyllklzk ttusuuudtdtqus uuddu uefyqfkiblyfkyd ffyyqde qfxqecljeqeedea jqdxf prrbfxdxffpbpp ffppd ynjgygygjnjnjg jgynjggn maenpaksmxyya saxkep nrdnbnjipnjowjz djbwojzrpni oputuoufoojupu uoouopo mphmhphpkpkpmhp phmhpppp zwznzpzqyjczzy wczjnpzqy pfxfxxkfffpfx fxffkffxpx hzdhzhhh h...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 2 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 2 3 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 2 1 1 1 1 4 1 2 1 1 1 1 1 3 1 1 3 1 1 1 1 1 1 1 1 1 1 1 3 1 1 4 1 1 1 1 1 1 1 1 1 1 5 1 7 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 ...
result:
wrong answer 5721st numbers differ - expected: '1', found: '2'