QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#501386#7876. Cyclic SubstringsemtCompile Error//C++203.1kb2024-08-02 17:39:302024-08-02 17:39:30

Judging History

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

  • [2024-08-02 17:39:30]
  • 评测
  • [2024-08-02 17:39:30]
  • 提交

answer

// #pragma GCC optimize(3)
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using ld = long double;
using i128 = __int128_t;
using u128 = __uint128_t;
#define int long long
#define mem(a, b) memset((a), (b), sizeof(a))
#define all(a) (a).begin(), (a).end()
#define inf 0x3f3f3f3f
#define lowbit(x) (-x) & x
#define debug cout<<"$"
#define ls u << 1
#define rs u << 1 | 1
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
using pii = pair<int,int>;
mt19937 rnd(time(0));
const int MOD = 998244353;
const ld eps = 1;
int qmi(int m, int k){int res = 1, t = m;while (k){if (k & 1) res = (res * t) % MOD;t = t * t % MOD;k >>= 1;}return res;}
const int N = 6e6 + 7;
const int P = 13331;


struct mana
{
    char s[N];
    int k = 0;
    int d[N]; // 回文半径函数
    void init(string t)
    {
        int n = t.size()-1;
        s[0] = '$', s[++k] = '#';
        for (int i = 1; i <= n; i++)
            s[++k] = t[i], s[++k] = '#';
    }
    void get_d(){
    d[1]=1;
        for(int i=2,l,r=1;i<=k;i++){
            if(i<=r)d[i]=min(d[r-i+l],r-i+1);
            while(s[i-d[i]]==s[i+d[i]])d[i]++;
            if(i+d[i]-1>r)l=i-d[i]+1,r=i+d[i]-1;
        }  
    }
}man[2];


u128 h[N], p[N]; 
u128 get(int l, int r)
{
    return h[r] - h[l - 1] * p[r - l + 1];
}
void solve()
{
    int n;
    string s0;
    cin>>n>>s0;
    int t = n;
    man[1].init(" "+s0);
    s0 = " " + s0 + s0;
    man[0].init(s0);
    map<pair<int,u128>,int> ma;
    p[0] = 1;
    for (int i = 1; i <= 2*n; i ++ )
    {
        h[i] = h[i - 1] * P + s0[i];
        p[i] = p[i - 1] * P;
    }
    man[0].get_d(); 
    man[1].get_d(); 
    unordered_map<u128,u128> mb;
    for(int q=0;q<2;q++)
    for (int i = 2; i <= man[q].k; i++)
    {
        int len;
        int l,r;
        if(i&1)
        {
            len = min(t/2*2,man[q].d[i]-1);
            l = i/2-(len/2-1);
            r = i/2+(len/2-1)+1;
        }
        else 
        {
            len = min(((t-1)/2*2+1),man[q].d[i]-1);
            l = i/2-len/2;
            r = i/2+len/2;
        }
        if(!len)    continue;
        auto z = get(l,r);
        // debug<<i<<"\n";
        // debug<<l<<" "<<r<<" "<<len<<" "<<q<<"\n";
        ma[{-len,z}] += (q?-1:1);
        while(!mb.count(z)&&l<=r)
        {
            l++,r--;
            auto t = get(l,r);
            mb[z] = t;
            z = t;
        }
    }   
    int ans = 0;
    // for(auto [c,d]:ma)
    // {
    //     auto [len,hash] = c;
    //     debug<<len<<" "<<(int)hash<<" "<<d<<"\n";
    // }
    while(ma.size())
    {
        auto [c,d] = *ma.begin();
        ma.erase(ma.begin());
        auto [len,hash] = c;
        ans += (-len)*d%MOD*d%MOD;
        ans %= MOD;
        if(-len>=2)
            ma[{len+2,mb[hash]}]+=d;
    }
    cout<<ans;
}   

signed main()
{
    // freopen("test.in","r",stdin);
    // freopen("test.out","w",stdout);
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
    int T = 1;
    // cin>>T;
    while (T--)
        solve();
}
/*
6677667766776677
*/

Details

answer.code: In function ‘void solve()’:
answer.code:73:30: error: use of deleted function ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = __int128 unsigned; _Tp = __int128 unsigned; _Hash = std::hash<__int128 unsigned>; _Pred = std::equal_to<__int128 unsigned>; _Alloc = std::allocator<std::pair<const __int128 unsigned, __int128 unsigned> >]’
   73 |     unordered_map<u128,u128> mb;
      |                              ^~
In file included from /usr/include/c++/13/unordered_map:41,
                 from /usr/include/c++/13/functional:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53,
                 from answer.code:2:
/usr/include/c++/13/bits/unordered_map.h:148:7: note: ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = __int128 unsigned; _Tp = __int128 unsigned; _Hash = std::hash<__int128 unsigned>; _Pred = std::equal_to<__int128 unsigned>; _Alloc = std::allocator<std::pair<const __int128 unsigned, __int128 unsigned> >]’ is implicitly deleted because the default definition would be ill-formed:
  148 |       unordered_map() = default;
      |       ^~~~~~~~~~~~~
/usr/include/c++/13/bits/unordered_map.h:148:7: error: use of deleted function ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = __int128 unsigned; _Value = std::pair<const __int128 unsigned, __int128 unsigned>; _Alloc = std::allocator<std::pair<const __int128 unsigned, __int128 unsigned> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<__int128 unsigned>; _Hash = std::hash<__int128 unsigned>; _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++/13/bits/unordered_map.h:33:
/usr/include/c++/13/bits/hashtable.h:530:7: note: ‘std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = __int128 unsigned; _Value = std::pair<const __int128 unsigned, __int128 unsigned>; _Alloc = std::allocator<std::pair<const __int128 unsigned, __int128 unsigned> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<__int128 unsigned>; _Hash = std::hash<__int128 unsigned>; _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:
  530 |       _Hashtable() = default;
      |       ^~~~~~~~~~
/usr/include/c++/13/bits/hashtable.h:530:7: error: use of deleted function ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = __int128 unsigned; _Value = std::pair<const __int128 unsigned, __int128 unsigned>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<__int128 unsigned>; _Hash = std::hash<__int128 unsigned>; _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++/13/bits/hashtable.h:35:
/usr/include/c++/13/bits/hashtable_policy.h:1710:7: note: ‘std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = __int128 unsigned; _Value = std::pair<const __int128 unsigned, __int128 unsigned>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<__int128 unsigned>; _Hash = std::hash<__int128 unsigned>; _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:
 1710 |       _Hashtable_base() = default;
      |       ^~~~~~~~~~~~~~~
/usr/include/c++/13/bits/hashtable_policy.h:1710: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 unsigned; _Value = std::pair<const __int128 unsigned, __int128 unsigned>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<__int128 unsigned>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]’
/usr/include/c++/13/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 unsigned>]’:
/usr/include/c++/13/bits/hashtable_policy.h:1297:7:   required from here
/usr/include/c++/13/bits/hashtable_policy.h:1214:49: error: use of deleted function ‘std...