QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#227265#7618. Pattern Searchucup-team1004#WA 25ms3880kbC++141.2kb2023-10-27 08:39:152023-10-27 08:39:16

Judging History

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

  • [2023-10-27 08:39:16]
  • 评测
  • 测评结果:WA
  • 用时:25ms
  • 内存:3880kb
  • [2023-10-27 08:39:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T> &x){
	if(x.empty())return out<<"[]";
	out<<'['<<x[0];
	for(int i=1,len=x.size();i<len;i++)out<<','<<x[i];
	return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
	cerr<<x<<endl;
}
template<typename T,typename ... S>
void debug(T x,S...y){
	cerr<<x<<' ',debug(y...);
}
const int N=2e5+10,V=26;
int T,n,m,a[V],b[V];
char s1[N],s2[N];
bool chk(){
	for(int i=0;i<V;i++){
		if(a[i]<b[i])return 1;
	}
	return 0;
}
int calc(){
	int ans=n,mn=n;
	for(int i=0;i<V;i++)if(b[i])mn=min(mn,b[i]);
	for(int i=0;i<V;i++)if(b[i]){
		if(a[i]<b[i])return 0;
		int x=(b[i]+mn)/(mn+1);
		ans=min(ans,(a[i]-b[i])/x+1);
	}
	return ans;
}
void get(){
	scanf("%s%s",s1+1,s2+1),n=strlen(s1+1),m=strlen(s2+1);
	for(int i=1;i<=n;i++)a[s1[i]-'a']++;
	for(int i=1;i<=m;i++)b[s2[i]-'a']++;
	if(chk())puts("0");
	else printf("%d\n",calc());
}
void clr(){
	for(int i=0;i<V;i++)a[i]=b[i]=0;
}
int main(){
	for(scanf("%d",&T);T--;clr())get();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
bajkaaall aal
abca cba

output:

2
1

result:

ok 2 number(s): "2 1"

Test #2:

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

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: 3880kb

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'