QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#226278 | #7618. Pattern Search | tselmegkh | WA | 0ms | 3676kb | C++17 | 1.2kb | 2023-10-25 19:21:54 | 2023-10-25 19:21:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
string s, t;
cin >> s >> t;
vector<int> fs(26);
for (char c : s) {
fs[c - 'a']++;
}
vector<int> ft(26);
for (char c : t) {
ft[c - 'a']++;
}
int mn = 1e9;
for (int i = 0; i < 26; i++) {
if (ft[i] > 0) {
mn = min(mn, ft[i]);
}
}
bool chichi = 1;
for(int i = 0; i < 26; i++){
if(mn != ft[i]){
chichi = 0;
break;
}
}
if(chichi) mn++;
vector<int> a(26);
for (int i = 0; i < 26; i++) {
a[i] = ft[i] / mn;
ft[i] %= mn;
}
int c = 1e9;
vector<int> b(26);
for (int i = 0; i < 26; i++) {
if (a[i] == 0) continue;
b[i] = fs[i] / a[i];
c = min(c, b[i]);
}
int ans = max(0, c - mn);
bool ok = c >= mn;
for (int i = 0; i < 26; i++) {
if (ft[i] > fs[i] - a[i] * c) {
ok = 0;
}
}
if (ok) ans++;
cout << ans << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3676kb
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: 3636kb
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 2
result:
wrong answer 10th numbers differ - expected: '2', found: '1'