QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#625257 | #7618. Pattern Search | guodong | WA | 1ms | 5620kb | C++14 | 849b | 2024-10-09 18:15:19 | 2024-10-09 18:15:20 |
Judging History
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'