QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#302318 | #7618. Pattern Search | defyers# | WA | 1ms | 3488kb | C++20 | 812b | 2024-01-10 19:11:34 | 2024-01-10 19:11:35 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
using ll = long long;
using pii = pair<int, int>;
int c_s[26], c_t[26];
void solve(int TC) {
string s, t; cin >> s >> t;
for(int i = 0; i < 26; i++) c_s[i] = c_t[i] = 0;
for(auto c : s) c_s[c - 'a']++;
for(auto c : t) c_t[c - 'a']++;
int mx = 1 << 30, cnt = 0;
for(int i = 0; i < 26; i++){
if(c_t[i]) mx = min(mx, c_s[i] / c_t[i]), cnt++;
}
if(cnt == 1){
int x = -1; for(int i = 0; i < 26; i++) if(c_t[i]) x = i;
cout << max(0, c_s[x] - c_t[x] + 1) << '\n';
}else{
cout << mx << '\n';
}
}
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
cout << fixed << setprecision(10);
int t = 1;
cin >> t;
for (int i = 1; i <= t; i++) {
solve(i);
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3448kb
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: 3488kb
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'