QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#282567#7618. Pattern Searchlight_ink_dots#WA 1ms5944kbC++141.1kb2023-12-12 13:47:342023-12-12 13:47:35

Judging History

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

  • [2023-12-12 13:47:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5944kb
  • [2023-12-12 13:47:34]
  • 提交

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);
        if (g != 1) {
            int mx = INT_MAX;
            for (int i = 0; i < sigma_size; i++)
                if (cT[i])
                    mx = min(mx, cS[i] / (cT[i] / g));
            printf("%d\n", max(0, mx - g + 1));
            continue;
        }
        int mx = INT_MAX;
        for (int i = 0; i < sigma_size; i++) {
            if (!cT[i])
                continue;
            int cA = cT[i] >> 1, cB = cT[i] & 1;
            mx = min(mx, (cS[i] - cA) / (cA + cB));
        }
        printf("%d\n", max(0, mx));
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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
0
0
1

result:

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