QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#433070#6635. Strange Keyboarducup-team3215Compile Error//C++201.7kb2024-06-07 23:37:362024-06-07 23:37:36

Judging History

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

  • [2024-06-07 23:37:36]
  • 评测
  • [2024-06-07 23:37:36]
  • 提交

answer

#include <algorithm>
#include <array>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

constexpr int A = 26, V = 26e6 + 1, K = 5e3;

int nx[V], cost[V], used = V, ks[K];
int64_t ans[K + 1];

int main() {
  cin.tie(0)->sync_with_stdio(0);
  for (int tc = (cin >> tc, tc); tc--; ) {
    fill_n(cost, used, 1e9);
    fill_n(nx, used, 0);
    used = 1;
    fill(ks + 1, end(ks), 1e9);
    fill(ans + 1, end(ans), 1e18);
    int n, k; cin >> n >> k;
    vector<string> v(n);
    for (auto& s: v) cin >> s;
    {
      priority_queue pq{greater{}, vector<array<int, 2>>{{1}}};
      vector<uint32_t> cost(k, -1);
      for (auto& s: v) cost[s.size() % k] = min(cost[s.size() % k], {s.size() / k + 1});
      while (pq.size()) {
        auto [c, l] = pq.top(); pq.pop();
        if (!l || c == ks[l])
        for (int s = 0; s < k; ++s) if (~cost[k] && ks[(l + s) % k] > c + cost[k] + (l + s) / k) {
          pq.push({ks[(l + s) % k] = c + cost[k] + (l + s) / k, (l + s) % k});
        }
      }
      reverse(ks + 1, ks + k);
    }
    for (auto& s: v) {
      int v = 0;
      for (int rem = s.size(); auto& c: s) {
        if (!nx[v]) nx[v] = used, used += A;
        v = nx[v] + c - 'a';
        --rem;
        cost[v] = min(cost[v], ks[rem % k] + rem / k);
      }
    }
    string s; cin >> s;
    for (int i = 0; i < s.size(); ++i) {
      int v = 0;
      for (int j = i; j < s.size(); ++j) {
        v = nx[v] + s[j] - 'a';
        if (cost[v] == 1e9) break;
        ans[j + 1] = min(ans[j + 1], ans[i] + cost[v] + 1);
      }
    }
    cout << (ans[s.size()] == 1e18? ans[s.size()]: -1) << '\n';
  }
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:27:14: error: ‘uint32_t’ was not declared in this scope
   27 |       vector<uint32_t> cost(k, -1);
      |              ^~~~~~~~
answer.code:5:1: note: ‘uint32_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
    4 | #include <queue>
  +++ |+#include <cstdint>
    5 | #include <vector>
answer.code:27:22: error: template argument 1 is invalid
   27 |       vector<uint32_t> cost(k, -1);
      |                      ^
answer.code:27:22: error: template argument 2 is invalid
answer.code:27:34: error: expression list treated as compound expression in initializer [-fpermissive]
   27 |       vector<uint32_t> cost(k, -1);
      |                                  ^
answer.code:28:28: error: invalid types ‘int[std::__cxx11::basic_string<char>::size_type {aka long unsigned int}]’ for array subscript
   28 |       for (auto& s: v) cost[s.size() % k] = min(cost[s.size() % k], {s.size() / k + 1});
      |                            ^
answer.code:28:53: error: invalid types ‘int[std::__cxx11::basic_string<char>::size_type {aka long unsigned int}]’ for array subscript
   28 |       for (auto& s: v) cost[s.size() % k] = min(cost[s.size() % k], {s.size() / k + 1});
      |                                                     ^
answer.code:32:46: error: invalid types ‘int[int]’ for array subscript
   32 |         for (int s = 0; s < k; ++s) if (~cost[k] && ks[(l + s) % k] > c + cost[k] + (l + s) / k) {
      |                                              ^
answer.code:32:79: error: invalid types ‘int[int]’ for array subscript
   32 |         for (int s = 0; s < k; ++s) if (~cost[k] && ks[(l + s) % k] > c + cost[k] + (l + s) / k) {
      |                                                                               ^
answer.code:33:46: error: invalid types ‘int[int]’ for array subscript
   33 |           pq.push({ks[(l + s) % k] = c + cost[k] + (l + s) / k, (l + s) % k});
      |                                              ^
answer.code:33:18: error: no matching function for call to ‘std::priority_queue<std::array<int, 2>, std::vector<std::array<int, 2> >, std::greater<void> >::push(<brace-enclosed initializer list>)’
   33 |           pq.push({ks[(l + s) % k] = c + cost[k] + (l + s) / k, (l + s) % k});
      |           ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/queue:66,
                 from answer.code:4:
/usr/include/c++/13/bits/stl_queue.h:738:7: note: candidate: ‘void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::array<int, 2>; _Sequence = std::vector<std::array<int, 2> >; _Compare = std::greater<void>; value_type = std::array<int, 2>]’
  738 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:738:30: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘const std::priority_queue<std::array<int, 2>, std::vector<std::array<int, 2> >, std::greater<void> >::value_type&’ {aka ‘const std::array<int, 2>&’}
  738 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_queue.h:746:7: note: candidate: ‘void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::array<int, 2>; _Sequence = std::vector<std::array<int, 2> >; _Compare = std::greater<void>; value_type = std::array<int, 2>]’
  746 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:746:25: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘std::priority_queue<std::array<int, 2>, std::vector<std::array<int, 2> >, std::greater<void> >::value_type&&’ {aka ‘std::array<int, 2>&&’}
  746 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~