QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#266751 | #7618. Pattern Search | ucup-team173# | WA | 28ms | 3508kb | C++20 | 1.2kb | 2023-11-26 17:20:45 | 2023-11-26 17:20:45 |
Judging History
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;
for(int i=0;i<26;i++){
if(ts[i]){
if(ts[i]<c){
tmp=0;break;
}
rs[i]=(ts[i]+c)/(c+1);
tmp=min(tmp,(ss[i]-ts[i])/rs[i]+1);
}
}
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: 3372kb
input:
2 bajkaaall aal abca cba
output:
2 1
result:
ok 2 number(s): "2 1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3508kb
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: 28ms
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'