Skip to content

Commit

Permalink
🚀 Deploying to gh-pages @ 31eb8ea
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jun 21, 2024
0 parents commit 399c36b
Show file tree
Hide file tree
Showing 426 changed files with 69,854 additions and 0 deletions.
Empty file added .nojekyll
Empty file.
21 changes: 21 additions & 0 deletions 404.html

Large diffs are not rendered by default.

Empty file added TI1049/.nojekyll
Empty file.
1,255 changes: 1,255 additions & 0 deletions TI1049/2020/nowcoder-national-day-training-party/day1/index.html

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions TI1049/2020/nowcoder-national-day-training-party/day1/solutions/a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
using db = double;
using ll = long long;
using ull = unsigned long long;
using pII = pair<int, int>;
using pLL = pair<ll, ll>;
constexpr int mod = 1e9 + 7;
template <class T1, class T2>
inline void chadd(T1 &x, T2 y, int Mod = mod) {
x += y;
while (x >= Mod) x -= Mod;
while (x < 0) x += Mod;
}
template <class T1, class T2>
inline void chmax(T1 &x, T2 y) {
if (x < y)
x = y;
}
template <class T1, class T2>
inline void chmin(T1 &x, T2 y) {
if (x > y)
x = y;
}
inline int nextInt() {
int x;
cin >> x;
return x;
}
void rd() {}
template <class T, class... Ts>
void rd(T &arg, Ts &...args) {
cin >> arg;
rd(args...);
}
#define dbg(x...) \
do { \
cout << "\033[32;1m" << #x << " -> "; \
err(x); \
} while (0)
void err() {
cout << "\033[39;0m" << endl;
}
template <class T, class... Ts>
void err(const T &arg, const Ts &...args) {
cout << arg << ' ';
err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &...args) {
for (auto &v : arg) cout << v << ' ';
err(args...);
}
void ptt() {
cout << endl;
}
template <class T, class... Ts>
void ptt(const T &arg, const Ts &...args) {
cout << ' ' << arg;
ptt(args...);
}
template <class T, class... Ts>
void pt(const T &arg, const Ts &...args) {
cout << arg;
ptt(args...);
}
void pt() {}
template <template <typename...> class T, typename t, typename... A>
void pt(const T<t> &arg, const A &...args) {
for (int i = 0, sze = arg.size(); i < sze; ++i) cout << arg[i] << " \n"[i == sze - 1];
pt(args...);
}
inline ll qpow(ll base, ll n) {
assert(n >= 0);
ll res = 1;
while (n) {
if (n & 1)
res = res * base % mod;
base = base * base % mod;
n >>= 1;
}
return res;
}
// head
constexpr int N = 4e5 + 10;
int n;
char s[N];

struct Manacher {
int len, l;
char Ma[N << 1];
int Mp[N << 1];
void work(char *s) {
len = strlen(s);
l = 0;
Ma[l++] = '$';
Ma[l++] = '#';
for (int i = 0; i < len; ++i) {
Ma[l++] = s[i];
Ma[l++] = '#';
}
Ma[l] = 0;
int mx = 0, id = 0;
for (int i = 0; i < l; ++i) {
Mp[i] = mx > i ? min(Mp[2 * id - i], mx - i) : 1;
while (Ma[i + Mp[i]] == Ma[i - Mp[i]]) Mp[i]++;
if (i + Mp[i] > mx) {
mx = i + Mp[i];
id = i;
}
}
}
bool check(int l, int r) {
int il = (l + 1) * 2, ir = (r + 1) * 2;
int mid = (il + ir) / 2;
int len = (r - l + 2) / 2;
return (Mp[mid] / 2) >= len;
}
} man;

void run() {
rd(n);
cin >> s;
man.work(s);
for (int i = 0; i < n; ++i) {
if (man.check(i, n - 1))
return pt(i);
}
}

int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cout << fixed << setprecision(20);
int _T = 1;
// nextInt();
while (_T--) run();
// for (int kase = 1; kase <= _T; ++kase) {
// cout << "Case #" << kase << ": ";
// run();
// }
// while (cin >> n) run();
// run();
return 0;
}
Loading

0 comments on commit 399c36b

Please sign in to comment.