当前位置:网站首页>【学习笔记】AGC041
【学习笔记】AGC041
2022-07-26 04:18:00 【仰望星空的蚂蚁】
Domino Quality
- atcoder简洁题面好评
做构造题要有耐心- 好阴间的构造题啊。。。
- 设 ( A , Q ) (A,Q) (A,Q)表示每行每列数量为 Q Q Q的 A × A A\times A A×A大小的矩阵
- 如果我们知道 ( A , Q ) (A,Q) (A,Q)以及 ( B , Q ) (B,Q) (B,Q)的构造方法,我们就能构造出 ( A + B , Q ) (A+B,Q) (A+B,Q)
- 具体做法是把两个矩阵分别放在左上角和右下角,其余为空
- 显然考虑 Q = 3 Q=3 Q=3的情况
并不显然 - 显然可以把 ( 4 , 3 ) , ( 5 , 3 ) , ( 6 , 3 ) , ( 7 , 3 ) (4,3),(5,3),(6,3),(7,3) (4,3),(5,3),(6,3),(7,3)全部暴搜出来
- 显然可以打表
反正这题考点也不在这 诶n=7怎么暴力跑不出来呀诶加了玄学剪枝怎么就跑得飞快呀代码一堆打表非常丑陋甚至输出也很丑陋
Unique Path
- 美妙的构造题
虽然我还是做不出来 - 显然删去所有边权为 1 1 1的边,对于每个连通块内的点两两有唯一简单路径
- 先不忙对每个连通块缩点,首先我们从每个连通块中选取一个点,然后把它们连成一个环,这样对于不在同一个连通块内的点有至少两条简单路径
- 设连通块数目为 k k k(上述构造恰连了 k k k条边,构成一颗基环树),那么跨连通块边的数目不会超过 k ( k − 1 ) 2 \frac{k(k-1)}{2} 2k(k−1),否则一个连通块不能保持其独立性
- 因此我们只要判断 m m m的大小是否在范围内即可。
- 复杂度 O ( n ) O(n) O(n)。
- 总结:考虑答案的上下界
Wide Swap
兔兔的题解- 考虑一个好的问题转化
- 设 Q [ i ] Q[i] Q[i]表示 i i i在原序列中的位置
- 那么交换 Q [ i ] Q[i] Q[i]和 Q [ i + 1 ] Q[i+1] Q[i+1]的条件是 ∣ Q [ i ] − Q [ i + 1 ] ∣ ≥ K |Q[i]-Q[i+1]|\ge K ∣Q[i]−Q[i+1]∣≥K
- 如果 i < j i<j i<j, ∣ Q [ i ] − Q [ j ] ∣ < K |Q[i]-Q[j]|<K ∣Q[i]−Q[j]∣<K那么 Q [ i ] Q[i] Q[i]和 Q [ j ] Q[j] Q[j]的相对位置关系不会发生改变,换句话说 Q [ i ] Q[i] Q[i]永远在 Q [ j ] Q[j] Q[j]之前
- 那么我们让 Q [ i ] → Q [ j ] Q[i]\to Q[j] Q[i]→Q[j]这样跑出来的拓扑序一定是满足限制的
- 同时我们要让 P P P的字典序最小,转化成 1 1 1在 Q Q Q中最靠前,在 1 1 1最靠前的前提下让 2 2 2最靠前
- 这是一个经典问题
不要再经典了我都wa过一遍了可以建反图跑最大拓扑序解决 - 可以按编号从小到大考虑 Q [ i ] Q[i] Q[i],我们发现只要找到 Q [ i ] Q[i] Q[i]的前驱编号最大和后继编号最大连边即可。
- 复杂度 O ( n log n ) O(n\log n) O(nlogn)
Nondivisible Prefix Sums
- Hint1:所有元素之和不能被 P P P整除
显然 - Hint2:众数出现次数不超过 n 2 \frac{n}{2} 2n的序列合法(可以倒着考虑
- Hint3:有一个巧妙的转化。设众数为 x x x,将所有元素乘 x − 1 x^{-1} x−1,那么前缀和也会乘 x − 1 x^{-1} x−1
- Hint4:
巧妙的观察注意到每跨过 P P P都会消耗至少一个不为 1 1 1的数字 - 那么不为 1 1 1的数字至少有 ∑ i = 1 n y i P \frac{\sum_{i=1}^ny_i}{P} P∑i=1nyi个
- 考虑构造方案,首先把所有数字 1 1 1用完,然后对于剩下的只要我们让它不到达 P P P
- 显然去掉众数后是有解的
边栏推荐
- 图互译模型
- Implementation of distributed lock
- 机器学习之桑基图(用于用户行为分析)
- 低成本、快速、高效搭建数字藏品APP、H5系统,扇贝科技专业开发更放心!
- JS upload avatar (you can understand it after reading it, trust me)
- Huawei issued another global convening order of "genius youth", and some people once gave up their annual salary of 3.6 million to join
- 【第019问 Unity中对SpherecastCommand的理解?】
- Small ball and box model, arrangement and combination
- 【二叉树】二叉树中的最长交错路径
- How to build an enterprise level OLAP data engine for massive data and high real-time requirements?
猜你喜欢

HelloWorld case analysis

Pathmatchingresourcepatternresolver parsing configuration file resource file
远坂凛壁纸

makefile知识再整理(超详细)

Verilog implementation of key dithering elimination

综合评价与决策方法

Lua and go mixed call debugging records support cross platform (implemented through C and luajit)

Communication protocol and message format between microservices

APISIX 在 API 和微服务领域的探索

Makefile knowledge rearrangement (super detailed)
随机推荐
Soft simulation rasterization renderer
Life related -- the heartfelt words of a graduate tutor of Huake (mainly applicable to science and Engineering)
座椅/安全配置升级 新款沃尔沃S90行政体验到位了吗
【SVN】一直出现 Please execute the ‘Cleanup‘ command,cleanup以后没有反应的解决办法
Educational Codeforces Round 132 (Rated for Div. 2) E. XOR Tree
Acwing第 61 场周赛【完结】
支持代理直连Oracle数据库,JumpServer堡垒机v2.24.0发布
How is the launch of ros2 different?
Helloworld案例分析
Lua and go mixed call debugging records support cross platform (implemented through C and luajit)
当你尝试删除程序中所有烂代码时 | 每日趣闻
JS get some attributes of the object
Acwing_12. 背包问题求具体方案_dp
2022杭电多校 Bowcraft
How to write the summary? (including 7 easily ignored precautions and a summary of common sentence patterns in 80% of review articles)
Implementation of distributed lock
makefile知识再整理(超详细)
图互译模型
Recommendation | DBT skills training manual: baby, you are the reason why you live
软模拟光栅化渲染器