atcoder 162c game tree

AtCoder Grand Contest 041

A - Table Tennis Training 如果 \(n\) 为偶数,一个 \(+1\) 一个 \(-1\) 即可。 如果 \(n\) 为奇数,那么肯定有一个先到了 \(1\) 或 \(n\),然后再 \(+1,-1\),取个较小值即可。 代码: #include<iostream> #in ......
AtCoder Contest Grand 041

AtCoder Grand Contest 040

A - >< 将所有的连续段缩起来,如果这个区间为 <,则左端点为 \(0\),依次递增;如果这个区间为 >,则右端点为 \(0\),分界点取个左右的 \(\max\) 就好了。 #include<iostream> #include<cstdio> #include<cstring> using ......
AtCoder Contest Grand 040

AtCoder Grand Contest 039

A - Connection and Disconnection 对于连续的一段连续的长度为 \(L\) 的段,至少需要 \(\frac{L}{2}\) 次操作。判下头尾相等的情况,实现时注意细节即可。 #include<iostream> #include<cstdio> #include<cst ......
AtCoder Contest Grand 039

AtCoder Grand Contest 037

A - Dividing a String 可以发现,划分后的子串的长度不可能大于 \(2\)。令 \(f_{i,1/2}\) 表示到第 \(i\) 位,当前位置划分的子串长度为 \(1/2\) 的最大的 \(K\),转移枚举一下 \(i-1,i-2\) 即可。 #include<iostream> ......
AtCoder Contest Grand 037

AtCoder Grand Contest 036

A - Triangle 考虑 \(x_1,y_1\) 选原点,构造另外两个点。考虑叉积的形式,可以得出: \[x_2y_3+x_3y_2=S \]令 \(x_2=y_3=\lceil \sqrt S\rceil\),令 \(t=S-x_2y_3\),暴力枚举 \(t\) 的因数即可。 #inclu ......
AtCoder Contest Grand 036

AtCoder Grand Contest 035

A - XOR Circle 可以发现,相邻三个数的异或和一定为 \(0\)。如果三个字符已经确定了,那么整个字符串就已经确定为这三个字符构成,且序列唯一。 如果 \(n\bmod 3\ne 0\),显然无解。 如果字符集的大小大于 \(3\),显然无解。 如果字符集的大小等于 \(3\),只有在这 ......
AtCoder Contest Grand 035

AtCoder Grand Contest 034

Kenken Race 可以分成两种情况: 当 \(A\leq B\leq C\leq D\) 时,先让 \(B\) 到 \(D\),在让 \(A\) 到 \(C\); 当 \(A\leq B\leq D\leq C\) 时,判断一下 \(B\to D\) 是否有三个连续的 .。 然后判断一下 \( ......
AtCoder Contest Grand 034

AtCoder Grand Contest 033

A - Darker and Darker 从 # 向外广搜即可。 #include<iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; const int N=1005; const i ......
AtCoder Contest Grand 033

AtCoder Grand Contest 032

A - Limited Insertion 考虑从后往前做,插数变成了删数。可以发现,我们可以删去的只有 \(a_i=i\) 的数,如果有多个肯定删最后面的是最优的,因为这样影响到的数最少。每次扫一遍找出删什么数即可。 #include<iostream> #include<cstdio> usin ......
AtCoder Contest Grand 032

AtCoder Grand Contest 030

A - Poisonous Cookies 解毒的饼干肯定所有都吃,剩下的算一下最多能吃多少毒饼干就好了。 #include<iostream> #include<cstdio> using namespace std; int A,B,C; int main() { scanf("%d%d%d", ......
AtCoder Contest Grand 030

AtCoder Grand Contest 029

A - Irreversible operation 对于某个 W 的位置,它的贡献即为前面 B 的个数,直接搞就完事了。 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int N=2 ......
AtCoder Contest Grand 029

AtCoder Grand Contest 048

A - atcoder < S 枚举操作完的串 \(s\) 和 atcoder 相同的前缀长度,算出前面的前缀相同的代价加上当前这位大于 atcoder 中对应的那一位的代价即为达到当前状态的代价,取个最小值即可。 #include<iostream> #include<cstdio> #inclu ......
AtCoder Contest Grand 048

AtCoder Grand Contest 047

A - Integer Product 考虑将原来的数全部化为整数,乘上 \(10^9\),那么问题就变成了是否有两个数的乘积是 \(10^{18}\) 的倍数。考虑如果是 \(10^{18}\) 的倍数的话必然是 \(2^{18}\) 和 \(5^{18}\) 的倍数,那么分解出每个数的 \(2, ......
AtCoder Contest Grand 047

AtCoder Grand Contest 046

A - Takahashikun, The Strider 问题就是要你求 \(ax\equiv 0 \pmod{360}\) 中 \(a\) 的最小值。 答案就是 \(a=\frac{360}{\gcd(x,360)}\)。 代码: #include<iostream> #include<cstd ......
AtCoder Contest Grand 046

AtCoder Grand Contest 045

A - Xor Battle 可以发现,从后往前扫,遇到一个 \(1\) 找后面是否有若干个 \(0\) 的位置的 \(a_i\) 与当前位置的异或和相等,用线性基维护一下就好了。 代码: #include<iostream> #include<cstdio> #include<cstring> u ......
AtCoder Contest Grand 045

AtCoder Grand Contest 044

A - Pay to Win 不妨将操作倒过来考虑,问题就变成了每次除以 \(2,3,5\) 或者 \(+1,-1\),令 \(f_n\) 表示将 \(n\) 变成 \(0\) 的最小花费,然后记忆化搜索即可,可以证明复杂度是对的。 代码: #include<iostream> #include<c ......
AtCoder Contest Grand 044

AtCoder Grand Contest 043

A - Range Flip Find Route 可以发现,一条路径的最小操作数等于路径上有多少 # 的块,令 \(f_{i,j}\) 表示到 \((i,j)\) 的最小操作次数,直接 DP 就行了。 注意路径上一个 \(1\) 的块会被算两次,需要除以 \(2\)。 #include<iostr ......
AtCoder Contest Grand 043

Merkle Tree 简介

Merkle 树(Merkle Tree)是一种树状数据结构,通常用于验证大规模数据集的完整性和一致性。它的名字来源于其发明者 Ralph Merkle。Merkle 树在密码学、分布式系统和区块链等领域得到广泛应用,尤其在区块链中,它用于验证交易和区块的完整性,确保数据不被篡改。 下面是 Merk ......
简介 Merkle Tree

AtCoder Beginner Contest 318

AtCoder Beginner Contest 318 A - Full Moon (atcoder.jp) 以\(M\)为首项,\(P\)为公差,看\(1 \sim N\)里包含了多少项的个数 #include<bits/stdc++.h> using i64 = long long; usin ......
Beginner AtCoder Contest 318

AtCoder Regular Contest 165

Preface 这场前三题是上周四写的,今天课有点多本来想着把最近两场CF的博客先写下的 但后面发现还有CCLCC的杂谈没写,写完发现由于晚上要上课没时间了,只能先把这场先写一下 A - Sum equals LCM 设\(n=\prod_{i=1}^k p_i^{c_i}\),不难发现令\(A_1 ......
AtCoder Regular Contest 165

CF1882C Card Game

某种程度上的抽卡游戏? 有这样一个结论:一个后缀中\([i+1,n]\) 中所有的正数都可以被取到,所以维护一个正数后缀和 \(s_i\),枚举每个位置 \(i\),如果 \(i\) 为奇数,答案对 \(a_i+s_{i+1}\) 取 \(\max\),否则对 \(s_{i+1}\) 取 \(\ma ......
1882C 1882 Card Game CF

abc321E - Complete Binary Tree

E - Complete Binary Tree 首先我们只考虑x子树中的答案,非常明显,一定是一个连续的区间,那么我们只需要找到两个端点即可,左端点一直往左走即可,但是右端点要注意,如果走不了,如果左端点存在,说明n就是我们的右端点。 处理完子树之后往上跳即可,因为树高只有60 #include< ......
Complete Binary 321E Tree abc

题解 AtCoder Beginner Contest 268 A~H

RobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinChenRobinC... ......
题解 Beginner AtCoder Contest 268

使用Vue3+elementPlus的Tree组件实现一个拖拽文件夹管理

目录1、前言2、分析3、 实现4、踩坑4.1、拖拽辅助线的坑4.2、数据的坑4.3、限制拖拽4.4、样式调整 1、前言 最近在做一个文件夹管理的功能,要实现一个树状的文件夹面板。里面包含两种元素,文件夹以及文件。交互要求如下: 创建、删除,重命名文件夹和文件 可以拖拽,拖拽文件到文件夹中,或着拖拽文 ......
elementPlus 文件夹 组件 文件 Vue3

module开发过程tree_ shaking

module 开发过程 tree_ shaking module 开发可以实现 tree-shaking 注意事项 ❓:什么情况下就会 tree-shaking? 💡:当我们导出模块时候使用 /* 当我们使用这种方式的时候可以进行tree-shaking */ export function na ......
过程 shaking module tree

GAMES202作业4

目录作业要求能量补全为什么会出现能量损失如何进行能量补全Kulla-Conty近似补全多次反射丢失的能量预计算E(μo)预计算Eavg还原有色物体该有的能量 作业要求 微表面模型的 BRDF(Microfacet BRDF) 存在一个根本问题,就是忽略了微平面间的多次弹射,这就导致了材质的能量损失, ......
GAMES 202

CF1710D Recover the Tree

题目链接 一个比较显然的思路就是:我们按照右端点从小到大的顺序(右端点相同按左端点从大到小)去考虑每个好的区间。 由于是连通性问题,不难想到用并查集去实时维护连通性。 根据定义,一个好的区间必定对应了一个连通块;我们考虑的是好的区间,所以当前并查集中的每个连通块必定都是一个区间。而在加入某个点前,这 ......
Recover 1710D 1710 Tree the

[abc321E]Complete Binary Tree

2023-09-23 题目 题目传送门 翻译 翻译 难度&重要性(1~10):6 题目来源 AtCoder 题目算法 模拟 解题思路 考场没调出来,考完赶紧写发题解祭奠一下。 这道题主要就是模拟,细节比较多。 思路就是一层一层的计算贡献: 如图,我们首先计算出以结点 \(x\) 为根的子树第 \(k ......
Complete Binary 321E Tree abc

E - Complete Binary Tree

E - Complete Binary Tree 完全二叉树 三个值N,X,K,分别表示点的个数,点的编号,求到X点的距离为K点的个数。 首先,我们对以X为根的子树进行分析,可以知道到X点距离为K的点的个数为2^k。这里需要特判,深度为K时最左边的编号不能大于N,点的个数就等于min(r,n)-l+ ......
Complete Binary Tree

【题解】AtCoder-ABC321

AtCoder-ABC321A 321-like Checker 依题意判断。 提交记录:Submission - AtCoder AtCoder-ABC321B Cutoff 枚举 \(a_n\),依题意模拟即可。 提交记录:Submission - AtCoder AtCoder-ABC321C ......
题解 AtCoder-ABC AtCoder ABC 321