线段459579152 zhuanlan atcoder

AtCoder Beginner Contest 309

A: 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<iostream> 5 #include<string> 6 #include<vector> 7 #include<stack> 8 #includ ......
Beginner AtCoder Contest 309

AtCoder Beginner Contest 273 ABCD

# [AtCoder Beginner Contest 273](https://atcoder.jp/contests/abc273) ## **A - A Recursive Function** ### Problem Statement 题意:给你一个函数$f(x)$ - $f(0)=1$ ......
Beginner AtCoder Contest ABCD 273

abc309f <线段树 + 离散化 + 双指针>

[F - Box in Box](https://atcoder.jp/contests/abc309/tasks/abc309_f) ``` // https://atcoder.jp/contests/abc309/tasks/abc309_f // [unique + lower_bound ......
线段 指针 309f abc 309

Atcoder AGC043C Giant Graph

首先能由 $10^{18(x + y + z)}$ 发现 $x + y + z$ 肯定越大越好。 于是就能想到贪心,从大到小枚举 $h = x + y + z$,若 $(x, y, z)$ 没有相连的点被选,那就选这个点。 考虑对于每条边 $(u, v)$,令 $u u, a = a, b = b$ ......
Atcoder Giant Graph 043C AGC

Atcoder ARC160C Power Up

首先有个很朴素的 DP: 设 $f_{i, j}$ 为有 $j$ 个数 $i$ 能为数 $i + 1$ 产生贡献的方案数和,这个状态的转移方程要好想一些: $f_{i, \frac{j + c_i}{2}} = \sum\limits_{k = j}^{2\times10^5} f_{i - 1, ......
Atcoder Power 160C ARC 160

Atcoder ARC163C Harmonic Mean

首先考虑到分数裂项:$\frac{1}{x} - \frac{1}{x + 1} = \frac{1}{x\times (x + 1)}$,那就有 $\frac{1}{x} = \frac{1}{x + 1} + \frac{1}{x\times (x + 1)}$。 于是构造方法就很明显了啊,首先 ......
Harmonic Atcoder 163C Mean ARC

Atcoder ARC119D Grid Repainting 3

看到方格图,便想到把行和列当成图上的点,把红点当作连接行列的边,这样就能构造出二分图。 考虑把每个连通的二分图单独拎出来考虑,能发现对其建一个生成树,只要 $u$ 节点的操作与 $son_u$ 的操作相反,则 $son_u$ 是不会干扰到 $u$ 的。 这则说明每个连通的二分图消完后肯定是只剩一行或 ......
Repainting Atcoder 119D Grid ARC

Atcoder ARC162C Mex Game on Tree

发现如果子树内如果存在 $k$ 则 $mex$ 的值必定不为 $k$,所以 Bob 的策略即为在空位填上 $k$。 Alice 的决策便可以知道是在 Bob 出手前就要让这个子树满足条件,不让 Bob 破坏这个子树,考虑需满足哪些条件: - 至多 $1$ 个空位,否则 Bob 可以把 $k$ 填在子 ......
Atcoder 162C Game Tree ARC

Atcoder ARC161C Dyed by Majority (Odd Tree)

首先能发现对于树的叶子节点,与其连边的只有其父节点,所以该节点最终状态为 $\text{B/W}$ 其父节点的状态就一定为 $\text{B/W}$。 然后考虑它自己是什么状态,因为同样的与其连边的只有其父节点,所以其父节点最终状态为 $\text{B/W}$ 其状态就为 $\text{B/W}$。 ......
Majority Atcoder 161C Dyed Tree

AtCoder Beginner Contest 309

> 感觉F写了个乱搞做法 ## [A - Nine (abc309 A)](https://atcoder.jp/contests/abc309/tasks/abc309_a) ### 题目大意 给定一个$3 \times 3$的网格,以及两个数字。 ![tu](https://img.atcode ......
Beginner AtCoder Contest 309

AtCoder Beginner Contest 178(E,F)

# AtCoder Beginner Contest 178(E,F) ## E(计算几何) 给出$n$个点坐标,我们需要知道两个不同的点之间的曼哈顿的最大的那一个,求$max(abs(x_i-x_j)+abs(y_i-y_j))$ 题意很好懂,就是如果按照最简单的想法,可以一个一个找,我们枚举不同 ......
Beginner AtCoder Contest 178

线段上的格点数量

平面坐标系上有两个格点$p_1(x_1,y_1)$和$p_2(x_2,y_2)$,求线段$p_1p_2$上除了$p_1,p_2$还有几个格点。 ## 结论 - 当斜率存在时,格点数量为 $gcd(|y_2-y_1|,|x_2-x_1|)-1$ - 当斜率不存在且$y_1\ne y_2$时,格点数量为 ......
线段 数量

AtCoder Grand Contest 058 D Yet Another ABC String

[洛谷传送门](https://www.luogu.com.cn/problem/AT_agc058_d "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/agc058/tasks/agc058_d "AtCoder 传送门") Orz H6_6Q ......
AtCoder Another Contest String Grand

AtCoder Beginner Contest 308 题解

https://atcoder.jp/contests/abc308/tasks_print # A - New Scheme 过水已隐藏。 代码: ```cpp #include #include #include #include using namespace std; using names ......
题解 Beginner AtCoder Contest 308

CF1842E Tenzing and Triangle - 线段树优化 dp -

题目链接:https://codeforces.com/contest/1842/problem/E 题解: 首先,如果两个等腰三角形相交了,那答案肯定不会更优。因此不会相交。 先考虑一个 $n^2$ 的 dp: 设 $dp_i$ 表示考虑到 $x=i$ 时的最小代价,首先可以先都加一个 $\sum ......
线段 Triangle Tenzing 1842E 1842

AtCoder Beginner Contest 264 ABCDE

# [AtCoder Beginner Contest 264](https://atcoder.jp/contests/abc264) ## **A - "atcoder".substr()** ### Problem Statement 题意:截取字符串 `atcoder`的[L,R]一段并输出 ......
Beginner AtCoder Contest ABCDE 264

李超线段树模板

细节和理解详见注释 题目:https://www.luogu.com.cn/problem/P4097 ```c++ #include using namespace std; #define int long long const int mod1=39989; const int mod2=1e ......
线段 模板

【DS】【AtCoder】Pakencamp 2022 Day2 H

2023.6.30 [Problem Link](https://atcoder.jp/contests/pakencamp-2022-day2/tasks/pakencamp_2022_day2_h) 有 $n$ 个帮派在打架,每个帮派有一个大小 $a_i$,每相邻两个帮派有一个仇恨度 $b_i$ ......
Pakencamp AtCoder 2022 Day2 Day

AtCoder Regular Contest 163

### [A](https://atcoder.jp/contests/arc163/tasks/arc163_a) 只需暴力判断能否分成两部分即可。 时间复杂度 $\mathcal{O}(n^2)$。 ### [B](https://atcoder.jp/contests/arc163/tasks ......
AtCoder Regular Contest 163

AtCoder Beginner Contest 304

A: 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<iostream> 5 #include<string> 6 #include<vector> 7 #include<stack> 8 #includ ......
Beginner AtCoder Contest 304

李超线段树

### 引入与概括 思考下列问题: 在平面直角坐标系中维护集合,支持下列操作: - 加入一个定义域为 $[l,r]$ 的一次函数。 - 查询所有定义域包含 $x$ 的一次函数的函数值的最值。 我们发现,这可以看成一个区间修改,单点查询的问题,考虑使用线段树维护。 但我们发现传统线段树难以维护,于是李 ......
线段

线段树分治 学习笔记

离线算法。在时间轴上建线段树(可能要事先离散化),要维护的东西用 `vector` 什么的挂在线段树的节点上,DFS 一遍线段树,每次进入一个节点就加入要维护的东西,离开时撤销即可。 由于 DFS 的特性,只需支持最近的 `undo`,用 `stack` 可维护。 ......
线段 笔记

AtCoder Grand Contest 033 D Complexity

[洛谷传送门](https://www.luogu.com.cn/problem/AT_agc033_d "洛谷传送门") [AtCoder 传送门](https://atcoder.jp/contests/agc033/tasks/agc033_d "AtCoder 传送门") 这题感觉实在太 e ......
Complexity AtCoder Contest Grand 033

线段树区间查改(懒标记+代码细节)

就如同我上次写链式前向星一样,这次我又一次在模拟赛中打算混点分。经过我缜密的思考基于暴力的猜测,我认为带懒操作的线段树至少可以混70分!(大雾弥漫)。于是我兴冲冲的开始敲代码,然后……线段树就打挂了……比赛结束后我痛定思痛,决定要好好复习一下线段树,然后经过我一下午的折腾,我终于……陷在bug的泥沼 ......
线段 区间 标记 细节 代码

[Java]线段树

# 线段树 ## 不含懒标记(单点修改) ![image-20230704210835506](https://pic-typora-nb.oss-cn-hangzhou.aliyuncs.com/img/image-20230704210835506.png) ### 代码 **维护区间最大/最小 ......
线段 Java

线段树

# 引入 用来维护**区间信息**的数据结构 可以在 $O(\log N)$ 的时间复杂度内实现单点修改、区间修改、区间查询(区间求和,求区间最大值、最小值)等操作。 # 线段树的基本结构与建树 ## 过程 将每个长度不为 $1$ 的区间划分成左右两个区间递归求解,把整个线段划分为一个树形结构,通过 ......
线段

AtCoder Beginner Contest 308 - E

题目链接:[abc 308](https://atcoder.jp/contests/abc308) 前四题简单就不放了 #### [E - MEX](https://atcoder.jp/contests/abc308/tasks/abc308_e) 阿巴阿巴,比赛的时候想复杂了,一直在想怎么快速 ......
Beginner AtCoder Contest 308

Atcoder Beginer Contest 306 D ~ E

vp中途突然拉肚子>_ using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; array dp; for(int ......
Atcoder Beginer Contest 306

AtCoder Regular Contest 163

# Preface 补题,这场比赛的时候被拉去开科研组会了,所以就没现场打了 这两天军训在伤病连划水,白天可以好好想题目舒服的一批 这场D题确实很妙,需要一些竞赛图相关的知识才能想到转化,不过也算是学到一个重要trick了吧 # **A - Divide String** 显然只要考虑能否分成两个串 ......
AtCoder Regular Contest 163

线段树

[toc] # 线段树 ## 例题 ## 相关资料 ......
线段