QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#770897#7618. Pattern SearchSCUTkkWA 1ms3792kbC++201.3kb2024-11-22 01:39:162024-11-22 01:39:17

Judging History

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

  • [2024-11-22 01:39:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3792kb
  • [2024-11-22 01:39:16]
  • 提交

answer

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

#define int long long

using ll = long long;
using i64 = long long;
using pii = pair<int, int>;
using db = double;

#define cY cout << "YES\n"
#define cN cout << "NO\n"
#define cA cout << ans << "\n"
#define pb push_back

const int N = 2e5 + 7;
const ll mod = 998244353;
const ll MOD = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

void crossparallel() {
    string s, t;
    cin >> s >> t;

    vector<int> cs(26), ct(26);
    for (auto i : s) cs[i - 'a']++;
    for (auto i : t) ct[i - 'a']++;

    int ans = s.length();

    for (int i = 0; i < 26; i++) {
        if (cs[i] < ct[i]) {
            cout << 0 << "\n";
            return;
        }
    }

    for (int p = 1; p <= t.length(); p++) {
        for (int i = 0; i < 26; i++) {
            if (ct[i] == 0)
                continue;
            if ((ct[i] + p - 1) / p * (p - 1) > ct[i]) {
                cout << ans << "\n";
                return;
            }
            ans = min(ans, cs[i] / ((ct[i] + p - 1) / p));
        }
    }

    cA;

    return;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    cin >> t;
    while (t--) {
        crossparallel();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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'