QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#282575#7618. Pattern Searchlight_ink_dots#WA 1ms5984kbC++141.2kb2023-12-12 14:10:202023-12-12 14:10:20

Judging History

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

  • [2023-12-12 14:10:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5984kb
  • [2023-12-12 14:10:20]
  • 提交

answer

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

int main() {
    static const int maxn = 2000010, sigma_size = 26;
    int z;
    scanf("%d", &z);
    while (z--) {
        static char s[maxn], t[maxn];
        scanf("%s %s", s, t);
        int ls = strlen(s), lt = strlen(t);
        static int cS[sigma_size], cT[sigma_size];
        memset(cS, 0, sizeof(cS)), memset(cT, 0, sizeof(cT));
        for (int i = 0; i < ls; i++) cS[s[i] - 'a']++;
        for (int i = 0; i < lt; i++) cT[t[i] - 'a']++;
        int g = 0;
        for (int i : cT) g = __gcd(g, i);
        int mx = 0;
        if (g != 1) {
            mx = INT_MAX;
            for (int i = 0; i < sigma_size; i++)
                if (cT[i])
                    mx = min(mx, cS[i] / (cT[i] / g));
            mx = max(0, mx - g + 1);
        }
        for (int c = 1; c <= lt; c++) {
            int cur = INT_MAX;
            for (int i = 0; i < sigma_size; i++) {
                if (!cT[i])
                    continue;
                int p = (cT[i] + c) / (c + 1), q = cT[i] - p * c;
                cur = min(cur, (cS[i] - q) / p);
            }
            mx = max(mx, cur - c + 1);
        }
        printf("%d\n", mx);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5984kb

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

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'