QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#317261 | #7618. Pattern Search | karuna# | WA | 0ms | 3636kb | C++20 | 1.0kb | 2024-01-28 18:49:52 | 2024-01-28 18:49:52 |
Judging History
answer
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main() {
cin.tie(0); ios_base::sync_with_stdio(0);
int t;
cin >> t;
while (t--) {
string S, T;
cin >> S >> T;
vector<int> cnt(26);
for (char c : S) cnt[c - 'a']++;
bool flag = true;
for (char c : T) {
if (cnt[c - 'a'] == 0) {
flag = false;
break;
}
cnt[c - 'a']--;
}
if (!flag) {
cout << 0 << '\n';
}
else {
vector<int> d(26);
for (char c : T) d[c - 'a']++;
int mn = 1e9;
for (int x : d) if (x) mn = min(mn, x);
int ans = 1;
for (int k = 1; k <= mn; k++) {
bool flag = true;
for (int x : d) if (x) {
if (x / k < x % k) flag = false;
}
if (!flag) continue;
int s = 1e9;
for (int i = 0; i < 26; i++) if (d[i]) {
s = min(s, cnt[i] / (d[i] / k));
}
ans = max(ans, s + 1);
}
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: 0ms
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 1 2 0 0 0 0 1
result:
wrong answer 10th numbers differ - expected: '2', found: '1'