QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#404764#7618. Pattern Searchucup-team3215#WA 0ms3588kbC++20700b2024-05-04 17:37:082024-05-04 17:37:09

Judging History

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

  • [2024-05-04 17:37:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3588kb
  • [2024-05-04 17:37:08]
  • 提交

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 l = 0, r = t.size();
    while (r > l + 1) {
      int m = (l + r) / 2;
      bool ok = 0;
      for (int n = 1; !ok && n <= p.size(); ++n) {
        ok = 1;
        for (int i = 0; ok && i < 26; ++i) if (cp[i]) {
          int a = (cp[i] + n) / (n + 1), b = cp[i] - a * n;
          ok &= ct[i] >= (m + n - 1ll) * a + b;
        }
      }
      (ok? l: r) = m;
    }
    cout << l << '\n';
  }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3588kb

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

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:

0
0
0
1
0
1
0
1
1
2
2
0
0
0
0
2

result:

wrong answer 1st numbers differ - expected: '1', found: '0'