Submission #161136

#TimeUsernameProblemLanguageResultExecution timeMemory
161136errorgornJOIOJI (JOI14_joioji)C++14
Compilation error
0 ms0 KiB
#include <cstdio> #include <unordered_map> #include <utility> #include <string> #include <iostream> #include <cstring> #include <algorithm> using namespace std; typedef pair<int,int> ii; int n; char c; string s; class custom_hash{ class custom_hash{ public: template <typename T, typename U> size_t operator()(const pair<T,U> &i)const{ return std::hash<T>()(i.first) ^ std::hash<U>()(i.second); } }; unordered_map<ii,int,custom_hash> suffix; int arr[3]; int pre[3]; int main(){ suffix.reserve(4096); suffix.max_load_factor(0.25); //freopen("input.txt","r",stdin); scanf("%d",&n); getchar(); c=getchar(); while (c!='\n'){ s+=c; if (c=='J') arr[0]++; else if (c=='O') arr[1]++; else arr[2]++; c=getchar(); } suffix[ii(0,0)]=0; for (int x=0;x<3;x++) pre[x]=arr[x]; for (int x=0;x<s.size();x++){ if (s[x]=='J') pre[0]--; else if (s[x]=='O') pre[1]--; else pre[2]--; suffix[ii(pre[0]-pre[1],pre[0]-pre[2])]=x+1; } memset(pre,0,sizeof(pre)); int ans=0; int a=arr[0]-arr[1],b=arr[0]-arr[2]; for (int x=0;x<s.size();x++){ ans=max(ans,suffix[ii(a-(pre[0]-pre[1]),b-(pre[0]-pre[2]))]-x); if (s[x]=='J') pre[0]++; else if (s[x]=='O') pre[1]++; else pre[2]++; } printf("%d\n",ans); }

Compilation message (stderr)

joioji.cpp:14:7: error: 'custom_hash::custom_hash' has the same name as the class in which it is declared
 class custom_hash{
       ^~~~~~~~~~~
In file included from /usr/include/c++/7/bits/hashtable.h:35:0,
                 from /usr/include/c++/7/unordered_map:47,
                 from joioji.cpp:2:
/usr/include/c++/7/bits/hashtable_policy.h: In instantiation of 'struct std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash>':
/usr/include/c++/7/type_traits:143:12:   required from 'struct std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> >'
/usr/include/c++/7/type_traits:154:31:   required from 'struct std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
/usr/include/c++/7/bits/unordered_map.h:103:66:   required from 'class std::unordered_map<std::pair<int, int>, int, custom_hash>'
joioji.cpp:21:47:   required from here
/usr/include/c++/7/bits/hashtable_policy.h:87:34: error: no match for call to '(const custom_hash) (const std::pair<int, int>&)'
  noexcept(declval<const _Hash&>()(declval<const _Key&>()))>
           ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/bits/move.h:54:0,
                 from /usr/include/c++/7/bits/stl_pair.h:59,
                 from /usr/include/c++/7/utility:70,
                 from /usr/include/c++/7/unordered_map:38,
                 from joioji.cpp:2:
/usr/include/c++/7/type_traits: In instantiation of 'struct std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >':
/usr/include/c++/7/bits/unordered_map.h:103:66:   required from 'class std::unordered_map<std::pair<int, int>, int, custom_hash>'
joioji.cpp:21:47:   required from here
/usr/include/c++/7/type_traits:154:31: error: 'value' is not a member of 'std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> >'
     : public __bool_constant<!bool(_Pp::value)>
                               ^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/unordered_map:48:0,
                 from joioji.cpp:2:
/usr/include/c++/7/bits/unordered_map.h: In instantiation of 'class std::unordered_map<std::pair<int, int>, int, custom_hash>':
joioji.cpp:21:47:   required from here
/usr/include/c++/7/bits/unordered_map.h:103:66: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc>  _Hashtable;
                                                                  ^~~~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:110:45: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::key_type key_type;
                                             ^~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:111:47: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::value_type value_type;
                                               ^~~~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:112:48: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::mapped_type mapped_type;
                                                ^~~~~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:113:43: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::hasher hasher;
                                           ^~~~~~
/usr/include/c++/7/bits/unordered_map.h:114:46: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::key_equal key_equal;
                                              ^~~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:115:51: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::allocator_type allocator_type;
                                                   ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:120:45: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::pointer  pointer;
                                             ^~~~~~~
/usr/include/c++/7/bits/unordered_map.h:121:50: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::const_pointer const_pointer;
                                                  ^~~~~~~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:122:47: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::reference  reference;
                                               ^~~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:123:52: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::const_reference const_reference;
                                                    ^~~~~~~~~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:124:46: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::iterator  iterator;
                                              ^~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:125:51: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::const_iterator const_iterator;
                                                   ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:126:51: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::local_iterator local_iterator;
                                                   ^~~~~~~~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:127:57: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::const_local_iterator const_local_iterator;
                                                         ^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:128:47: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::size_type  size_type;
                                               ^~~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:129:52: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       typedef typename _Hashtable::difference_type difference_type;
                                                    ^~~~~~~~~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:288:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       operator=(initializer_list<value_type> __l)
       ^~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:386:2: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
  emplace(_Args&&... __args)
  ^~~~~~~
/usr/include/c++/7/bits/unordered_map.h:578:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       insert(const value_type& __x)
       ^~~~~~
/usr/include/c++/7/bits/unordered_map.h:584:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       insert(value_type&& __x)
       ^~~~~~
/usr/include/c++/7/bits/unordered_map.h:591:2: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
  insert(_Pair&& __x)
  ^~~~~~
/usr/include/c++/7/bits/unordered_map.h:657:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       insert(initializer_list<value_type> __l)
       ^~~~~~
/usr/include/c++/7/bits/unordered_map.h:953:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       equal_range(const key_type& __x)
       ^~~~~~~~~~~
/usr/include/c++/7/bits/unordered_map.h:957:7: error: 'value' is not a member of 'std::__not_<std::__and_<std::__is_fast_hash<custom_hash>, std::__detail::__is_noexcept_hash<std::pair<int, int>, custom_hash> > >'
       equal_range(const key_type& __x) const
       ^~~~~~~~~~~
joioji.cpp:56:13: error: expected '}' at end of input
             }
             ^
joioji.cpp: In member function 'int custom_hash::main()':
joioji.cpp:25:24: error: 'class std::unordered_map<std::pair<int, int>, int, custom_hash>' has no member named 'reserve'
                 suffix.reserve(4096);
                        ^~~~~~~
joioji.cpp:38:23: error: no match for 'operator[]' (operand types are 'std::unordered_map<std::pair<int, int>, int, custom_hash>' and 'ii {aka std::pair<int, int>}')
                 suffix[ii(0,0)]=0;
                       ^
joioji.cpp:40:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for (int x=0;x<s.size();x++){
                              ~^~~~~~~~~
joioji.cpp:44:27: error: no match for 'operator[]' (operand types are 'std::unordered_map<std::pair<int, int>, int, custom_hash>' and 'ii {aka std::pair<int, int>}')
                     suffix[ii(pre[0]-pre[1],pre[0]-pre[2])]=x+1;
                           ^
joioji.cpp:49:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for (int x=0;x<s.size();x++){
                              ~^~~~~~~~~
joioji.cpp:50:39: error: no match for 'operator[]' (operand types are 'std::unordered_map<std::pair<int, int>, int, custom_hash>' and 'ii {aka std::pair<int, int>}')
                     ans=max(ans,suffix[ii(a-(pre[0]-pre[1]),b-(pre[0]-pre[2]))]-x);
                                       ^
joioji.cpp:56:13: warning: no return statement in function returning non-void [-Wreturn-type]
             }
             ^
joioji.cpp: At global scope:
joioji.cpp:56:13: error: expected unqualified-id at end of input
In file included from /usr/include/c++/7/unordered_map:48:0,
                 from joioji.cpp:2:
/usr/include/c++/7/bits/unordered_map.h: In instantiation of 'void std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::max_load_factor(float) [with _Key = std::pair<int, int>; _Tp = int; _Hash = custom_hash; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]':
joioji.cpp:26:44:   required from here
/usr/include/c++/7/bits/unordered_map.h:1101:9: error: using invalid field 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::_M_h'
       { _M_h.max_load_factor(__z); }
         ^~~~