QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#624771#7618. Pattern Searchucup-team3519#WA 31ms3852kbC++201.1kb2024-10-09 16:35:592024-10-09 16:36:02

Judging History

你现在查看的是最新测评结果

  • [2024-10-09 16:36:02]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:3852kb
  • [2024-10-09 16:35:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define V vector
typedef long long LL;
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
#define fi first
#define se second
#define all1(x) (x).begin() + 1, (x).end()
#define all0(x) (x).begin(), (x).end()
#define pb push_back

const int INF = 2e9 + 1000;

void solve() {
    string s, t; cin >> s >> t;
    V<int> cnt_s(26);
    V<int> cnt_t(26);
    V<int> cost_t(26);

    for(auto c : s) cnt_s[c - 'a']++;
    for(auto c : t) cnt_t[c - 'a']++;

    for(int i = 0; i < 26; i++) {
        cnt_s[i] -= cnt_t[i];
        if(cnt_s[i] < 0) {
            cout << 0 << endl;
            return;
        }
    }

    int mn = INF;
    for(auto cnt : cnt_t) {
        if(cnt) mn = min(mn, cnt);
    }

    mn++;
    for(auto &cnt : cnt_t) {
        cnt = (cnt + mn - 1) / mn;
    }

    mn = INF;
    for(int i = 0; i < 26; i++) {
        if(cnt_t[i]) mn = min(cnt_s[i] / cnt_t[i], mn);
    }

    cout << mn + 1 << endl;
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int t; cin >> t;
    while(t--)
    solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3616kb

input:

2
bajkaaall aal
abca cba

output:

2
1

result:

ok 2 number(s): "2 1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3620kb

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
2
2
0
0
0
0
1

result:

ok 16 numbers

Test #3:

score: -100
Wrong Answer
time: 31ms
memory: 3852kb

input:

90522
cyykzyylklyll ylcyllklzk
ttusuuudtdtqus uuddu
uefyqfkiblyfkyd ffyyqde
qfxqecljeqeedea jqdxf
prrbfxdxffpbpp ffppd
ynjgygygjnjnjg jgynjggn
maenpaksmxyya saxkep
nrdnbnjipnjowjz djbwojzrpni
oputuoufoojupu uoouopo
mphmhphpkpkpmhp phmhpppp
zwznzpzqyjczzy wczjnpzqy
pfxfxxkfffpfx fxffkffxpx
hzdhzhhh h...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
4
1
1
1
2
1
1
4
1
1
1
1
1
1
1
1
1
1
1
1
1
2
1
2
1
1
1
1
1
2
3
1
1
1
1
1
1
1
1
1
2
2
1
1
1
1
1
2
1
1
1
1
4
1
2
1
1
1
1
1
3
1
1
3
1
1
1
1
1
1
1
1
1
1
1
3
1
1
4
1
1
1
1
1
1
1
1
1
1
5
1
7
1
1
1
1
1
3
1
1
1
1
1
1
1
1
1
1
1
2
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
2
...

result:

wrong answer 5721st numbers differ - expected: '1', found: '2'