/*
_ _ _______ _ _
| | / / | _____| | | / /
| | / / | | | | / /
| |/ / | |_____ | |/ /
| |\ \ | _____| | |\ \
| | \ \ | | | | \ \
| | \ \ | |_____ | | \ \
|_| \_\ |_______| |_| \_\
*/
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair < ll, int > PLI;
#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek
#define fname ""
const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;
int d[N], mn[N];
ll hs[N], p[N], pr = 37;
char a[N], b[N];
ll get(int l, int r) {
return (hs[r] - hs[l - 1] * p[r - l + 1] % base + base) % base;
}
int main() {
ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef krauch
freopen("input.txt", "r", stdin);
#else
//freopen(fname".in", "r", stdin);
//freopen(fname".out", "w", stdout);
#endif
int T;
scanf("%d\n", &T);
while (T--) {
gets(b);
scanf("\n");
int n = 1;
while ('a' <= b[n] && b[n] <= 'z') ++n;
p[0] = 1;
forn(i, 1, n) {
a[i] = b[i - 1];
hs[i] = (hs[i - 1] * pr + a[i] - 'a') % base;
p[i] = p[i - 1] * pr % base;
}
if (n & 1) d[n / 2 + 1] = 1;
else d[n / 2 + 1] = 0;
mn[n / 2 + 1] = 0;
for1(i, n / 2, 1) {
mn[i] = 0;
forn(j, 1, n / 2 - i + 1) {
if (get(i, i + j - 1) == get(n - i - j + 2, n - i + 1)) {
mn[i] = j;
break;
}
}
if (mn[i]) d[i] = d[i + mn[i]] + 2;
else d[i] = 1;
}
cout << d[1] << "\n";
}
return 0;
}
Compilation message
palindromic.cpp: In function 'int main()':
palindromic.cpp:65:15: error: 'gets' was not declared in this scope
gets(b);
^
palindromic.cpp:63:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d\n", &T);
^
palindromic.cpp:66:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("\n");
^