QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#226887#7618. Pattern Searchckiseki#WA 0ms3652kbC++201.5kb2023-10-26 17:46:482023-10-26 17:46:49

Judging History

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

  • [2023-10-26 17:46:49]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3652kb
  • [2023-10-26 17:46:48]
  • 提交

answer

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

#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(const char *s, auto ...a) {
  cerr << "\e[1;32m(" << s << ") = (";
  int f = 0;
  (..., (cerr << (f++ ? ", " : "") << a));
  cerr << ")\e[0m\n";
}
void orange_(const char *s, auto L, auto R) {
  cerr << "\e[1;32m[ " << s << " ] = [ ";
  for (int f = 0; L != R; ++f)
    cerr << (f ? ", " : "") << *L++;
  cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  const auto solve = [] {
    string S, T;
    cin >> S >> T;
    int A[26] = {}, B[26] = {};
    for (char c : S) A[c - 'a'] += 1;
    for (char c : T) B[c - 'a'] += 1;
    for (int j = 0; j < 26; j++) {
      if (A[j] < B[j]) {
        return 0;
      }
    }

    for (int j = 0; j < 26; j++) {
      A[j] -= B[j];
    }

    const auto cdiv = [](int a, int b) {
      return (a + b - 1) / b;
    };

    const int n = max(S.size(), T.size());
    int mx = 0;
    for (int k = 1; k <= n; k++) {
      int cur = 1e9;
      for (int j = 0; j < 26; j++) {
        int C = cdiv(B[j], k + 1);
        int D = B[j] - C * k;
        assert (D <= C);
        if (C == 0) continue;
        cur = min(cur, A[j] / C + 1);
      }
      mx = max(mx, cur);
    }

    return mx;
  };

  int tc;
  cin >> tc;
  while (tc--)
    cout << solve() << '\n';

  return 0;
}

详细

Test #1:

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

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:

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'