QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623814#7618. Pattern SearchLX1288#WA 0ms3772kbC++14725b2024-10-09 14:05:022024-10-09 14:05:03

Judging History

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

  • [2024-10-09 14:05:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3772kb
  • [2024-10-09 14:05:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int M=1005;
int tt,n,m;
string s,t;
int main(){
	ios::sync_with_stdio(false),cin.tie(0);
	cin>>tt;
	while(tt--){
		int cnt[M]={},cnt1[M]={},cnt2[M]={};
		string s1,s2;
		cin>>s>>t;
		for(int i=0;i<t.size();i++)cnt1[t[i]]++;
		for(int i=0;i<s.size();i++)cnt[s[i]]++;
		int mx=0;
		for(int i=0;i<t.size()-1;i++){
			s1=s1+t[i];
			s2=t[t.size()-1-i]+s2;
			if(s1==s2)mx=max(mx,i+1);
		}
//		printf("mx=%d\n",mx);
		for(int i=mx;i<t.size();i++)cnt2[t[i]]++;
		
		int mi=1e9;
		for(int i='a';i<='z';i++){
			if(cnt1[i]){
				if(cnt1[i]<=cnt[i])mi=min(mi,(cnt[i]-cnt1[i])/cnt2[i]+1);
				else mi=0;
			}
		}
		printf("%d\n",mi);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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'