QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#278262#5065. Beautiful Stringhhoppitree#Compile Error//C++141.6kb2023-12-07 14:24:182023-12-07 14:24:18

Judging History

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

  • [2023-12-07 14:24:18]
  • 评测
  • [2023-12-07 14:24:18]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=5010;
int lcp[N][N];
int F[N][N];
int T,n;
char s[N];
const __int128 P=1e18+9;
__int128 h[N],B=10;
unordered_map<__int128,int>M;
int main()
{
    cin>>T;
    while(T--)
    {
        cin>>s+1;n=strlen(s+1);
        memset(lcp,0,sizeof lcp);
        memset(F,0,sizeof F);
        for(int i=n;i;--i)
            for(int j=n;j;--j)
                lcp[i][j]=(lcp[i+1][j+1]+1)*(s[i]==s[j]);
        for(int i=1;i<=n;++i)
            for(int j=1;j<=n&&j<=i&&j+i-1<=n;++j)
                F[i][j]=lcp[i][i-j]>=j;
        // for(int i=1;i<=n;++i)
        //     for(int j=1;j<=n;++j)
        //         cerr<<"F["<<i<<"]["<<j<<"]="<<F[i][j]<<endl;
        for(int i=1;i<=n;++i)
            for(int j=1;j<=n;++j)
                F[i][j]+=F[i][j-1];
        for(int i=1;i<=n;++i)s[i]-='0';
        long long ans=0;
        for(int d=1;d<=n;++d)
        {
            int p=1;M.clear();
            __int128 up=0,b=1;
            for(int i=1;i<=d;++i)b=b*B%P;
            for(int i=1;i<d;++i)up=(up*B+s[i])%P;
            for(int i=1,j=d;j<=n;++i,++j)
            {
                while(p<i-d)
                {
                    M[h[p]]+=F[p][d-1];
                    // cerr<<"ADD: "<<p<<" "<<(long long)h[p]<<" "<<F[p][d-1]<<endl;
                    ++p;
                }
                up=(up*B+s[j])%P;
                if(i!=1)up=(up-b*s[i-1]%P+P)%P;
                // cerr<<"RANGE: "<<i<<" "<<j<<" "<<(long long)up<<" "<<M[up]<<endl;
                h[i]=up;
                ans+=M[h[i]];
            }
        }
        cout<<ans<<endl;
    }
}

Details

answer.code:10:28: error: use of deleted function ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = __int128; _Tp = int; _Hash = std::hash<__int128>; _Pred = std::equal_to<__int128>; _Alloc = std::allocator<std::pair<const __int128, int> >]’
   10 | unordered_map<__int128,int>M;
      |                            ^
In file included from /usr/include/c++/11/unordered_map:47,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:117,
                 from answer.code:1:
/usr/include/c++/11/bits/unordered_map.h:141:7: note: ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = __int128; _Tp = int; _Hash = std::hash<__int128>; _Pred = std::equal_to<__int128>; _Alloc = std::allocator<std::pair<const __int128, int> >]’ is implicitly deleted because the default definition would be ill-formed:
  141 |       unordered_map() = default;
      |       ^~~~~~~~~~~~~
/usr/include/c++/11/bits/unordered_map.h:141:7: error: use of deleted function ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = __int128; _Value = std::pair<const __int128, int>; _Alloc = std::allocator<std::pair<const __int128, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<__int128>; _Hash = std::hash<__int128>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’
In file included from /usr/include/c++/11/unordered_map:46,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:117,
                 from answer.code:1:
/usr/include/c++/11/bits/hashtable.h:528:7: note: ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = __int128; _Value = std::pair<const __int128, int>; _Alloc = std::allocator<std::pair<const __int128, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<__int128>; _Hash = std::hash<__int128>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’ is implicitly deleted because the default definition would be ill-formed:
  528 |       _Hashtable() = default;
      |       ^~~~~~~~~~
/usr/include/c++/11/bits/hashtable.h:528:7: error: use of deleted function ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = __int128; _Value = std::pair<const __int128, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<__int128>; _Hash = std::hash<__int128>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’
In file included from /usr/include/c++/11/bits/hashtable.h:35,
                 from /usr/include/c++/11/unordered_map:46,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:117,
                 from answer.code:1:
/usr/include/c++/11/bits/hashtable_policy.h:1604:7: note: ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = __int128; _Value = std::pair<const __int128, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<__int128>; _Hash = std::hash<__int128>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]’ is implicitly deleted because the default definition would be ill-formed:
 1604 |       _Hashtable_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/11/bits/hashtable_policy.h:1604:7: error: use of deleted function ‘std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = __int128; _Value = std::pair<const __int128, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<__int128>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]’
/usr/include/c++/11/bits/hashtable_policy.h: In instantiation of ‘std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<__int128>]’:
/usr/include/c++/11/bits/hashtable_policy.h:1210:7:   required from here
/usr/include/c++/11/bits/hashtable_policy.h:1127:49: error: use of deleted function ‘std::hash<__int128>::hash()’
 1127 |       _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
      |                                                 ^~~~~
In file included from /usr/include/c++/11/bits/basic_string.h:6860,
            ...