QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623680 | #7618. Pattern Search | HDU-T12# | WA | 1ms | 3552kb | C++20 | 1.1kb | 2024-10-09 13:41:50 | 2024-10-09 13:41:52 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define X first
#define Y second
#define umap unordered_map
using ll = long long;
using ull = unsigned long long;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int maxn = 2e5 + 5, mod = 1e9 + 7, maxp = 31, inf = 1e9;
const ll INF = 1e18;
const double eps = 1e-6;
void solve() {
string s, t;
cin >> s >> t;
int n = s.size();
int m = t.size();
vector<int> sum(26);
for(auto it : s) {
sum[it - 'a'] += 1;
}
vector<int> cnt(26);
for(auto it : t) {
cnt[it - 'a'] += 1;
}
vector<int> half(26);
for(int i = 0; i <= 25; i++) {
half[i] += cnt[i] / 2;
}
for(int i = 0; i <= 25; i++) {
cnt[i] -= half[i];
sum[i] -= cnt[i];
if(sum[i] < 0) {
return cout << 0 << '\n', void();
}
}
//cerr << "?";
int res = 1;
int Min = 1e9;
for(int i = 0; i <= 25; i++) {
if(cnt[i]) Min = min(Min, sum[i] / cnt[i]);
}
cout << res + (Min == 1e9 ? 0 : Min) << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
cin >> tt;
while (tt--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3552kb
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: 3548kb
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 1 1 0 1 1 2 2 0 0 0 0 2
result:
wrong answer 5th numbers differ - expected: '0', found: '1'