JOISC 2018 Day 1 道路建设 发现操作本质上是一个 $\text{access}$,LCT 维护即可,逆序对就把路径上的颜色块爬下来树状数组求就行了,时间复杂度 $\mathcal O(n \log^2 n)$。 const int N = 1e5 + 7; s...
AtCoder Grand Contest 044 题解
AtCoder Grand Contest 044 Pay to Win 倒着考虑,记忆化搜索一下即可。 #define ll __int128 const int o[3] = {2,3,5}; const ll inf = 1e18; ll n, a[3], d; map<ll, ll> p; inline ll f(ll x) ...
USACO 2018-2019 Platinum 题解
USACO 2018 December Contest Balance Beam 单调栈求一个上凸壳即可。 卡精度,要用 __int128。 const int N = 1e5 + 7; int n; __int128 a[N]; vi s(1, 0); inline bool pd(int i, int j, int k) { ...
OI Blogs
一些神仙的博客,没脸放到友链上所以就放这儿来。 cz_xuyixuan hzwer immortalCO Matrix67 matthew99 mcfx Menci Miskcoo nocriz OwenOwl rqy Sengxian VFleaKing yww
JOISC 2019 题解
JOISC 2019 Day1 試験 (Examination) 裸的三维偏序模板题,$\mathcal O(n \log^2 n)$ 的 CDQ 分治即可。 const int N = 6e5 + 7; int n, m, a[N], c[N], t, ans[N]; struct P { int x, y, z, o; ...
USACO 2019-2020 Platinum 题解
USACO 2019 December Contest Greedy Pie Eaters 区间 dp。 考虑最后放上去的区间,必有一个位置被新覆盖了。 枚举这个位置即可,时间复杂度 $\mathcal O(n^3)$。 const int N = 307; int n, m, a[N][N...
Codeforces Round #641 (Div. 1) 题解
Codeforces Round #641 (Div. 1) Orac and LCM 每个质因子考虑一下即可。 namespace shai { const int N = 1e6 + 7; int p[N], v[N], phi[N], miu[N]; inline void init(int n) { v[...
JOI Open 2019 题解
JOI Open 2019 三级跳 考虑 $a,b$,注意到如果存在 $a < i < b$ 且 $A_i \ge A_a$,$A_i \ge A_b$,则选择 $a,i$ 或者 $i,b$ 一定比 $a,b$ 不劣。 因此理论上可能成为答案的 $a,b$ 只有 $\mathcal O...
AtCoder Grand Contest 039 题解
AtCoder Grand Contest 039 Connection and Disconnection 分类讨论贪心。 const int N = 107; int n, c, k, t, a, b; char s[N]; int main() { rds(s, n), rd(k); for (int l = 1, r = 1; l <...
AtCoder Grand Contest 038 题解
AtCoder Grand Contest 038 01 Matrix 简单构造题。 const int N = 1e3 + 7; int n, m, a, b; int main() { rd(n, m), rd(a, b); for (int i = 1; i <= n; i++) { for (int j = 1; j ...
