QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#273475#7618. Pattern SearcharahatoWA 1ms3464kbC++14647b2023-12-03 00:13:292023-12-03 00:13:30

Judging History

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

  • [2023-12-03 00:13:30]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3464kb
  • [2023-12-03 00:13:29]
  • 提交

answer

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


void doit(){
	string S,T;
	vector<int> s(26,0),t(26,0),p(26);
	cin>>S>>T;
	for(char c:S) s[c-'a']++;
	for(char c:T) t[c-'a']++;
	int ans=0;
	for(int c=0;c<26;c++) if(s[c]<t[c]){
		cout<<0<<endl;
		return ;
	}
	for(int i=1;i<=T.size();i++){
		bool ok=1;
		int cur=S.size();
		for(int c=0;c<26&&ok;c++){
			p[c]=t[c]/i;
			if(t[c]%i>p[i]) ok=0;
		}
		if(!ok) continue;
		for(int c=0;c<26;c++) if(t[c]) cur=min(cur,1+(s[c]-t[c])/p[c]);
		ans=max(ans,cur);
	}
	cout<<ans<<endl;
}

signed main(){
	cin.tie(0) -> sync_with_stdio(0);
	int t;
	cin>>t;
	while(t--) doit();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
bajkaaall aal
abca cba

output:

2
1

result:

ok 2 number(s): "2 1"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3420kb

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
1
2
0
0
0
0
1

result:

wrong answer 10th numbers differ - expected: '2', found: '1'