QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#749527#7618. Pattern Searchucup-team3474WA 0ms3844kbC++201.2kb2024-11-15 03:10:322024-11-15 03:10:33

Judging History

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

  • [2024-11-15 03:10:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3844kb
  • [2024-11-15 03:10:32]
  • 提交

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;
    For(cs,(n+1)/2,n)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<<endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3844kb

input:

2
bajkaaall aal
abca cba

output:

1
1

result:

wrong answer 1st numbers differ - expected: '2', found: '1'