QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#317955#7618. Pattern Searcharnold518WA 0ms6024kbC++171.3kb2024-01-30 02:12:292024-01-30 02:12:30

Judging History

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

  • [2024-01-30 02:12:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:6024kb
  • [2024-01-30 02:12:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2e6;

int N, M, TC;
char S[MAXN+10], T[MAXN+10];
int A[30], B[30];

int main()
{
    scanf("%d", &TC);
    while(TC--)
    {
        scanf(" %s %s", S+1, T+1);
        N=strlen(S+1);
        M=strlen(T+1);

        for(int i=0; i<26; i++) A[i]=B[i]=0;
        for(int i=1; i<=N; i++) A[S[i]-'a']++;
        for(int i=1; i<=M; i++) B[T[i]-'a']++;

        bool flag=true;
        for(int i=0; i<26; i++)
        {
            if(A[i]<B[i]) flag=false;
            else A[i]-=B[i];
        }
        if(!flag)
        {
            printf("0\n");
            continue;
        }
        
        int ans=0;
        for(int i=1; i<=M; i++)
        {
            bool flag=true;
            int val=N;
            for(int j=0; j<26; j++)
            {
                int x=(B[j]+i)/(i+1);
                int y=B[j]-x*i;
                if(x<y)
                {
                    flag=false;
                    break;
                }
                if(x) val=min(val, A[j]/x);
            }
            if(flag) ans=max(ans, val);
        }
        printf("%d\n", ans+1);
    }
}

详细

Test #1:

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

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

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
2

result:

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