Submission #1305754

#TimeUsernameProblemLanguageResultExecution timeMemory
1305754hackstarHack (APIO25_hack)C++20
Compilation error
0 ms0 KiB
#include "hack.h"
#include <bits/stdc++.h>
using namespace std;
#define ll int

int hack(){
    int low = 1;
    int high = 1e9;
    map<vector<ll>,int>cache;
    while(low<high){
        int mid = (low+high)/2;
        int s = sqrt(mid-low+1);
        vector<long long> query;
        for(int i=0;i<s;i++){
            query.push_back(i+1);
        }
        for(int i=0;low+s*(i+1)<=mid;i++){
            query.push_back(low+s*(i+1));
        }
        query.push_back(mid+1);
        int curr;
        				if(cache.count(query))
        						curr=cache[query];
        				else
        				{
        						curr=collisions(query);
        						cache[query]=curr;
        				}
        if(curr){
            high = mid;
        }
        else{
            low = mid+1;
        }
    }
    return low;
}

Compilation message (stderr)

hack.cpp: In function 'int hack()':
hack.cpp:22:55: error: no matching function for call to 'std::map<std::vector<int>, int>::count(std::vector<long long int>&)'
   22 |                                         if(cache.count(query))
      |                                            ~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/13/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:152,
                 from hack.cpp:2:
/usr/include/c++/13/bits/stl_map.h:1271:9: note: candidate: 'template<class _Kt> decltype (((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::count(const _Kt&) const [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >]'
 1271 |         count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
      |         ^~~~~
/usr/include/c++/13/bits/stl_map.h:1271:9: note:   template argument deduction/substitution failed:
/usr/include/c++/13/bits/stl_map.h: In substitution of 'template<class _Kt> decltype (((const std::map<std::vector<int>, int>*)this)->std::map<std::vector<int>, int>::_M_t.std::_Rb_tree<std::vector<int>, std::pair<const std::vector<int>, int>, std::_Select1st<std::pair<const std::vector<int>, int> >, std::less<std::vector<int> >, std::allocator<std::pair<const std::vector<int>, int> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<std::vector<int>, int>::count(const _Kt&) const [with _Kt = std::vector<long long int>]':
hack.cpp:22:27:   required from here
/usr/include/c++/13/bits/stl_map.h:1271:65: error: no matching function for call to 'std::_Rb_tree<std::vector<int>, std::pair<const std::vector<int>, int>, std::_Select1st<std::pair<const std::vector<int>, int> >, std::less<std::vector<int> >, std::allocator<std::pair<const std::vector<int>, int> > >::_M_count_tr(const std::vector<long long int>&) const'
 1271 |         count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
      |                                                 ~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/13/map:62:
/usr/include/c++/13/bits/stl_tree.h:1315:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_count_tr(const _Kt&) const [with _Req = _Kt; _Key = std::vector<int>; _Val = std::pair<const std::vector<int>, int>; _KeyOfValue = std::_Select1st<std::pair<const std::vector<int>, int> >; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >]'
 1315 |         _M_count_tr(const _Kt& __k) const
      |         ^~~~~~~~~~~
/usr/include/c++/13/bits/stl_tree.h:1315:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/13/bits/refwrap.h:39,
                 from /usr/include/c++/13/vector:68,
                 from hack.h:1,
                 from hack.cpp:1:
/usr/include/c++/13/bits/stl_function.h: In substitution of 'template<class _Func, class _SfinaeType> using std::__has_is_transparent_t = typename std::__has_is_transparent<_Func, _SfinaeType>::type [with _Func = std::less<std::vector<int> >; _SfinaeType = std::vector<long long int>]':
/usr/include/c++/13/bits/stl_tree.h:1313:9:   required by substitution of 'template<class _Kt> decltype (((const std::map<std::vector<int>, int>*)this)->std::map<std::vector<int>, int>::_M_t.std::_Rb_tree<std::vector<int>, std::pair<const std::vector<int>, int>, std::_Select1st<std::pair<const std::vector<int>, int> >, std::less<std::vector<int> >, std::allocator<std::pair<const std::vector<int>, int> > >::_M_count_tr<_Kt, _Req>(__x)) std::map<std::vector<int>, int>::count(const _Kt&) const [with _Kt = std::vector<long long int>]'
hack.cpp:22:27:   required from here
/usr/include/c++/13/bits/stl_function.h:1430:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<std::vector<int> >, std::vector<long long int>, void>'
 1430 |     using __has_is_transparent_t
      |           ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_map.h:1265:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::size_type std::map<_Key, _Tp, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; size_type = long unsigned int; key_type = std::vector<int>]'
 1265 |       count(const key_type& __x) const
      |       ^~~~~
/usr/include/c++/13/bits/stl_map.h:1265:29: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const std::map<std::vector<int>, int>::key_type&' {aka 'const std::vector<int>&'}
 1265 |       count(const key_type& __x) const
      |             ~~~~~~~~~~~~~~~~^~~
hack.cpp:23:67: error: no match for 'operator[]' (operand types are 'std::map<std::vector<int>, int>' and 'std::vector<long long int>')
   23 |                                                         curr=cache[query];
      |                                                                   ^
/usr/include/c++/13/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; mapped_type = int; key_type = std::vector<int>]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const std::map<std::vector<int>, int>::key_type&' {aka 'const std::vector<int>&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; mapped_type = int; key_type = std::vector<int>]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::map<std::vector<int>, int>::key_type&&' {aka 'std::vector<int>&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
hack.cpp:27:62: error: no match for 'operator[]' (operand types are 'std::map<std::vector<int>, int>' and 'std::vector<long long int>')
   27 |                                                         cache[query]=curr;
      |                                                              ^
/usr/include/c++/13/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; mapped_type = int; key_type = std::vector<int>]'
  504 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_map.h:504:34: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const std::map<std::vector<int>, int>::key_type&' {aka 'const std::vector<int>&'}
  504 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::vector<int>; _Tp = int; _Compare = std::less<std::vector<int> >; _Alloc = std::allocator<std::pair<const std::vector<int>, int> >; mapped_type = int; key_type = std::vector<int>]'
  524 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/13/bits/stl_map.h:524:29: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::map<std::vector<int>, int>::key_type&&' {aka 'std::vector<int>&&'}
  524 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~