楚泫 @ 2019-02-28 15:41:08
内心无比复杂
#include <bits/stdc++.h>
#define ll long long
#define space putchar(' ')
#define endl putchar('\n')
#define debug puts("------------------------")
using namespace std;
inline void read(int &a) {a = 0; int c = getchar(), b = 1; while (c > '9' || c < '0') {if (c == '-')b = -1; c = getchar();} while (c >= '0' && c <= '9') a = (a << 3) + (a << 1) + c - 48, c = getchar(); a *= b; }
inline int Rem() {int a = 0, c = getchar(), b = 1; while (c > '9' || c < '0') {if (c == '-')b = -1; c = getchar();} while (c >= '0' && c <= '9') a = (a << 3) + (a << 1) + c - 48, c = getchar(); return a *= b; }
inline void write(int x) {if (x > 9)write(x / 10); putchar('0' + x % 10);}
inline void W(int x) {if (x < 0) {putchar('-'), x = -x;} write(x);}
/**/
const int N = 5e5 + 5;
int n, hw[N << 1], mid, mr, ans;
char a[N], s[N << 1];
/**/
int main()
{
freopen("test.in","r",stdin);
freopen("cx.out","w",stdout);
read(n);
scanf("%s", a + 1);
for (int i = 1; i <= n; i++) s[i * 2 - 1] = '$', s[i * 2] = a[i];
// s[n * 2 + 1] = '$';
for (int i = 1; i <= n * 2; i += 2)
{
hw[i] = (i < mr) ? min(hw[(mid << 1) - i], mr - i) : 1;
if (i < mr && i - hw[i] < mid) ans = max(ans, 2 * (i - mid));
while (s[i + hw[i]] == s[i - hw[i]]) ++hw[i];
if (mr < i + hw[i]) mr = i + hw[i], mid = i;
}
cout << ans << '\n';
}
by 楚泫 @ 2019-02-28 15:51:21
对不起我拍出来了我太sb了
(全谷最弱是我了
by ieeqwq @ 2019-02-28 15:51:59
@楚泫 又来个装蒟蒻的……
by ieeqwq @ 2019-02-28 15:53:14
Rank317怎么能说全洛谷最弱呢
by ニヒル @ 2019-02-28 16:02:32
@wzsCD 看来我果然可以说我是全洛谷最弱的了qwq
by ieeqwq @ 2019-02-28 16:04:53
@ニヒル 你还学了5个算法,我自从学OI以来一个算法也没有学(大雾)
by ニヒル @ 2019-02-28 16:09:26
@wzsCD 您太虚假了
by mzy2003 @ 2019-07-16 21:10:24
数组大小?