QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#404766#7618. Pattern Searchucup-team3215#WA 1ms3764kbC++20608b2024-05-04 17:45:342024-05-04 17:45:35

Judging History

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

  • [2024-05-04 17:45:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3764kb
  • [2024-05-04 17:45:34]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  for (int tc = (cin >> tc, tc); tc--; ) {
    int ct[26]{}, cp[26]{};
    string t, p; cin >> t >> p;
    for (auto c: t) ++ct[c - 'a'];
    for (auto c: p) ++cp[c - 'a'];
    int ans = 0;
    for (int n = 1; n <= p.size(); ++n) {
      int cans = 1e9;
      for (int i = 0; i < 26; ++i) if (cp[i]) {
        int a = (cp[i] + n) / (n + 1), b = cp[i] - a * n;
        cans = min(cans, (ct[i] - (n - 1) * a - b) / a);
      }
      ans = max(ans, cans);
    }
    cout << ans << '\n';
  }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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'