QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#769889#7618. Pattern Searchucup-team2172#WA 25ms5968kbC++231.3kb2024-11-21 19:46:412024-11-21 19:46:42

Judging History

This is the latest submission verdict.

  • [2024-11-21 19:46:42]
  • Judged
  • Verdict: WA
  • Time: 25ms
  • Memory: 5968kb
  • [2024-11-21 19:46:41]
  • Submitted

answer

#include <bits/stdc++.h>
#define inf (0x7f7f7f7f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
    int ch = 0, f = 0; x = 0;
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    if(f) x = -x;
}
const int N = 2e6 + 5;
int T;
char t[N], s[N];
int cntt[26], cnts[26];
int main(){
    read(T);
    while(T--){
        scanf("%s %s", t + 1, s + 1);
        int n = strlen(t + 1);
        int m = strlen(s + 1);
        for(int i = 0; i < 26; i++) cntt[i] = cnts[i] = 0;
        for(int i = 1; i <= n; i++) cntt[t[i] - 'a']++;
        for(int i = 1; i <= m; i++) cnts[s[i] - 'a']++;
        int maxx = m;
        for(int i = 0; i < 26; i++){
            if(cnts[i] != 0){
                maxx = min(maxx, cnts[i]);
            }
        }
        int ans = n;
        for(int j = 0; j < 26; j++){
            if(cnts[j] == 0) continue;
            if(cntt[j] < cnts[j]) ans = 0;
            else{
                cntt[j] -= cnts[j];
                ans = min(ans, 1 + cntt[j] / ((cnts[j] + maxx) / (maxx + 1)));
            }
        }
        printf("%d\n", ans);
    }
}

详细

Test #1:

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

input:

2
bajkaaall aal
abca cba

output:

2
1

result:

ok 2 number(s): "2 1"

Test #2:

score: 0
Accepted
time: 1ms
memory: 5952kb

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: 25ms
memory: 5964kb

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'