当前位置:网站首页>[learning notes] agc010
[learning notes] agc010
2022-07-07 13:09:00 【Ants looking up at the starry sky】
Do more AGC Long brain
No samples , Just rely on your brain
Rearranging
- Consider if two numbers are not mutually prime , Then their relative positions in the final sequence remain unchanged
- So for two numbers that are not coprime , At the same time, orient each edge DAG
- The answer is the largest topological order , Because considering that a point can be exchanged with any other point without entering
- Greedy structure . Start from the point with the lowest number dfs , Find the edge with the lowest node number every time , It can be understood as constructing a tree .
- Then simulate it (
Tiling
- Greedy to consider how to maximize the grid
- Obviously, the mesh is divided into several 2x2 The matrix of is optimal
- The leftover materials are paved with corresponding horizontal bricks or vertical bricks
- This will definitely maximize the number of bricks
- Hand play discovery n=3,m=3,A=2,B=2 There will be problems ( Here hack Data is the difficulty
- That is to say, for the last 2x2 Of the lattice , There is one horizontal brick and one vertical brick left , Theoretically, it can lay two bricks , But due to the shape, only one piece can be paved

- Notice that there is a space in the lower right corner , You can put it down by adjusting .

- There are two schemes directly check that will do .
- Notice the grid problem Nastia and a Beautiful Matrix , from Maximize the use of grid space Starting with , Find the local optimum , Then the global optimal solution is constructed .
Three Circuits
- The degree of each point must be even
- The title gives that this is a connected graph , So there must be an Euler circuit
- If there are degrees of points >=6 , Then there must be a solution ( Consider proving from the perspective of Euler loop
- Count the degree = 4 The number of points is cnt
- If cnt=0 , Then only one ring can be constructed at most
- If cnt=1 , Then only two rings can be constructed at most
- If cnt=2 , So there are two situations ( Drawing perception : It is possible to construct two rings or three rings
- If cnt>=3 , Then remove a simple ring and conclude cnt=2 The situation of , At least three rings can be constructed
Decrementing
- If there is a i = 1 a_i=1 ai=1 , So judge ∑ ( a i − 1 ) \sum{(a_i-1)} ∑(ai−1) Parity .
- Definition ∑ ( a i − 1 ) \sum{(a_i-1)} ∑(ai−1) Odd numbers are wins , Even numbers are negative
- If the person currently operating wins , So no matter what the other person does , At present, this person will win
- Because if you don't divide all numbers by the greatest common divisor , ∑ a i \sum a_i ∑ai The parity of does not change , that ∑ ( a i − 1 ) \sum (a_i-1) ∑(ai−1) The parity of will not change , The outcome is fixed
- Now it's equivalent to ∑ a i → ∑ a i x \sum{a_i}\to \frac{\sum{a_i}}{x} ∑ai→x∑ai , If and only if x x x It's even and ∑ a i x \frac{\sum{a_i}}{x} x∑ai Only when it is an odd number
- Note that the number of odd numbers in the sequence is cnt , At first, because of mutual prime cnt>=1 , Then two people take turns , Those who are behind can never let cnt=0 (n>=3 when )
- If the current operation fails , Then operate on the only odd number , This may reverse the outcome .
- So direct simulation . Not more than log a \log a loga Time .
边栏推荐
- Session
- leecode3. 无重复字符的最长子串
- Day21 multithreading
- LIS 最长上升子序列问题(动态规划、贪心+二分)
- The difference between cache and buffer
- How does MySQL create, delete, and view indexes?
- . Net ultimate productivity of efcore sub table sub database fully automated migration codefirst
- COSCon'22 社区召集令来啦!Open the World,邀请所有社区一起拥抱开源,打开新世界~
- 为租客提供帮助
- 迅为iTOP-IMX6ULL开发板Pinctrl和GPIO子系统实验-修改设备树文件
猜你喜欢

Milkdown 控件图标

. Net ultimate productivity of efcore sub table sub database fully automated migration codefirst

.Net下极限生产力之efcore分表分库全自动化迁移CodeFirst

《开源圆桌派》第十一期“冰与火之歌”——如何平衡开源与安全间的天然矛盾?

Ogre入门尝鲜

DETR介绍

Go语言学习笔记-结构体(Struct)

Differences between MySQL storage engine MyISAM and InnoDB

Leetcode question brushing: binary tree 26 (insertion operation in binary search tree)

飞桨EasyDL实操范例:工业零件划痕自动识别
随机推荐
DrawerLayout禁止侧滑显示
Practical example of propeller easydl: automatic scratch recognition of industrial parts
MySQL导入SQL文件及常用命令
Leetcode brush question: binary tree 24 (the nearest common ancestor of binary tree)
Query whether a field has an index with MySQL
Sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
[untitled]
Leetcode skimming: binary tree 25 (the nearest common ancestor of binary search tree)
人均瑞数系列,瑞数 4 代 JS 逆向分析
shell 批量文件名(不含扩展名)小写改大写
基于鲲鹏原生安全,打造安全可信的计算平台
单片机原理期末复习笔记
Ip2long and long2ip analysis
Leetcode skimming: binary tree 22 (minimum absolute difference of binary search tree)
Blog recommendation | Apache pulsar cross regional replication scheme selection practice
php——laravel缓存cache
飞桨EasyDL实操范例:工业零件划痕自动识别
Common text processing tools
Practical case: using MYCAT to realize read-write separation of MySQL
Day22 deadlock, thread communication, singleton mode