Submission #655339

# Submission time Handle Problem Language Result Execution time Memory
655339 2022-11-03T21:18:07 Z xiryss Palindromes (APIO14_palindrome) C++17
100 / 100
25 ms 35108 KB
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,abm,mmx,popcnt")
#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")
//#pragma comment(linker,"/STACK:256777216")
/*
MMMMMMMMNNNNNNNNNNNNNNNNNNmNNNNNNNNNNNmmmmmmmmNNMMMMNMMMMMMMMMMMMMMMMMMMMMMMMNMMMMMMMMMMMMMMMMMMMMNNMMMNMMMMMMMMMMMMMMMMMMMMMMNNMMNNNNNNNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMNNNNNNNNNNNmNNNMMMMMMMMMMMMNNNNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNMNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMNNNNNNNNNNNNNNNNmmNNNNNNNNMMMMMMMMNmNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMNNNNNMMNNNNNNNNNNNNNNNNNNNNNMMMMMMMMNmNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMNNNNNMMNNNNNNmNNNNNNNMMMMMMMMMMMMMMMMNNMMMMMMMMM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MMMMMMMMMMMMMMNNNNNNNNNNNmsNNNNNNNNNNNNNNmmNNmNNNNNNNNmNNNmmmNNMMMMMMMMMMMN
ssssssyyysssyyyyyyyyyyy+:/so::syyymNNNmmNdNNNNNNNNNNNNhdNNNNNNNNNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNNNNNNNNNhsNNNNNNNNNNNNNNmNNNdNNNNNNNNmddddhmdNNNNNMNNNNNNN
oo++++oooooossssssssso/:/os/::+oosNNNNdNNdNNNNNNNNNNNNhymNNNNNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNNNNNNNmyyNNNNNNNNNNNNNNmNNNdNNNNNNNNmyyyhhhmdmmmNNmmmmddd
++////++oosssssssssso::/sss:::+++yNNNdNNNdNNNNNNNNNNNNhhyNNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNNNNNNyyyNNNNNNNNNNNNNNdNNNmmmmmmmmmmhdhddddmdddddddhhhhh
////////+ossyysysss+::/ssss::+ssshmNmmNNNdNNNNNNNNNNNNhhhhNNNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMNNNNNNNNNhhhymNNNNNNNNNNNmmdmmmmdmmmmmmmmdddddmddhddhhhhhhhhh
//:::--:/+ssyyyyys/--+ssssy:-+sssmmmdmmNmdNNNNNNNNNNNNyyhyyNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNhyhhymNNNmmmmmmmmmmymmmmdmmmmmmmmdhhddddhdyhhhhhhhhhh
///::---/+osssyys/--+ssyysy--+sssmmdmmmmmdmmmmmNmNNNmmhssyyymNNNNNNNNNNNNNNNNNNNNNmmmNmmNNmmmmmNNNNNNNNNNNNNNNNNNNNNhssyssmmmmmmmmmmmmmmydmmmhmmmmmmmmdhdddddhhdyyyyhhhhhh
///::--:/+osssss:-:osssssys--+ssymdmmmmdmhmmmmmmmmmmmmhyyyyyohmNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNdyssssssmmmmmmmmmmmmmmshmmmhmmmmmmmddhddddhhyhhyyyyhhhhh
///::--:/osssso--:ssssssyys--+ssyddmmmdmmhmmmmmmmmmmmmhsssssosshmNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNdyssssssssmmmmmmmmmmmmmmsymmmhdddddddddyddhhhhhhhyyyyhhhhh
///::--:/osss+--:sssssssyss--+soydmmmhmmmhmmmmmmmmmmmmhsssssossssydNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNmhsssssosssssmmmmmmmmmmmmddosdddhdddddddddyhhhhhhyyyhsyyhhhhh
////:--:+oss/--/sssssssyyss--+sohdddhddddddmmmmmmmmmmmysssssosssssoshNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNdyosossssosssssddmddddddddddhoodddhhddddddddydhhhyyyyyysyyhhhhh
////:::/+os/../ssssssssysss--/osddddhdddddhdddddddddmdyssssoosssssoossydNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNmysosssoossooooooodddddddddddddsoohdddyddddddhhyhhhhhyyyhsyshddddd
////:::/+o/../sssssssssssss--:sddddyddddddhdddddddddddyooooooooooooooo+syhmmmmmmmmmmmmmmmmmmmmmmmmmmmmhyy+oooooooooo+ooooodddddddddddddooohddhshhhhhhhhhyhhhhhhhhhssdmmmmm
++//:::/+/../sssssssssyssss--:hhddyhhdddddydddddddddddyoooooooooooo+oo+yyysydmmmmmmmmmmmmmmmmmmmmmmdyyyys+oooooo+ooo+oooosdddddddddddhhoo+yhhhshhhhhhhhhshhhhhyyyysyyddddd
++//::://../ssyyyyyysyyssss:.-hhhhyyhhdddyyhddddddddddyoooo+ooooooo+oo+sssysssyhdmmmmmmmmmmmmmmdhysssssso+oooooo+ooo+ooooshdddhhhhhhhhy+++yhhyohhhhhhhhhsyyyyysssysosyyhhh
+++/:://..:ssyyyyyyyyyyyyss/.-hhhsyyhhhhhyhyhhhhhhhddhyoooo+ooooooyhhyosssssssssssyhdmmmmmmdhyssssssssssoooo+ooo+o+++++++shhhhhhhhhhhhs+++shhsshhhhyyyyyossssssssyyosoyyhh
+++////..-ossyyyyyyyhyyyyyy+..shyyshhhhhhyhshhhhhhhhhhy++++++++ooddddddhssssssssssssssyhhysssssssssssoyhdddhyo++/++++++++shhhhhhhhhhhy++++syysoyyyyyyyyyosssssssssysooyyhh
+++///-..+ossyyyyyyyhhhhyyss..oyssyhhhhhhyhshhhhhhhhhhy++++/++++++/:/oyddyossssssssssssossssssssssssoydho+++sy++/++/+++++yhhhhhhhhhyys/+//syyooyyyyyyyyyosssssssssysossyhh
+++//-../ooossyyyyyyyhyyysyy-.:oysyyyyyyyyysyhhhhhhhhhy++++/++++--+oo/-+hdyssyyyyssoooooooooooossssshds--///::://++/++++/yyyyyyyyyyyy+////oyyooyyyyyyyysosssssssssyysooyyh
++++/...+ooossyyyyyyyyyyssyy/..ooyyyyyyysyyysyyyyyyyyyy+++//++++:yhddhs-:yhhhhhhhddhooooooooyhhhhhhhho-+hhhhhy://///////+yyyyyyyyyyys/////oyssoyssssssss+ssssssssssyy+osyy
////.``/+++ossyyyyyyyyyyosss+..+oyyyyyyyoyyysyyyyyyyyyy//////////yhhhhhy--:---:://shh+oooo+yhhs/:::::-+hhhhhh+//////////+yyyyyyyyyyyo/////osoyosssssssss+ssssssssyyyyoooyy
/::-``-///++oossssssyyyosssso..-ssssyyyyoyyyssyyyyyyyyy//////////ohhhhhhyssoooo+:..+hy+oo+yhy:.:oyhhyshhhhhyo://////////+yyyyyyyysss/////:osohosssssssss+yyyyyyyyyhhhhoohh
:::.``::://+++o++o++oo+osssss-.-ssssssssossssossssyyyyy+o+////////hhhhhhhhhhhhhhhs-.sy++++hs-.ohhhhhhhhhhyo+/:/:/://////osssssssssso::::::ssshossssssooooyyyyyyhhhhdmmo+hh
//:--:////+++oo+++///++osssss:.-ooosssssossssosssosssysossyyssossossyyyyyyyyyyyyyyo-/so+/ss:-oyyyyysyyyyy++/-:::////++o+osossssssss///////ooos+ooooooooo+syyyyyyyyyyddo+yh
*/


#include <set>
#include <map>
#include <deque>
#include <string>
#include <cstdint>
#include <cmath>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
#include <iomanip>
#include <cstring>
#include <numeric>
#include <time.h>//////////////
#include <ctime>
#include <climits>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <complex>
#include <chrono>
#include <unordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define all(a) (a).begin(), (a).end()
#define pbc push_back
#define pob pop_back()
#define vin(a) for (auto& i : a) cin >> i
#define sp system("pause")
#define mp make_pair
// mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

template<typename T1, typename T2>
inline void chkmin(T1& x, const T2& y)
{
    if (y < x) x = y;
}

template<typename T1, typename T2>
inline void chkmax(T1& x, const T2& y)
{
    if (x < y) x = y;
}
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
ld asdasdcl = 0;
double getTime() { return (clock() - asdasdcl) / (double)CLOCKS_PER_SEC; }
pair<int, int> operator-(pair<int, int> a, pair<int, int> b)
{
    return { a.first - b.first, a.second - b.second };
}
pair<int, int> operator+(pair<int, int> a, pair<int, int> b)
{
    return { a.first + b.first, a.second + b.second };
}

//#define getchar_unlocked _getchar_nolock
//inline int readInt()
//{
//    char x;
//    while (x = getchar_unlocked())
//    {
//        if (x >= '0' && x <= '9')
//        {
//            int ans = x - '0';
//            while (x = getchar_unlocked())
//
//            {
//                if (!(x >= '0' && x <= '9')) return ans;
//                ans = ans * 10 + x - '0';
//            }
//        }
//    }
//}
/*using namespace __gnu_pbds;

using ordered_set = tree<
    pair<int, int>,
    null_type,
    less<pair<int, int>>,
    rb_tree_tag,
    tree_order_statistics_node_update>;*/
const int inf = 1e16 + 228;
using namespace chrono;
const ld EPS = 1e-12;
const ld PI = acos(-1.0);
const int mod = 1000000007;
const ll INF = 1e12;

const int maxn = 300100;

int len[maxn];
int suffLink[maxn];
int to[maxn][26];
int cnt[maxn];
int numV;
string s;
int v;

void addLetter(int n, string &str)
{
    while (str[n - len[v] - 1] != str[n])
        v = suffLink[v];
    int u = suffLink[v];
    while (str[n - len[u] - 1] != str[n])
        u = suffLink[u];
    int u_ = to[u][str[n] - 'a'];
    int v_ = to[v][str[n] - 'a'];
    if (v_ == -1)
    {
        v_ = to[v][str[n] - 'a'] = numV;
        len[numV++] = len[v] + 2;
        suffLink[v_] = u_;
    }
    v = v_;
    cnt[v]++;
}

void init()
{
    memset(to, -1, sizeof to);
    len[0] = -1;
    len[1] = 0;
    suffLink[1] = 0;
    suffLink[0] = 0;
    numV = 2;

    for (int i = 0; i < 26; ++i)
    {
        to[0][i] = numV++;
        suffLink[numV - 1] = 1;
        len[numV - 1] = 1;
    }
    v = 0;
}

signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cout.precision(17), cout.setf(ios::fixed);
    string s;
    cin >> s;
    init();
    s.insert(s.begin(), '$');
    for (int i = 1; i < s.size(); ++i)
    {
        addLetter(i, s);
    }
    ll res = 0;
    for (int i = numV - 1; i >= 0; --i)
    {
        cnt[suffLink[i]] += cnt[i];
        res = max(res, 1ll * cnt[i] * len[i]);
    }
    cout << res;
    //sp;
}
//stop investigating combinatoric problems
//tle/mle - think?? wrong asympthotics??
//don't distract
//look at different ideas, don't get stuck

Compilation message

palindrome.cpp:162:22: warning: overflow in conversion from 'double' to 'int' changes value from '1.0000000000000228e+16' to '2147483647' [-Woverflow]
  162 | const int inf = 1e16 + 228;
      |                 ~~~~~^~~~~
palindrome.cpp: In function 'int main()':
palindrome.cpp:224:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  224 |     for (int i = 1; i < s.size(); ++i)
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 30804 KB Output is correct
2 Correct 14 ms 30788 KB Output is correct
3 Correct 12 ms 30848 KB Output is correct
4 Correct 13 ms 30804 KB Output is correct
5 Correct 13 ms 30820 KB Output is correct
6 Correct 13 ms 30792 KB Output is correct
7 Correct 13 ms 30804 KB Output is correct
8 Correct 14 ms 30788 KB Output is correct
9 Correct 13 ms 30884 KB Output is correct
10 Correct 15 ms 30784 KB Output is correct
11 Correct 13 ms 30804 KB Output is correct
12 Correct 13 ms 30796 KB Output is correct
13 Correct 13 ms 30804 KB Output is correct
14 Correct 13 ms 30800 KB Output is correct
15 Correct 14 ms 30776 KB Output is correct
16 Correct 14 ms 30796 KB Output is correct
17 Correct 13 ms 30880 KB Output is correct
18 Correct 14 ms 30872 KB Output is correct
19 Correct 14 ms 30804 KB Output is correct
20 Correct 14 ms 30804 KB Output is correct
21 Correct 14 ms 30880 KB Output is correct
22 Correct 14 ms 30792 KB Output is correct
23 Correct 13 ms 30804 KB Output is correct
24 Correct 13 ms 30792 KB Output is correct
25 Correct 13 ms 30796 KB Output is correct
26 Correct 17 ms 30804 KB Output is correct
27 Correct 13 ms 30804 KB Output is correct
28 Correct 13 ms 30804 KB Output is correct
29 Correct 14 ms 30884 KB Output is correct
30 Correct 14 ms 30804 KB Output is correct
31 Correct 13 ms 30884 KB Output is correct
32 Correct 13 ms 30804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 30804 KB Output is correct
2 Correct 13 ms 30804 KB Output is correct
3 Correct 13 ms 30864 KB Output is correct
4 Correct 13 ms 30804 KB Output is correct
5 Correct 13 ms 30792 KB Output is correct
6 Correct 14 ms 30804 KB Output is correct
7 Correct 14 ms 30780 KB Output is correct
8 Correct 13 ms 30852 KB Output is correct
9 Correct 14 ms 30804 KB Output is correct
10 Correct 12 ms 30888 KB Output is correct
11 Correct 15 ms 30804 KB Output is correct
12 Correct 13 ms 30808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 30932 KB Output is correct
2 Correct 12 ms 31024 KB Output is correct
3 Correct 14 ms 30932 KB Output is correct
4 Correct 15 ms 30908 KB Output is correct
5 Correct 13 ms 30932 KB Output is correct
6 Correct 14 ms 30980 KB Output is correct
7 Correct 13 ms 31040 KB Output is correct
8 Correct 13 ms 30912 KB Output is correct
9 Correct 13 ms 30804 KB Output is correct
10 Correct 13 ms 30932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 32340 KB Output is correct
2 Correct 16 ms 32468 KB Output is correct
3 Correct 16 ms 32316 KB Output is correct
4 Correct 16 ms 32340 KB Output is correct
5 Correct 16 ms 32340 KB Output is correct
6 Correct 15 ms 32032 KB Output is correct
7 Correct 16 ms 32108 KB Output is correct
8 Correct 15 ms 31192 KB Output is correct
9 Correct 14 ms 31416 KB Output is correct
10 Correct 15 ms 32084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 35040 KB Output is correct
2 Correct 22 ms 35028 KB Output is correct
3 Correct 22 ms 35108 KB Output is correct
4 Correct 22 ms 35024 KB Output is correct
5 Correct 21 ms 34996 KB Output is correct
6 Correct 21 ms 34616 KB Output is correct
7 Correct 21 ms 34452 KB Output is correct
8 Correct 18 ms 31572 KB Output is correct
9 Correct 17 ms 31608 KB Output is correct
10 Correct 20 ms 34364 KB Output is correct
11 Correct 25 ms 35008 KB Output is correct
12 Correct 18 ms 31836 KB Output is correct