QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#625257#7618. Pattern SearchguodongWA 1ms5620kbC++14849b2024-10-09 18:15:192024-10-09 18:15:20

Judging History

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

  • [2024-10-09 18:15:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5620kb
  • [2024-10-09 18:15:19]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2000005;
int a[35],b[35],f[N],g[N];
int main(){
	int n;
	string s,t;
	cin>>n;
	while(n--){
		cin>>s>>t;
		int lens=s.length(),lent=t.length(),ans=0;
		for(int i=1; i<=lent; i++)f[i]=N,g[i]=0;
		for(int i=0; i<26; i++)a[i]=0,b[i]=0;
		for(int i=0; i<lens; i++)a[s[i]-'a']++;
		for(int i=0; i<lent; i++)b[t[i]-'a']++;
		int cnt=0;
		for(int i=0; i<26; i++){
			if(b[i]==0){
				cnt++;
				continue;
			}
			int mx=0;
			int xx=0,yy=0;
			for(int j=1; j<=b[i]; j++){
				int x=a[i]/j-b[i]/j+(b[i]%j<=a[i]%j),y=(b[i]-1)/j+1;
				if(y!=yy){
					f[yy]=min(f[yy],xx);
					g[yy]++;
					xx=x;
					yy=y;
				}
				else xx=max(xx,x);
			}
			f[yy]=min(f[yy],xx),g[yy]++;
		}
		for(int i=1; i<=lent; i++)if(g[i]==26-cnt)ans=max(ans,f[i]);
		cout<<ans<<endl;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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'