QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#273474#7618. Pattern SearcharahatoWA 0ms3616kbC++14574b2023-12-03 00:12:242023-12-03 00:12:24

Judging History

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

  • [2023-12-03 00:12:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3616kb
  • [2023-12-03 00:12:24]
  • 提交

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 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: 0ms
memory: 3616kb

input:

2
bajkaaall aal
abca cba

output:

2
1

result:

ok 2 number(s): "2 1"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3552kb

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

result:

wrong answer 5th numbers differ - expected: '0', found: '1'