QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#376835#3161. Another Coin Weighing Puzzleckiseki#Compile Error//C++202.1kb2024-04-04 17:15:052024-04-04 17:15:05

Judging History

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

  • [2024-04-04 17:15:05]
  • 评测
  • [2024-04-04 17:15:05]
  • 提交

answer

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

#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << "\n";
#define debug(a...) debug_(#a, a)
#define orange(a...) orange_(#a, a)
void debug_(auto s, auto ...a) {
  cerr << "\e[1;32m(" << s << ") = (";
  int f = 0;
  (..., (cerr << (f++ ? ", " : "") << a));
  cerr << ")\e[0m\n";
}
#include <experimental/iterator>
void orange_(auto s, auto L, auto R) {
  cerr << "\e[1;33m[ " << s << " ] = [ ";
  using namespace experimental;
  copy(L, R, make_ostream_joiner(cerr, ", "));
  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);


  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; i++)
    cin >> a[i];


  using VI = vector<int>;
  set<VI> dp[11];

  vector<long long> wei(n + 1, 1);

  for (int i = 1; i < n; i++) {
    wei[i + 1] = n / i;
  }
  for (int i = 1; i <= n; i++)
    wei[i] *= wei[i - 1];

  dp[0].insert(wei[n]);

  for (int i = 0; i < m; i++) {
    for (auto v : dp[i]) {
      vector<set<long long>> cur(a[i] + 1);
      cur[0].insert(0);

      // vector<size_t> sizes;
      for (size_t j = 0; j < v.size(); j++) {
        vector<set<VI>> nxt(a[i] + 1);
        for (int y = 0; y <= v[j]; y++) {
          for (int x = 0; x + y <= a[i]; x++) {
            for (auto u : cur[x]) {
              if (y)
                u.push_back(y);
              if (v[j] - y)
                u.push_back(v[j] - y);
              sort(all(u));
              nxt[x + y].insert(u);
            }
          }
        }

        cur = nxt;
        // size_t s = 0;
        // for (int x = 0; x <= a[i]; x++)
        //   s += cur[x].size();
        // sizes.push_back(s);
      }

      for (auto u : cur[a[i]]) {
        dp[i + 1].insert(u);
      }
    }
    debug(dp[i].size());
  }

  debug(dp[m].size());

  int ans = 0;
  for (auto v : dp[m]) {
    int cnt = 0;
    for (int x : v)
      if (x == 1)
        ++cnt;
    ans = max(ans, cnt);
  }
  cout << ans << '\n';

  return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:50:15: error: no matching function for call to ‘std::set<std::vector<int> >::insert(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)’
   50 |   dp[0].insert(wei[n]);
      |   ~~~~~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/13/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:158,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_set.h:568:9: note: candidate: ‘template<class _InputIterator> void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _Key = std::vector<int>; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::vector<int> >]’
  568 |         insert(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~
/usr/include/c++/13/bits/stl_set.h:568:9: note:   template argument deduction/substitution failed:
answer.code:50:15: note:   candidate expects 2 arguments, 1 provided
   50 |   dp[0].insert(wei[n]);
      |   ~~~~~~~~~~~~^~~~~~~~
/usr/include/c++/13/bits/stl_set.h:511:7: note: candidate: ‘std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::vector<int>; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::vector<int> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::vector<int>, std::vector<int>, std::_Identity<std::vector<int> >, std::less<std::vector<int> >, std::allocator<std::vector<int> > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::vector<int> >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::rebind<std::vector<int> >; typename _Alloc::value_type = std::vector<int>; value_type = std::vector<int>]’
  511 |       insert(const value_type& __x)
      |       ^~~~~~
/usr/include/c++/13/bits/stl_set.h:511:32: note:   no known conversion for argument 1 from ‘__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type’ {aka ‘long long int’} to ‘const std::set<std::vector<int> >::value_type&’ {aka ‘const std::vector<int>&’}
  511 |       insert(const value_type& __x)
      |              ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_set.h:520:7: note: candidate: ‘std::pair<typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator, bool> std::set<_Key, _Compare, _Alloc>::insert(value_type&&) [with _Key = std::vector<int>; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::vector<int> >; typename std::_Rb_tree<_Key, _Key, std::_Identity<_Tp>, _Compare, typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other>::const_iterator = std::_Rb_tree<std::vector<int>, std::vector<int>, std::_Identity<std::vector<int> >, std::less<std::vector<int> >, std::allocator<std::vector<int> > >::const_iterator; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key>::other = std::allocator<std::vector<int> >; typename __gnu_cxx::__alloc_traits<_Alloc>::rebind<_Key> = __gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::rebind<std::vector<int> >; typename _Alloc::value_type = std::vector<int>; value_type = std::vector<int>]’
  520 |       insert(value_type&& __x)
      |       ^~~~~~
/usr/include/c++/13/bits/stl_set.h:520:27: note:   no known conversion for argument 1 from ‘__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type’ {aka ‘long long int’} to ‘std::set<std::vector<int> >::value_type&&’ {aka ‘std::vector<int>&&’}
  520 |       insert(value_type&& __x)
      |              ~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_set.h:548:7: note: candidate: ‘std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::insert(const_iterator, const value_type&) [with _Key = std::vector<int>; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::vector<int> >; iterator = std::_Rb_tree<std::vector<int>, std::vector<int>, std::_Identity<std::vector<int> >, std::less<std::vector<int> >, std::allocator<std::vector<int> > >::const_iterator; const_iterator = std::_Rb_tree<std::vector<int>, std::vector<int>, std::_Identity<std::vector<int> >, std::less<std::vector<int> >, std::allocator<std::vector<int> > >::const_iterator; value_type = std::vector<int>]’
  548 |       insert(const_iterator __position, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/13/bits/stl_set.h:548:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/13/bits/stl_set.h:553:7: note: candidate: ‘std::set<_Key, _Compare, _Alloc>::i...