跳到正文

个人记录

考前必看

ka_da_Duck约 2 分钟
原文
文章信息与版本

文章信息

发布
2025年10月12日
收录
2025年12月12日
更新
2026年11月16日
篇幅
约 2 分钟

版本

  1. v2当前
  2. v1
C++
#include <bits/stdc++.h>
// #define int long long
#define pb push_back

using namespace std;

/*
n >= 1e7 use read, or cin
warn (long long or __int128_t, __int128_t needs wr)
-std=c++14 -Wall -Wextra
check the time and the space
*/

signed main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	return 0;
}

初始化 fa[i], sz[i], dep[i](dep[fa] = 1), dis[i], vis[i]

字符串

  • 是一个环形结构,就在s后面再拼接一个s,其中长度为n的就是s可能的所有状态
  • 多次比较字符串,用到哈希
  • manacher数组开两倍

Warning

  1. 如果认为自己写的是正解,不要认为自己能爆标,对照数据范围和时间限制推算代码应有的复杂度。
  2. 计数题,多造小数据对拍
  3. 小心corner case

!! longlong, (哈希要unsigned),数组大小(不要一个maxn解决,看空限),多测初始化注意下标和范围,少用多次的memset。

  1. nimk
  2. 区间覆盖贪心(常见贪心套路)

gcd(a, b) = gcd(b - a, b) -> gcd(i, n) = gcd(n - i, n)

-std=c++14 -Wall -Wextra

不要压行!!!

检查每个变量是否有初始值(在main函数里的)

使用 string (马拉车), s += ’#’, s += t[i] 不要用 s[++m] = …

如果一定要, 用char。

原文