QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#225857#7618. Pattern Searchucup-team2279WA 22ms3588kbC++14752b2023-10-25 10:48:002023-10-25 10:48:00

Judging History

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

  • [2023-10-25 10:48:00]
  • 评测
  • 测评结果:WA
  • 用时:22ms
  • 内存:3588kb
  • [2023-10-25 10:48:00]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;int fl,tot;
void solve(){
	string s,t;
	cin>>s>>t;
	vector<int> a(26),b(26),d(26);
	for(char&x:s) a[x-'a']++;
	for(char&x:t) b[x-'a']++;
	int mi=t.size(),o=s.size();
	for(int i=0;i<26;i++) if(b[i]) mi=min(mi,b[i]);
	int p=mi,k=s.size();
	for(int i=0;i<26;i++) if(b[i]){
		o=min(o,a[i]/b[i]);
		int c=d[i]=(b[i]+mi)/(mi+1);
		if(c*mi<b[i]) p=mi+1;
		k=min(k,a[i]/c);
	}
	int ans=k-p+1;
	if(p==mi+1){
		int fl=1;
		for(int i=0;i<26;i++) if(a[i]-k*d[i]<b[i]-mi*d[i]) fl=0;
		ans+=fl;
	}
	if(fl){
		if(++tot==2663) cout<<s<<" "<<t<<"\n";
	}else cout<<max(ans,o)<<"\n";
}
int main(){
	cin.tie(0)->sync_with_stdio(0);
	int t;
	cin>>t;fl=t==90522;
	while(t--) solve();
	return 0;
}

詳細信息

Test #1:

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

input:

2
bajkaaall aal
abca cba

output:

2
1

result:

ok 2 number(s): "2 1"

Test #2:

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

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: 22ms
memory: 3588kb

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:

kkkkkvvvgvvdkvk vkkkvkvk

result:

wrong output format Expected integer, but "kkkkkvvvgvvdkvk" found