QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#227253 | #7618. Pattern Search | ucup-team1004# | WA | 1ms | 5992kb | C++14 | 1.2kb | 2023-10-27 08:15:45 | 2023-10-27 08:15:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T> &x){
if(x.empty())return out<<"[]";
out<<'['<<x[0];
for(int i=1,len=x.size();i<len;i++)out<<','<<x[i];
return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
cerr<<x<<endl;
}
template<typename T,typename ... S>
void debug(T x,S...y){
cerr<<x<<' ',debug(y...);
}
const int N=2e6+10,V=26;
int T,n,m,a[V],b[V];
char s1[N],s2[N];
int calc1(){
int ans=n;
for(int i=0;i<V;i++)if(b[i]){
ans=min(ans,(a[i]-b[i])/((b[i]+1)/2)+1);
}
return ans;
}
int calc2(){
int ans=n,g=0;
for(int i=0;i<V;i++)g=__gcd(g,b[i]);
for(int i=0;i<V;i++)if(b[i]){
ans=min(ans,(a[i]-b[i])/(b[i]/g)+1);
}
return ans;
}
void get(){
scanf("%s%s",s1+1,s2+1),n=strlen(s1+1),m=strlen(s2+1);
for(int i=1;i<=n;i++)a[s1[i]-'a']++;
for(int i=1;i<=m;i++)b[s2[i]-'a']++;
printf("%d\n",max(calc1(),calc2()));
}
void clr(){
for(int i=0;i<V;i++)a[i]=b[i]=0;
}
int main(){
for(scanf("%d",&T);T--;clr())get();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5992kb
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: 5804kb
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 -1 -1 1
result:
wrong answer 10th numbers differ - expected: '2', found: '1'