QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#749532 | #7618. Pattern Search | ucup-team3474 | WA | 148ms | 3620kb | C++20 | 1.3kb | 2024-11-15 03:14:24 | 2024-11-15 03:14:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define mem(a) memset(a,0,sizeof(a))
const int N=100005;
int t,n;
int S[26],T[26];
int check(int x){
int ans=0;
bool flag=1;
for(int i=0;i<26;i++) if((T[i]+1)/2*x>S[i]) flag=0;
if(flag) return 1;
For(cs,1,(n+1)/2)if(1){
int sum=0,flag=0,gb=1e9;
For(i,0,25){
int ab=min(S[i]/x,T[i]/cs),b=T[i]-ab*cs;
//if(x==2&&cs==1&&i+'a'=='l')cerr<<ab<<" "<<S[i]<<" "<<b<<endl;
if(b>ab)flag=1;
}
//if(x==2&&flag==0)cout<<cs<<" "<<flag<<endl;
if(flag)continue;
return 1;
}
return 0;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);
cin>>t;
while(t--){
string s,t;
cin>>s>>t;
mem(S); mem(T);
for(auto i:s)S[i-'a']++;
for(auto i:t)T[i-'a']++;
For(i,0,25)S[i]-=T[i];
int flag=0;
For(i,0,25)if(S[i]<0){
cout<<0<<endl; flag=1; break;
}
n=t.length();
if(flag)continue;
int l=0,r=s.length();
while(l<r){
int mid=(l+r)>>1; mid++;
if(check(mid))l=mid; else r=mid-1;
}
cout<<1+l<<"\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
input:
2 bajkaaall aal abca cba
output:
2 1
result:
ok 2 number(s): "2 1"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3620kb
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 2 2 0 0 0 0 1
result:
ok 16 numbers
Test #3:
score: -100
Wrong Answer
time: 148ms
memory: 3556kb
input:
90522 cyykzyylklyll ylcyllklzk ttusuuudtdtqus uuddu uefyqfkiblyfkyd ffyyqde qfxqecljeqeedea jqdxf prrbfxdxffpbpp ffppd ynjgygygjnjnjg jgynjggn maenpaksmxyya saxkep nrdnbnjipnjowjz djbwojzrpni oputuoufoojupu uoouopo mphmhphpkpkpmhp phmhpppp zwznzpzqyjczzy wczjnpzqy pfxfxxkfffpfx fxffkffxpx hzdhzhhh h...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 2 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 2 3 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 2 1 1 1 1 4 1 1 1 1 1 1 1 3 1 1 3 1 1 1 1 1 1 1 1 1 1 1 3 1 1 4 1 1 1 1 1 1 1 1 1 1 5 1 7 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 ...
result:
wrong answer 77th numbers differ - expected: '2', found: '1'