Submission #235867

# Submission time Handle Problem Language Result Execution time Memory
235867 2020-05-30T08:31:36 Z balbit Palindromes (APIO14_palindrome) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define pii pair<int, int>
#define f first
#define s second

#define REP(i,n) for (int i = 0; i<n; ++i)
#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<": ", _do(__VA_ARGS__)
template<typename T> void _do(T && x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T && x, S&&...y){cerr<<x<<", "; _do(y...);}
#define IOS()
#else
#define IOS() ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define bug(...)
#endif // BALBIT

#define SZ(x) (int)(x.size())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back

const int B = 37;
const ll mod = 1e9+87;
const int maxn = 3e5;
ll hv[maxn];
ll pB[maxn], ipB[maxn];

ll inv(ll b) {
    if (b == 1)return 1;
    return inv(mod%b) * (mod-mod/b) % mod;
}



signed main(){
    IOS();

    gp_hash_table <ll, int> mp;
    string s;cin>>s;
    int n = SZ(s);
    pB[0] = ipB[0] = 1;
    for (int i = 1; i<=n; ++i) {
        pB[i] = pB[i-1] * B % mod;
        ipB[i] = inv(pB[i]);
    }
    bug(pB[2] * ipB[2] % mod);
    for (int i = 0; i<n; ++i) {
        hv[i+1] = hv[i] + pB[i] * (s[i] - 'a'+1); hv[i+1] %= mod;

    }

    for (int i = 0; i<n; ++i) {
        for (int j = 0; i-j>=0 && i+j < n && s[i-j] == s[i+j]; ++j) {
            mp[ (hv[i+j+1] - hv[i-j] + mod) % mod * ipB[i-j] % mod] += (j*2+1);
        }
        for (int j = 0; i-j>=0 && i+j+1 < n && s[i-j] == s[i+j+1]; ++j) {
            mp[ (hv[i+j+1+1] - hv[i-j] + mod) % mod * ipB[i-j]  % mod] += (j*2+2);
            bug(j*2+2, (hv[i+j+1+1] - hv[i-j] + mod) % mod * ipB[i-j] % mod);
        }
    }
    ll re = 0;
    for (auto x : mp) {
        re = max(re, x.s);
    }
    cout<<re<<endl;

}

Compilation message

palindrome.cpp: In function 'int main()':
palindrome.cpp:68:25: error: no matching function for call to 'max(long long int&, int&)'
         re = max(re, x.s);
                         ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from palindrome.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
palindrome.cpp:68:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
         re = max(re, x.s);
                         ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from palindrome.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
palindrome.cpp:68:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
         re = max(re, x.s);
                         ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from palindrome.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
palindrome.cpp:68:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
         re = max(re, x.s);
                         ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from palindrome.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
palindrome.cpp:68:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
         re = max(re, x.s);
                         ^