QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#770893 | #7618. Pattern Search | SCUTkk | WA | 0ms | 3856kb | C++20 | 1.2kb | 2024-11-22 01:32:21 | 2024-11-22 01:32:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
// #define int long long
using ll = long long;
using i64 = long long;
using pii = pair<int, int>;
using db = double;
#define cY cout << "YES\n"
#define cN cout << "NO\n"
#define cA cout << ans << "\n"
#define pb push_back
const int N = 2e5 + 7;
const ll mod = 998244353;
const ll MOD = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
void crossparallel() {
string s, t;
cin >> s >> t;
vector<int> cs(26), ct(26);
for (auto i : s) cs[i - 'a']++;
for (auto i : t) ct[i - 'a']++;
int ans = s.length();
for (int i = 0; i < 26; i++) {
if (cs[i] < ct[i]) {
cout << 0 << "\n";
return;
}
}
for (int p = t.length(); p > 0; p--) {
for (int i = 0; i < 26; i++) {
if (ct[i] == 0)
continue;
ans = min(ans, cs[i] / ((ct[i] + p - 1) / p));
}
}
cA;
return;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--) {
crossparallel();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3856kb
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: 3616kb
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'