Submission #171991

# Submission time Handle Problem Language Result Execution time Memory
171991 2019-12-30T18:30:55 Z emil_physmath Bank (IZhO14_bank) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef double ldouble;
typedef long long llong;
typedef unsigned int uint;
const int maxN = 100001;

vector<uint> get[1001];

bool IsSet(uint mask, uint i)
{
    return mask & (1 << i);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (int& x: a)
        cin >> x;
    vector<int> b(m);
    for (int& x: b)
        cin >> x;
    for (uint mask = 0; mask < (1 << m); ++mask)
    {
        int curSum = 0;
        for (int i = 0; i < m; ++i)
            if (IsSet(mask, i))
                curSum += b[i];
        if (curSum <= 1000)
            get[curSum].push_back(mask);
    }
    set<uint> possLeft;
    for (uint mask = 0; mask < (1 << m); ++mask)
        possLeft.insert(mask);
    for (int i = 0; i < n; ++i)
    {
        // cerr << possLeft.size() << endl;
        set<uint> temp;
        for (uint left: possLeft)
        {
            for (uint mask: get[a[i]])
            {
                // cerr << "get " << a[i] << " with " << mask << endl;
                if ((mask & left) == mask)
                    temp.insert(left ^ mask);
            }
        }
        possLeft.swap(temp);
    }
    // cerr << possLeft.size() << endl;
    cout << (possLeft.size() ? "YES" : "NO") << endl;
}

Compilation message

bank.cpp: In function 'int main()':
bank.cpp:30:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (uint mask = 0; mask < (1 << m); ++mask)
                         ~~~~~^~~~~~~~~~
bank.cpp:37:13: error: reference to 'get' is ambiguous
             get[curSum].push_back(mask);
             ^~~
bank.cpp:10:14: note: candidates are: std::vector<unsigned int> get [1001]
 vector<uint> get[1001];
              ^~~
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from bank.cpp:2:
/usr/include/c++/7/utility:273:5: note:                 template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)
     get(pair<_Up, _Tp>&& __p) noexcept
     ^~~
/usr/include/c++/7/utility:268:5: note:                 template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)
     get(const pair<_Up, _Tp>& __p) noexcept
     ^~~
/usr/include/c++/7/utility:263:5: note:                 template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)
     get(pair<_Up, _Tp>& __p) noexcept
     ^~~
/usr/include/c++/7/utility:258:5: note:                 template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)
     get(pair<_Tp, _Up>&& __p) noexcept
     ^~~
/usr/include/c++/7/utility:253:5: note:                 template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)
     get(const pair<_Tp, _Up>& __p) noexcept
     ^~~
/usr/include/c++/7/utility:248:5: note:                 template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)
     get(pair<_Tp, _Up>& __p) noexcept
     ^~~
/usr/include/c++/7/utility:239:5: note:                 template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)
     get(const std::pair<_Tp1, _Tp2>& __in) noexcept
     ^~~
/usr/include/c++/7/utility:234:5: note:                 template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)
     get(std::pair<_Tp1, _Tp2>&& __in) noexcept
     ^~~
/usr/include/c++/7/utility:229:5: note:                 template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)
     get(std::pair<_Tp1, _Tp2>& __in) noexcept
     ^~~
bank.cpp:40:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (uint mask = 0; mask < (1 << m); ++mask)
                         ~~~~~^~~~~~~~~~
bank.cpp:48:29: error: reference to 'get' is ambiguous
             for (uint mask: get[a[i]])
                             ^~~
bank.cpp:10:14: note: candidates are: std::vector<unsigned int> get [1001]
 vector<uint> get[1001];
              ^~~
In file included from /usr/include/c++/7/bits/stl_uninitialized.h:60:0,
                 from /usr/include/c++/7/vector:63,
                 from bank.cpp:2:
/usr/include/c++/7/utility:273:5: note:                 template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_Up, _Tp>&&)
     get(pair<_Up, _Tp>&& __p) noexcept
     ^~~
/usr/include/c++/7/utility:268:5: note:                 template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_Up, _Tp>&)
     get(const pair<_Up, _Tp>& __p) noexcept
     ^~~
/usr/include/c++/7/utility:263:5: note:                 template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_Up, _Tp>&)
     get(pair<_Up, _Tp>& __p) noexcept
     ^~~
/usr/include/c++/7/utility:258:5: note:                 template<class _Tp, class _Up> constexpr _Tp&& std::get(std::pair<_T1, _T2>&&)
     get(pair<_Tp, _Up>&& __p) noexcept
     ^~~
/usr/include/c++/7/utility:253:5: note:                 template<class _Tp, class _Up> constexpr const _Tp& std::get(const std::pair<_T1, _T2>&)
     get(const pair<_Tp, _Up>& __p) noexcept
     ^~~
/usr/include/c++/7/utility:248:5: note:                 template<class _Tp, class _Up> constexpr _Tp& std::get(std::pair<_T1, _T2>&)
     get(pair<_Tp, _Up>& __p) noexcept
     ^~~
/usr/include/c++/7/utility:239:5: note:                 template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const std::pair<_Tp1, _Tp2>&)
     get(const std::pair<_Tp1, _Tp2>& __in) noexcept
     ^~~
/usr/include/c++/7/utility:234:5: note:                 template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(std::pair<_Tp1, _Tp2>&&)
     get(std::pair<_Tp1, _Tp2>&& __in) noexcept
     ^~~
/usr/include/c++/7/utility:229:5: note:                 template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(std::pair<_Tp1, _Tp2>&)
     get(std::pair<_Tp1, _Tp2>& __in) noexcept
     ^~~