QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#625075#7618. Pattern SearchJustinWu#WA 1ms3904kbC++14739b2024-10-09 17:21:222024-10-09 17:21:22

Judging History

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

  • [2024-10-09 17:21:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3904kb
  • [2024-10-09 17:21:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int T,a[400],b[400];
char s[2000005];
int check;
int main(){
	scanf("%d",&T);
	while(T--){
		scanf("%s",s+1);
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		check=0;
		for(int i=1;i<=strlen(s+1);i++){
			a[s[i]]++;
		}
		scanf("%s",s+1);
		for(int i=1;i<=strlen(s+1);i++){
			b[s[i]]++;
		}
		for(int i='a';i<='z';i++){
			if(b[i])check++;
		}
		if(check!=1)
			for(int i='a';i<='z';i++){
				a[i]-=b[i]/2;
				b[i]=b[i]/2+b[i]%2;
			}
		else {
			for(int i='a';i<='z';i++){
				if(b[i]){
					a[i]-=b[i]-1;
					b[i]=1;
				}
			}
		}
		int mi=1e9;
		for(int i='a';i<='z';i++){
			if(b[i])mi=min(mi,a[i]/b[i]);
		}
		printf("%d\n",max(0,mi));
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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'