QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#266783#7618. Pattern Searchucup-team173#WA 32ms3396kbC++201.4kb2023-11-26 17:37:112023-11-26 17:37:13

Judging History

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

  • [2023-11-26 17:37:13]
  • 评测
  • 测评结果:WA
  • 用时:32ms
  • 内存:3396kb
  • [2023-11-26 17:37:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define Mp make_pair
#define SZ(x) ((int)(x).size())

typedef double db;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define ws laksdaljk
string s, t;
int n, m;
int ss[26];
int ts[26];
int rs[26];
int ws[26];
void solve() {
    memset(ts, 0, sizeof ts);
    memset(ss, 0, sizeof ss);
    cin >> s >> t;
    for (char c : s) ss[c - 'a']++;
    for (char c : t) ts[c - 'a']++;
    int ans = 1e9;
    for (int i = 0; i < 26; i++) {
        if (ts[i]) {
            if (ss[i] < ts[i]) return cout << "0\n", void();
            ans = min(ans, ss[i] / ts[i]);
        }
    }
    for (int c = 1; c <= t.size(); c++) {
        int tmp = 1e9;
        int s=0;
        for (int i = 0; i < 26; i++) {
            if (ts[i]) {
                if (ts[i] < c) {
                    tmp = 0;
                    break;
                }
                rs[i] = (ts[i] + c) / (c + 1);
                s+=rs[i];
                tmp = min(tmp, (ss[i] - ts[i]) / rs[i] + 1);
            }
        }
        if(s*c<=t.size())
        ans = max(ans, tmp);
    }
    cout << ans << "\n";
}
signed main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--) solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3384kb

input:

2
bajkaaall aal
abca cba

output:

2
1

result:

ok 2 number(s): "2 1"

Test #2:

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

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: 32ms
memory: 3396kb

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'