QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#246520#7606. Digital NimDateTreeWA 1ms3608kbC++171.3kb2023-11-10 21:38:232023-11-10 21:38:24

Judging History

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

  • [2023-11-10 21:38:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3608kb
  • [2023-11-10 21:38:23]
  • 提交

answer

#include <bits/stdc++.h>

int main() {
    //freopen("in", "r", stdin);
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int ttt;
    std::cin >> ttt;
    while (ttt--) {
        std::string x, y;
        std::cin >> x >> y;
        std::vector<int> s(26), t(26);
        for (auto &c: x)
            ++s[c - 'a'];
        for (auto &c: y)
            ++t[c - 'a'];
        bool flag = 0;
        for (int i = 0; i < 26; ++i) {
            if (s[i] < t[i]) {
                puts("0");
                flag = 1;
                break;
            }
        }
        if (flag)
            continue;
        int min = std::min(x.length(), y.length());
        int ans = 1;
        for (int k = 2; k <= min; ++k) {
            bool f = 0;
            int tmp = 1e9 + 7;
            for (int i = 0; i < 26; ++i) {
                if (!t[i])
                    continue;
                if (t[i] + 1 < k) {
                    f = 1;
                    break;
                }
                int p = (t[i] + k - 1) / k;
                tmp = std::min(tmp, 1 + (s[i] - t[i]) / p);
                //printf("tmp %d\n", tmp);
            }
            if (!f)
                ans = std::max(ans, tmp);
        }
        printf("%d\n", ans);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3608kb

input:

4
1
10
42
190

output:

1
1000000007
1
1

result:

wrong answer 1st lines differ - expected: 'Algosia', found: '1'