QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#420888#6523. Escape PlanshepherdCompile Error//C++201.9kb2024-05-25 02:55:582024-05-25 02:55:59

Judging History

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

  • [2024-05-25 02:55:59]
  • 评测
  • [2024-05-25 02:55:58]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

static constexpr const ll inf = 1e15;

int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m, k;
    cin >> n >> m >> k;
    vector<bool> is_exit(n);
    for (int i = 0; i < k; i++) {
      int e;
      cin >> e;
      is_exit[--e] = true;
    }
    vector<int> d(n);
    for (int i = 0; i < n; i++) {
      cin >> d[i];
    }
    vector<vector<pair<int, ll>>> graph(n);
    for (int i = 0; i < m; i++) {
      int x, y;
      ll w;
      cin >> x >> y >> w;
      graph[--x].emplace_back(--y, w);
      graph[y].emplace_back(x, w);
    }
    vector<ll> ret(n, inf);
    vector<bool> marked(n, false);
    // vector<multiset<ll>> dd(n);
    vector<ll> dd(n, -1);
    auto cmp = [&](int x, int y) {
      auto dx = *prev(end(dd[x]));
      auto dy = *prev(end(dd[y]));
      if (dx != dy) return dx < dy;
      return x < y;
    };
    set<int, decltype(cmp)> q(cmp);
    for (int i = 0; i < n; i++) {
      if (is_exit[i]) {
        dd[i].insert(0);
        q.insert(i);
        d[i] = 0;
      }
    }
    while (!q.empty()) {
      auto curr = *q.begin();
      q.erase(q.begin());
      ret[curr] = *prev(end(dd[curr]));
      for (const auto& [neighbor, weight] : graph[curr]) {
        if (d[curr] < 0) continue 
        if (int(dd[neighbor].size()) > d[neighbor]) {
          assert(q.find(neighbor) != q.end());
          q.erase(neighbor);
        }
        dd[neighbor].insert(ret[curr] + weight);
        while (int(dd[neighbor].size()) > d[neighbor] + 1) {
          dd[neighbor].erase(prev(end(dd[neighbor])));
        }
        if (int(dd[neighbor].size()) > d[neighbor]) {
          assert(q.find(neighbor) == q.end());
          q.insert(neighbor);
        }
      }
    }
    if (ret[0] >= inf)
      cout << -1 << '\n';
    else
      cout << ret[0] << '\n';
  }
}

詳細信息

answer.code: In lambda function:
answer.code:37:26: error: no matching function for call to ‘end(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)’
   37 |       auto dx = *prev(end(dd[x]));
      |                       ~~~^~~~~~~
In file included from /usr/include/c++/13/bits/algorithmfwd.h:39,
                 from /usr/include/c++/13/bits/stl_algo.h:59,
                 from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:1:
/usr/include/c++/13/initializer_list:99:5: note: candidate: ‘template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)’
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
/usr/include/c++/13/initializer_list:99:5: note:   template argument deduction/substitution failed:
answer.code:37:26: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘long long int’
   37 |       auto dx = *prev(end(dd[x]));
      |                       ~~~^~~~~~~
In file included from /usr/include/c++/13/string:53,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52:
/usr/include/c++/13/bits/range_access.h:74:5: note: candidate: ‘template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)’
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/13/bits/range_access.h:74:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/range_access.h: In substitution of ‘template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&) [with _Container = long long int]’:
answer.code:37:26:   required from here
/usr/include/c++/13/bits/range_access.h:74:48: error: request for member ‘end’ in ‘__cont’, which is of non-class type ‘long long int’
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |                                         ~~~~~~~^~~
/usr/include/c++/13/bits/range_access.h:85:5: note: candidate: ‘template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)’
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/13/bits/range_access.h:85:5: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/range_access.h: In substitution of ‘template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&) [with _Container = long long int]’:
answer.code:37:26:   required from here
/usr/include/c++/13/bits/range_access.h:85:54: error: request for member ‘end’ in ‘__cont’, which is of non-class type ‘const long long int’
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |                                               ~~~~~~~^~~
/usr/include/c++/13/bits/range_access.h:106:5: note: candidate: ‘template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])’
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/13/bits/range_access.h:106:5: note:   template argument deduction/substitution failed:
answer.code:37:26: note:   mismatched types ‘_Tp [_Nm]’ and ‘__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type’ {aka ‘long long int’}
   37 |       auto dx = *prev(end(dd[x]));
      |                       ~~~^~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:166:
/usr/include/c++/13/valarray:1243:5: note: candidate: ‘template<class _Tp> _Tp* std::end(valarray<_Tp>&)’
 1243 |     end(valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/13/valarray:1243:5: note:   template argument deduction/substitution failed:
answer.code:37:26: note:   mismatched types ‘std::valarray<_Tp>’ and ‘__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type’ {aka ‘long long int’}
   37 |       auto dx = *prev(end(dd[x]));
      |                       ~~~^~~~~~~
/usr/include/c++/13/valarray:1259:5: note: candidate: ‘template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)’
 1259 |     end(const valarray<_Tp>& __va) noexcept
      |     ^~~
/usr/include/c++/13/valarray:1259:5: note:   template argument deduction/substitution failed:
answer.code:37:26: note:   mismatched types ‘const std::valarray<_Tp>’ and ‘__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type’ {aka ‘long long int’}
   37 |       auto dx = *prev(end(dd[x]));
      |                       ~~~^~~~~~~
answer.code:38:26: error: no matching function for call to ‘end(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)’
   38 |       auto dy = *prev(end(dd[y]));
      |                       ~~~^~~~~~~
/usr/include/c++/13/initializer_list:99:5: note: candidate: ‘template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)’
   99 |     end(initializer_list<_Tp> __il...